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

Failure in mysql collector for diamond-4.0 #672

Closed williamjoy closed 2 years ago

williamjoy commented 6 years ago
==> /var/log/diamond/diamond.log <==
[2017-08-10 02:54:59,651] [MainThread] Collector failed!
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/diamond/utils/scheduler.py", line 77, in collector_process
    collector._run()
  File "/usr/lib/python2.7/site-packages/diamond/collector.py", line 477, in _run
    self.collect()
  File "/usr/share/diamond/collectors/mysqlstat/mysqlstat.py", line 477, in collect
    self.disconnect()
  File "/usr/share/diamond/collectors/mysqlstat/mysqlstat.py", line 313, in disconnect
    self.db.close()
AttributeError: 'NoneType' object has no attribute 'close'
williamjoy commented 6 years ago

for temp skip the error, modify File "/usr/share/diamond/collectors/mysqlstat/mysqlstat.py", line 313

     def disconnect(self):
-        self.db.close()
+        if hasattr(self, 'db'):
+            self.db.close()
shortdudey123 commented 2 years ago

Based on the limited info, I am guessing there is an uncaught exception in the connect method when trying to define self.db. You could add some debug lines to narrow it down.