CygnusNetworks / check_ups_apc.py

APC UPS Nagios Check
Apache License 2.0
4 stars 3 forks source link

No module PowerNet-MIB loaded #1

Closed davidc closed 5 years ago

davidc commented 5 years ago

I can't seem to get this working, installed with pip3 install -r requirements.txt and python3 setup.py install on Debian 10:

# check_ups_apc -C asd -H 12.16.0.5 -vvv
UPSAPC UNKNOWN: pysnmp.smi.error.MibNotFoundError: No module PowerNet-MIB loaded at <pysnmp.smi.builder.MibBuilder object at 0x7f35e64abcc0>caused by <class 'ValueError'>: invalid literal for int() with base 10: 'PowerNet-MIB::upsBasicIdentModel'
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/check_ups_apc.py-0.10-py3.7.egg/ups_apc_snmp/snmpclient.py", line 119, in nodeid
    ids_num = [int(x) for x in ids]
  File "/usr/local/lib/python3.7/dist-packages/check_ups_apc.py-0.10-py3.7.egg/ups_apc_snmp/snmpclient.py", line 119, in <listcomp>
    ids_num = [int(x) for x in ids]
ValueError: invalid literal for int() with base 10: 'PowerNet-MIB::upsBasicIdentModel'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/nagiosplugin/runtime.py", line 43, in wrapper
    return func(*args, **kwds)
  File "/usr/local/lib/python3.7/dist-packages/check_ups_apc.py-0.10-py3.7.egg/EGG-INFO/scripts/check_ups_apc", line 423, in main
  File "/usr/local/lib/python3.7/dist-packages/nagiosplugin/check.py", line 120, in main
    runtime.execute(self, verbose, timeout)
  File "/usr/local/lib/python3.7/dist-packages/nagiosplugin/runtime.py", line 128, in execute
    with_timeout(self.timeout, self.run, check)
  File "/usr/local/lib/python3.7/dist-packages/nagiosplugin/platform/posix.py", line 19, in with_timeout
    func(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/nagiosplugin/runtime.py", line 117, in run
    check()
  File "/usr/local/lib/python3.7/dist-packages/nagiosplugin/check.py", line 105, in __call__
    self._evaluate_resource(resource)
  File "/usr/local/lib/python3.7/dist-packages/nagiosplugin/check.py", line 79, in _evaluate_resource
    for metric in metrics:
  File "/usr/local/lib/python3.7/dist-packages/check_ups_apc.py-0.10-py3.7.egg/EGG-INFO/scripts/check_ups_apc", line 177, in probe
  File "/usr/local/lib/python3.7/dist-packages/check_ups_apc.py-0.10-py3.7.egg/ups_apc_snmp/snmpclient.py", line 187, in get
    oids_trans = nodeids(oids)
  File "/usr/local/lib/python3.7/dist-packages/check_ups_apc.py-0.10-py3.7.egg/ups_apc_snmp/snmpclient.py", line 136, in nodeids
    oids_list.append(nodeid(oid), )
  File "/usr/local/lib/python3.7/dist-packages/check_ups_apc.py-0.10-py3.7.egg/ups_apc_snmp/snmpclient.py", line 123, in nodeid
    mibnode, = __mibBuilder.importSymbols(*symbols)
  File "/usr/local/lib/python3.7/dist-packages/pysnmp/smi/builder.py", line 444, in importSymbols
    'No module %s loaded at %s' % (modName, self)
pysnmp.smi.error.MibNotFoundError: No module PowerNet-MIB loaded at <pysnmp.smi.builder.MibBuilder object at 0x7f35e64abcc0>caused by <class 'ValueError'>: invalid literal for int() with base 10: 'PowerNet-MIB::upsBasicIdentModel'
Probing APC UPS device 12.16.0.5 through SNMP
Queried APC UPS device 12.16.0.5 through SNMP - device is reachable
Found Sysname ups01.its.signavio.local and sysdescr APC Web/SNMP Management Card (MB:v4.1.0 PF:v6.4.0 PN:apc_hw05_aos_640.bin AF1:v6.4.0 AN1:apc_hw05_sumx_640.bin MN:AP9537SUM HR:05 SN: 5A1XXXXXXXX MD:10/11/2016) (Embedded PowerNet SNMP Agent SW v2.2 compatible)
Starting SNMP polling of host 12.16.0.5 

If I forcibly load PowerNet-MIB:

class UPSAPC(nagiosplugin.Resource):  # pylint: disable=too-few-public-methods
        def __init__(self, args):
                self.args = args
                ups_apc_snmp.snmpclient.add_mib_path(MIB_PATH)
+                ups_apc_snmp.snmpclient.load_mibs('PowerNet-MIB')
                self.snmpclient = None

there is no error at this point of loading, but it still continues to give the same error including "No module PowerNet-MIB loaded".

Unfortunately I'm not familiar enough with Python and pysnmp to figure out how to fix this, any ideas?

Thanks -davidc

cygnusb commented 5 years ago

We always use the Debian package. The Debian package is building the python modules without zipping the contents (Python egg). pysnmp cannot access the corresponding MIB file, if the python module is zipped. Adding a zip_safe=False fixes this issue for manual source installs

davidc commented 5 years ago

Solved, thank you.