summaryrefslogtreecommitdiffstats
path: root/doc/stats_dabmux_multi.py
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-10-16 14:06:19 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-10-16 14:06:19 +0200
commite91ff1f3b5193713f2fef7876db40c4af5cbc01b (patch)
tree5c91bfbf153b09594b4922feba258ea05370a411 /doc/stats_dabmux_multi.py
parent7a57fb48c25b0dae4e372b8e522f308c589bb35e (diff)
downloaddabmux-e91ff1f3b5193713f2fef7876db40c4af5cbc01b.tar.gz
dabmux-e91ff1f3b5193713f2fef7876db40c4af5cbc01b.tar.bz2
dabmux-e91ff1f3b5193713f2fef7876db40c4af5cbc01b.zip
Merge state management command into values, adapt munin accordingly
Diffstat (limited to 'doc/stats_dabmux_multi.py')
-rwxr-xr-xdoc/stats_dabmux_multi.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/doc/stats_dabmux_multi.py b/doc/stats_dabmux_multi.py
index 664f2f1..ff6f0a4 100755
--- a/doc/stats_dabmux_multi.py
+++ b/doc/stats_dabmux_multi.py
@@ -7,10 +7,13 @@ import sys
import json
import zmq
import os
+import re
config_top = """
"""
+#default data type is GAUGE
+
config_template = """
multigraph buffers_{ident}
graph_title Contribution {ident} buffer
@@ -68,6 +71,19 @@ right.min -90
right.max 0
right.warning -40:0
right.critical -80:0
+
+multigraph state_{ident}
+graph_title State of contribution {ident}
+graph_order state
+graph_args --base 1000 --lower-limit 0 --upper-limit 5
+graph_vlabel Current state of the input
+graph_category dabmux
+graph_info This graph shows the state for the {ident} ZMQ input
+
+state.info Input state
+state.label 0 Unknown, 1 NoData, 2 Unstable, 3 Silent, 4 Streaming
+state.warning 4:4
+state.critical 2:4
"""
ctx = zmq.Context()
@@ -93,6 +109,8 @@ def connect():
return sock
+re_state = re.compile(r"\w+ (\d+)")
+
if len(sys.argv) == 1:
sock = connect()
sock.send("values")
@@ -111,6 +129,14 @@ if len(sys.argv) == 1:
munin_values += "left.value {}\n".format(v['peak_left'])
munin_values += "right.value {}\n".format(v['peak_right'])
+ if 'state' in v:
+ # If ODR-DabMux is v1.3.1-3 or older, it doesn't export state
+ match = re_state.match(v['state'])
+ if match:
+ munin_values += "state.value {}\n".format(match.group(1))
+ else:
+ print("Cannot parse state '{}'".format(v['state']))
+
print(munin_values)
elif len(sys.argv) == 2 and sys.argv[1] == "config":