Compare commits

...

2 Commits
main ... main

Author SHA1 Message Date
587877e5db
Fix missing device name
All checks were successful
buildbot/multibuild_parent Build done.
buildbot/travis_bionic Build done.
- now is "missing" instead of an empty string
- this is triggered e.g. when mounting degraded mode. In normal
  operation it shouldn't happen
- Fixes #1
2023-11-24 14:04:18 +08:00
4dae2cd4dc
updated callback frequency
All checks were successful
buildbot/multibuild_parent Build done.
buildbot/travis_bionic Build done.
2023-11-08 23:07:01 +05:30

View File

@ -5,7 +5,7 @@ import collectd
PLUGIN = 'btrfs'
TYPE_STATS = "device_stats"
INTERVAL = 600
def read_callback():
"""Read Btrfs device information and dispatch values to collectd."""
@ -22,13 +22,17 @@ def read_callback():
r'[^a-zA-Z0-9]',
r'-',
dev_info.path)[1:]
if not metric.plugin_instance:
metric.plugin_instance = "missing"
for counter, value in stats.counters.items():
metric.type_instance = counter
metric.dispatch(TYPE_STATS, [value])
metric.dispatch(TYPE_STATS, [value], interval=INTERVAL)
except Exception as e:
collectd.error("btrfs: read_callback: {}".format(e))
collectd.debug("btrfs: read done")
if __name__ != "__main__":
# Register callbacks
collectd.register_read(read_callback)
collectd.register_read(read_callback, INTERVAL)