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

diskspace.py: Fixed ZeroDivisionError when blocks_free is 0 and nfs mounts #700

Closed stefan7018 closed 2 years ago

stefan7018 commented 6 years ago

Fixed that collector stopps operation for all filesystems when one filesystem has zero blocks_free:

[2018-03-05` 12:14:39,245] [ERROR] [MainThread:DiskSpaceCollector] Collector failed!
Traceback (most recent call last):
  File "/python2.7/site-packages/diamond/utils/scheduler.py", line 73, in collector_process
    collector._run()
  File "/python2.7/site-packages/diamond/collector.py", line 477, in _run
    self.collect()
  File "/share/diamond/collectors/diskspace/diskspace.py", line 243, in collect
    blocks_free + (blocks_total - blocks_free)) * 100
ZeroDivisionError: float division by zero
coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 24.667% when pulling 2ba5509e895f3f7ab9b206e3aa6350030d5c97a2 on stefan7018:master into f2bece462577a7c557be8a9f90f6b9340c3db571 on python-diamond:master.

stefan7018 commented 6 years ago

Additional added a fix for nfs Devicenames without slashes

Now it is possible to get metrics from NFS Devicenames like "nfs.local:nice_new_nfs_mount"