Update regex sh ver
This commit is contained in:
parent
6a9a3fb350
commit
4a1217fbfa
|
|
@ -3,12 +3,14 @@ import XRegExp from 'xregexp'
|
|||
// Parser function
|
||||
const parseLog = (data: string) => {
|
||||
const patterns = [
|
||||
// 1. Software Image & Version
|
||||
XRegExp(
|
||||
'^.*Software.*\\((?<SOFTWARE_IMAGE>\\S+)\\),\\s+Version\\s+(?<VERSION>.+?),\\s+RELEASE.*\\((?<RELEASE>\\S+)\\)'
|
||||
),
|
||||
XRegExp('Active-image:\\s+(?<SOFTWARE_IMAGE>\\S+)'),
|
||||
XRegExp('Version:\\s+(?<VERSION>\\S+)'),
|
||||
XRegExp('^ROM:\\s+(?<ROMMON>\\S+)'),
|
||||
// 2. Uptime
|
||||
XRegExp('^(?<HOSTNAME>\\S+)\\s+uptime\\s+is\\s+(?<UPTIME>.+)'),
|
||||
XRegExp('Date:\\s+(?<UPTIME>\\S+)'),
|
||||
XRegExp('uptime\\s+is.*\\s+(?<UPTIME_YEARS>\\d+)\\syear'),
|
||||
|
|
@ -16,20 +18,26 @@ const parseLog = (data: string) => {
|
|||
XRegExp('uptime\\s+is.*\\s+(?<UPTIME_DAYS>\\d+)\\sday'),
|
||||
XRegExp('uptime\\s+is.*\\s+(?<UPTIME_HOURS>\\d+)\\shour'),
|
||||
XRegExp('uptime\\s+is.*\\s+(?<UPTIME_MINUTES>\\d+)\\sminute'),
|
||||
// 3. Reload Reason & Serial
|
||||
XRegExp('System\\s+image\\s+file\\s+is\\s+"(?:.*?):(?<RUNNING_IMAGE>\\S+)"'),
|
||||
XRegExp('(?:Last reload reason:|System returned to ROM by)\\s+(?<RELOAD_REASON>.+)'),
|
||||
XRegExp('[Pp]rocessor\\s+board\\s+ID\\s+(?<SERIAL>\\w+)'),
|
||||
// 4. MEMORY & HARDWARE
|
||||
XRegExp('^(?<MEMORY>\\d+[KMG])\\s+bytes\\s+of\\s+physical\\s+memory', 'i'),
|
||||
XRegExp(
|
||||
'[Cc]isco\\s+(?<HARDWARE>\\S+|\\S+\\d\\S+)\\s+\\(.+\\)\\s+with\\s+(?<MEMORY>.+)\\s+bytes'
|
||||
'[Cc]isco\\s+(?<HARDWARE>\\S+)\\s+\\(.+?\\)\\s+processor\\s+with\\s+(?<MEMORY>\\d+[KMG]\\/\\d+[KMG])\\s+bytes\\s+of\\s+memory',
|
||||
'i'
|
||||
),
|
||||
// XRegExp("^(?<USB_FLASH>.+)\\s+bytes\\s+of\\s+[Uu][Ss][Bb]+\\s+[Ff]lash"),
|
||||
// 5. Flash / Storage
|
||||
XRegExp(
|
||||
'^(?<USB_FLASH>.+?)\\s+bytes\\s+of\\s+(?:' +
|
||||
'[Uu][Ss][Bb]+\\s+[Ff]lash' + // USB Flash
|
||||
'|ATA\\s+System\\s+CompactFlash.*' + // ATA System CompactFlash
|
||||
'|flash\\s+memory\\s+at\\s+bootflash:' + // flash memory at bootflash
|
||||
')'
|
||||
'^(?<USB_FLASH>\\d+[KMG])\\s+bytes\\s+of\\s+(?:' +
|
||||
'[Uu][Ss][Bb]+\\s+[Ff]lash' +
|
||||
'|ATA\\s+System\\s+CompactFlash.*' +
|
||||
'|flash\\s+memory\\s+at\\s+bootflash:' +
|
||||
')',
|
||||
'i'
|
||||
),
|
||||
// 6. Config & MAC
|
||||
XRegExp(
|
||||
'Base\\s+[Ee]thernet\\s+MAC\\s+[Aa]ddress\\s+:\\s+(?<MAC_ADDRESS>[0-9a-fA-F]{2}(?::[0-9a-fA-F]{2}){5})'
|
||||
),
|
||||
|
|
@ -65,10 +73,12 @@ const parseLog = (data: string) => {
|
|||
if (match) {
|
||||
const item = match?.groups || {}
|
||||
Object.keys(item).forEach((key) => {
|
||||
// Chỉ update nếu giá trị tìm thấy không undefined
|
||||
if (item[key] !== undefined) {
|
||||
records[key] = item[key]
|
||||
}
|
||||
})
|
||||
// Break inner loop (patterns) để sang dòng tiếp theo
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -264,7 +264,7 @@ export default function ModalConfigRamFlash({ opened, onClose }: Props) {
|
|||
size="xs"
|
||||
/>
|
||||
<TextInput
|
||||
label="Ram"
|
||||
label="RAM"
|
||||
placeholder="Enter ram"
|
||||
style={{ width: "200px" }}
|
||||
value={newConfig?.ram}
|
||||
|
|
@ -319,7 +319,7 @@ export default function ModalConfigRamFlash({ opened, onClose }: Props) {
|
|||
<Table.Tr>
|
||||
<Table.Th style={{ textAlign: "center" }}>Models</Table.Th>
|
||||
<Table.Th w={150} style={{ textAlign: "center" }}>
|
||||
Ram
|
||||
RAM
|
||||
</Table.Th>
|
||||
<Table.Th w={150} style={{ textAlign: "center" }}>
|
||||
Flash
|
||||
|
|
|
|||
Loading…
Reference in New Issue