Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Node Util panel #8

Merged
merged 3 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 23 additions & 16 deletions grafana/main/ben-dashboard-mod.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import json
import ast
import argparse
import requests
import urllib.request
import copy
import re

""""
Modifies panel relating to Ben Job Scheduler.
Expand Down Expand Up @@ -46,23 +45,31 @@ def fetch_metrics():
for line in metrics.split("\n"):
if line == "" or line.startswith('#') or line.startswith("ben"):
continue
nodes.append(line.split()[0])
match = re.match(r'([^0-9]+)\d*_ben_([^_]+)_', line.split()[0])
# example: newick01_ben_tronko_size
# group 1: first word (i.e newick)
# group 2: word after ben (i.e tronko)
if match:
if match.group(1) == match.group(2):
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

Expand Down
1 change: 0 additions & 1 deletion scheduler/jobs/ben-jobs.service
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[Unit]
Description=Ben Jobs Service
After=network-online.target
Requires=grafana-server.service

[Service]
User=ubuntu
Expand Down