mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 02:51:03 +00:00
Plugin feinstaubsensor: omit graphs for missing API fieldnames
Some sensor data fields may not be available, if the specific component is missing.
This commit is contained in:
parent
137913e39d
commit
90d214cd5a
1 changed files with 30 additions and 21 deletions
|
@ -176,27 +176,36 @@ def get_sensor_data(host):
|
||||||
|
|
||||||
|
|
||||||
def print_graph_section(graph_description, hosts, include_config, include_values):
|
def print_graph_section(graph_description, hosts, include_config, include_values):
|
||||||
print("multigraph {}".format(graph_description["name"]))
|
# retrieve the data and omit ony output, if the relevant key is missing
|
||||||
if include_config:
|
results = []
|
||||||
# graph configuration
|
for host_info in hosts:
|
||||||
print("graph_category sensors")
|
data = get_sensor_data(host_info.host)
|
||||||
for key in ("graph_title", "graph_vlabel", "graph_args", "graph_info"):
|
if data:
|
||||||
if key in graph_description:
|
for dataset in data["sensordatavalues"]:
|
||||||
print("{} {}".format(key, graph_description[key]))
|
if dataset["value_type"] == graph_description["api_value_name"]:
|
||||||
for host_info in hosts:
|
results.append((host_info, dataset["value"]))
|
||||||
print("{}.label {}".format(host_info.fieldname, host_info.label))
|
break
|
||||||
print("{}.type {}".format(host_info.fieldname, graph_description["value_type"]))
|
else:
|
||||||
if include_values:
|
# We cannot distinguish between fields that are not supported by the sensor (most
|
||||||
for host_info in hosts:
|
# are optional) and missing data. Thus we cannot handle online/offline sensor data
|
||||||
# We cannot distinguish between fields that are not supported by the sensor (most are
|
# fields, too.
|
||||||
# optional) and missing data. Thus we cannot handle online/offline sensor data fields,
|
pass
|
||||||
# too.
|
# skip this multigraph, if no host contained this data field
|
||||||
data = get_sensor_data(host_info.host)
|
if results:
|
||||||
if data is not None:
|
print("multigraph {}".format(graph_description["name"]))
|
||||||
value = data.get(graph_description["api_value_name"])
|
if include_config:
|
||||||
if value is not None:
|
# graph configuration
|
||||||
print("{}.value {}".format(host_info.fieldname, value))
|
print("graph_category sensors")
|
||||||
print()
|
for key in ("graph_title", "graph_vlabel", "graph_args", "graph_info"):
|
||||||
|
if key in graph_description:
|
||||||
|
print("{} {}".format(key, graph_description[key]))
|
||||||
|
for host_info, value in results:
|
||||||
|
print("{}.label {}".format(host_info.fieldname, host_info.label))
|
||||||
|
print("{}.type {}".format(host_info.fieldname, graph_description["value_type"]))
|
||||||
|
if include_values:
|
||||||
|
for host_info, value in results:
|
||||||
|
print("{}.value {}".format(host_info.fieldname, value))
|
||||||
|
print()
|
||||||
|
|
||||||
|
|
||||||
action = sys.argv[1] if (len(sys.argv) > 1) else ""
|
action = sys.argv[1] if (len(sys.argv) > 1) else ""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue