## warnings are disabled as they confuse Zabbix import warnings warnings.filterwarnings("ignore") import json import sys # The metric is passed as a single parameter. # Example: ocs.data.nextcloud.shares.num_shares # Check the XML or JSON file exported by serverinfo to know the exact # metric path metric = sys.argv[1] metric_path = metric.split('.') fl = open("/var/lib/zabbix/output/nc_metrics.json","r") metric_values = json.load(fl) # This part should absolutely be polished, # but it's working as is at the moment metric_val = metric_values[metric_path[0]][metric_path[1]][metric_path[2]][metric_path[3]] if len(metric_path)==4: print(metric_val) elif len(metric_path)==5: print(metric_val[metric_path[4]]) elif len(metric_path)==6: print(metric_val[metric_path[4]][metric_path[5]])