netfishers-onl / Netshot

Network Configuration and Compliance Management
http://www.netfishers.onl/netshot
242 stars 57 forks source link

Cisco devices - SN display #244

Open pfunkylol opened 1 year ago

pfunkylol commented 1 year ago

Hi,

This is more of a cosmetic issue, but i was wondering why in General > Serial Number field, it's not always populated or when it is populated it has the wrong SN in it, like for a module/transceiver the device has.

I have compared the output of the command : show inventory and the regex in the Cisco_IOS.js script and they seem to capture the right thing.

e.g. i have the following in the Module tab for a device , but nothing is displayed in SN

CISCO1921/K9 CISCO1921/K9 FCZZZZZZ 4 Port FE Switch on Slot 0 SubSlot 0 HWIC-4ESW FOCXXXXX

Another device, same model has the SN of the switch module in it

CISCO1921/K9 chassis CISCO1921/K9 FCAAAAA 4 Port FE Switch on Slot 0 SubSlot 0 HWIC-4ESW FOCBBBBB

Regards, Paul

SCadilhac commented 1 year ago

Hello, the current version of the Cisco IOS driver looks for "chassis" in the show inventory output to identify the main part and assigns the corresponding serial number as main serial number of the device. This doesn't seem to work properly with Cisco 1921... Can you post full examples of show inventory taken from your devices (but with fake serial numbers) so we can adjust the driver code?

pfunkylol commented 1 year ago

Hello,

show inventory NAME: "CISCO1921/K9", DESCR: "CISCO1921/K9 chassis, Hw Serial#: FCXXXXXXXX, Hw Revision: 1.0" PID: CISCO1921/K9 , VID: V05 , SN: FCXXXXXXXX

NAME: "4 Port FE Switch on Slot 0 SubSlot 0", DESCR: "4 Port FE Switch" PID: HWIC-4ESW , VID: V01 , SN: FOCXXXXXCR

I would say that this is not necessarily relate to 1921 products but to others as well. A observation would be that if the word "/Chassis/" isn't found, it just displays the output of the last module / line that it can parse having serialNumber: match[5] .

This would be another example

NAME: "chassis", DESCR: "1841 chassis" PID: CISCO1841 , VID: V05 , SN: FCZXXXXXX

NAME: "WIC/HWIC 0", DESCR: "4 Port FE Switch" PID: HWIC-4ESW , VID: V01 , SN: FOCXXXXXXX

SCadilhac commented 1 year ago

So we could match for /[Cc]hassis/. What is the full example (show inventory) of the 1921 where the serial number of the switch module gets captured as main serial number?

pfunkylol commented 1 year ago

I can confirm that it works with /[Cc]hassis/ for that router family. As for 1921, that is the whole output.

I've tested with the following code and appears to do the trick.

if (module.slot.match(/[Cc]hassis/)) { device.set("serialNumber", module.serialNumber); } if (module.slot.match(/CISCO1921/)) { device.set("serialNumber", module.serialNumber); }

pfunkylol commented 1 year ago

Hi,

I would require your help another issue if you could and have the time. For stack switches, i would like to display in the Serial Number field the SN for both ( SW1: SN1 / SW2: SN2 ), right now it's only displayed for the last member in the stack.

I assume that would require some kind of a loop to see if there's one configure, something like if in the show inventory command there is a NAME: "1" and a NAME: "2" and the PID is the same to set the SN for each of the one.

show inventory
NAME: "1", DESCR: "WS-C3750G-24TS"
PID: WS-C3750G-24TS-S  , VID: M0 , SN: CATXXXX

NAME: "2", DESCR: "WS-C3750G-24TS"
PID: WS-C3750G-24TS-S  , VID: V08, SN: FDOYYYY

BR, Paul