diff --git a/grafana/main/ben-dashboard-mod.py b/grafana/main/ben-dashboard-mod.py index f4a85c3..575e4df 100644 --- a/grafana/main/ben-dashboard-mod.py +++ b/grafana/main/ben-dashboard-mod.py @@ -47,22 +47,24 @@ def fetch_metrics(): if line == "" or line.startswith('#') or line.startswith("ben"): continue nodes.append(line.split()[0]) +print(nodes) for panel in dashboard["panels"]: try: - if(panel["title"] == "Node Utilization"): - print(nodes) - currRefId='A' #fix? shouldnt be able to reach Z. JS2 max of 25 instances - query=panel["targets"][0] - newTargets=[] - for i in range(0,len(nodes), 2): - source='_'.join(nodes[i].split("_")[0:-1]) - query["expr"]=f"{nodes[i]} / {nodes[i+1]}" - query["legendFormat"]=source - query["refId"]=currRefId - currRefId=chr(ord(currRefId)+1) - newTargets.append(copy.deepcopy(query)) - panel["targets"]=newTargets + if(panel["title"] == "Ben Server"): + for panel_ in panel["panels"]: + if(panel_["title"] == "Node Utilization"): + currRefId='A' #fix? shouldnt be able to reach Z. JS2 max of 25 instances + query=panel_["targets"][0] + newTargets=[] + for i in range(0,len(nodes), 2): + source='_'.join(nodes[i].split("_")[0:-1]) + query["expr"]=f"{nodes[i]} / {nodes[i+1]}" + query["legendFormat"]=source + query["refId"]=currRefId + currRefId=chr(ord(currRefId)+1) + newTargets.append(copy.deepcopy(query)) + panel_["targets"]=newTargets except: continue