phsmith / python

Python scripts
1 stars 0 forks source link

processorn count doesn't increase after one iteration #3

Closed arzWZM closed 4 years ago

arzWZM commented 4 years ago

The PROCESSORN count is always 1. The code below shows that it'll increase only if processorn == 0 which means it'll increase only once. It should increase as many times as PROCESSORS is there.

# Define variables to store OID values
processorn    = 0
...
... 
...
if 'hrDeviceDescr' in mib:
      if processorn == 0:
          processorn += 1

In the attached data, it should increase twice since there are two "Unkown Processor Type"

test.snmp.txt

HOST-RESOURCES-MIB::hrDeviceDescr.1 = Microsoft XPS Document Writer v4
HOST-RESOURCES-MIB::hrDeviceDescr.2 = Unknown Processor Type
HOST-RESOURCES-MIB::hrDeviceDescr.3 = Unknown Processor Type
HOST-RESOURCES-MIB::hrDeviceDescr.4 = Software Loopback Interface 1
arzWZM commented 4 years ago

A possible fix for SNMP based data is

        if 'Unknown Processor Type' in value:
            processorn += 1

        elif 'CPU' in value:
            processorn += 1

Don't know about DMIDECODE file

arzWZM commented 4 years ago

How do I test dmidecode?

I tried the following and I get the Usage menu instead.

root@hostname:~# dmidecode > dmi.data
root@hostname:~# python fusioninventory-xmlgenerator -d dmi.data  -o test.xml
Usage: fusioninventory-xmlgenerator [options]

Options:
  -h, --help            show this help message and exit
  -d DMIFILE, --dmi=DMIFILE
                        DMIDecode file
  -f OIDFILE, --oid=OIDFILE
                        OID file
  -o OUTPUTFILE, --output=OUTPUTFILE
                        Output file dest/name
  -i DEVICEID, --deviceid=DEVICEID
                        DeviceID: Format date-time ex.: 2013-10-11-17-00-00
phsmith commented 4 years ago

@arzWZM The processors count was fixed.

About the dmidecode, he a complement to the snmp data, so you need to pass the oidfile too. fusioninventory-xmlgenerator -f snmp.oid -d dmi.data -o test.xml