Tx summary
This commit is contained in:
parent
eba08d3b8b
commit
e98eb7380a
4 changed files with 146 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue