python-diamond / Diamond

Diamond is a python daemon that collects system metrics and publishes them to Graphite (and others). It is capable of collecting cpu, memory, network, i/o, load and disk metrics. Additionally, it features an API for implementing custom collectors for gathering metrics from almost any source.
http://diamond.readthedocs.org/
MIT License
1.74k stars 601 forks source link

imp load module causing TypeError('super(type, obj) #684

Closed williamjoy closed 2 years ago

williamjoy commented 6 years ago

TypeError('super(type, obj): obj must be an instance or subtype of type' with IMP when initializing SNMPInterfaceCollector

The collector module loaded as following orders, rely on os.listdir() output

>>> import os
>>> filter(lambda x: 'snmp' in x,os.listdir('/usr/share/diamond/collectors'))
['snmpinterface', 'netscalersnmp', 'snmp', 'snmpraw', 'iodrivesnmp']

I tested on my environment, snmpraw collector and iodrivesnmp always works but not snmpinterface, this is probably due to snmp module is reloaded by imp, related codes: https://github.com/python-diamond/Diamond/commit/8c7ea91d633caab0158cc5852a6b02f7a794422e#diff-264916192cc0a7d2ccfa0c62630b34e7R159

williamjoy commented 6 years ago

Diamond version __VERSION__ = 'f2bece462577a7c557be8a9f90f6b9340c3db571..0-github_archive' f2bece462577a7c557be8a9f90f6b9340c3db571 Adding the Error log


1508834136.81   [MainProcess:87379:ERROR]   Failed to initialize Collector: SNMPInterfaceCollector. Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/diamond/utils/classes.py", line 240, in initialize_collector
    collector = cls(name=name, configfile=configfile, handlers=handlers)
  File "/usr/share/diamond/collectors/snmp/snmp.py", line 39, in __init__
    super(SNMPCollector, self).__init__(*args, **kwargs)
TypeError: super(type, obj): obj must be an instance or subtype of type```
DStape commented 6 years ago

Hi @williamjoy,

As this issue was raised a few months ago, do you have a fix for this?