Tx summary

This commit is contained in:
Pascal Engélibert 2026-04-10 17:06:27 +02:00
commit e98eb7380a
4 changed files with 146 additions and 4 deletions

View file

@ -4,7 +4,7 @@ def fetch(site, node, start, stop, user, psw):
start_str = time.strftime("%Y-%m-%dT%H:%M", time.localtime(int(start)))
stop_str = time.strftime("%Y-%m-%dT%H:%M", time.localtime(int(stop+61)))
auth = requests.auth.HTTPBasicAuth(user, psw)
url = f"https://api.grid5000.fr/stable/sites/{site}/metrics?nodes={node}&metrics=bmc_node_power_watt&start_time={start_str}&end_time={stop_str}"
url = f"https://api.grid5000.fr/stable/sites/{site}/metrics?nodes={node}&metrics=wattmetre_power_watt&start_time={start_str}&end_time={stop_str}"
print(url)
resp = requests.get(url, auth=auth)
if resp.status_code != 200:
@ -17,7 +17,11 @@ def fetch(site, node, start, stop, user, psw):
last_power = None
last_time = 0
for sample in data:
t = time.mktime(time.strptime(sample["timestamp"], "%Y-%m-%dT%H:%M:%S.%f%z"))
t = None
try:
t = time.mktime(time.strptime(sample["timestamp"], "%Y-%m-%dT%H:%M:%S.%f%z"))
except Exception as e:
t = time.mktime(time.strptime(sample["timestamp"], "%Y-%m-%dT%H:%M:%S%z"))
if last_power != None:
energy += last_power * (t - last_time)
last_power = None