crinv (Create Inventory Report)
crinv is a perl script that processes a text file with a list of devices (routers & switches), then it gets info from them by using the SNMP Entity-MIB, and finally it creates a csv file with parts per device in a hierarchical format.
- The general format of each line is
"device|community"
- Only device is required, community is optional
- All white spaces are removed before processing each line
- Lines starting with
#
are comments and will be ignored - Lines starting with
|
are ignored - The
|
character must be used on each line for seperation between device and community - Devices without a community use the default/cli community
- Lines without a
|
character are considered to be devices and use the default/cli community
In order to make the output seem hierarchical, the following two parameters are used inside the script:
my $left_space = " "; # This can be any character(s) you want to use to produce the left indent effect
# spaces are prefered because tab characters do not show up in Excel
my $display_level = 1; # This must be 1 for hierarchical output
All output filenames are created automatically after removing any extension from the input filename and adding the right string to it.
If the input file is named devices.txt
, then the following output files are created:
devices.csv
(file that contains the generated report of part numbers per device in csv format)devices-error.txt
(file that contains the list of devices that returned error in SNMP walk)devices-null.txt
(file that contains the list of devices that returned null in SNMP walk)devices-other.txt
(file that contains the list of devices that returned other error in SNMP walk)
Process all devices from devices.txt
and use SNMP-COMM as a community name for devices that don't have one:
crinv -d devices.txt -c SNMP-COMM
Process all devices from devices.txt
and use the default community (public) for devices that don't have one:
crinv -d devices.txt
Collected snmp data are like the following
- 1.3.6.1.2.1.47.1.1.1.1.13.1 = "CISCO7609"
- 1.3.6.1.2.1.47.1.1.1.1.13.14 = "FAN-MOD-09"
- 1.3.6.1.2.1.47.1.1.1.1.13.17 = "FAN-MOD-09"
- 1.3.6.1.2.1.47.1.1.1.1.13.20 = "WS-CAC-4000W-INT"
- 1.3.6.1.2.1.47.1.1.1.1.13.29 = "WS-CAC-4000W-INT"
- 1.3.6.1.2.1.47.1.1.1.1.13.40 = "WS-C6K-VTT"
Then $entPhysicalModelName (1.3.6.1.2.1.47.1.1.1.1.13)
becomes a hash
i.e.
$entPhysicalModelName{'1'} = 'CISCO7609'
$entPhysicalModelName{'14'} = 'FAN-MOD-09'
The following information can be included in the generated csv file:
entPhysicalDescr
: A textual description of physical entityentPhysicalName
: The textual name of the physical entityentPhysicalHardwareRev
: The vendor-specific hardware revision string for the physical entityentPhysicalFirmwareRev
: The vendor-specific firmware revision string for the physical entityentPhysicalSoftwareRev
: The vendor-specific software revision string for the physical entityentPhysicalSerialNum
: The vendor-specific serial number string for the physical entityentPhysicalModelName
: The vendor-specific model name identifier string associated with this physical component
Check Entity MIB (ftp://ftp.cisco.com/pub/mibs/v2/ENTITY-MIB.my) for more details.
Please note that not all Cisco devices support the Entity MIB and those that support it, do not always display the correct information.
The following modular devices have been tested (with latest IOS) and seem to return correct values: 6500, 7600, 10000, ASR1000, 12000.
The following smaller devices have been tested (with latest IOS) and seem to return correct values: 2950, 2960, ME3400, 3750, 3845, 7200/G1, 7200/G2 (7200s may show a different S/N than the actual one).
Net::SNMP