Skip to content
Snippets Groups Projects
Commit 3ac62e30 authored by Georges Da Costa's avatar Georges Da Costa
Browse files

Adds kwollect power monitoring

parent b2ca374b
Branches
No related tags found
No related merge requests found
import time
import requests
import os
import json
def get_names():
return {'kwollect'}
class Power:
'Monitoring using Kwollect on g5k'
def __init__(self):
self.hostnames = None
self.site = None
self.start_time = None
self.end_time = None
self.executor = None
self.names = get_names()
def build(self, executor):
"""Prepare the right request only needed on g5k"""
self.hostnames = ','.join([fullname.split('.')[0] for fullname in executor.hostnames])
self.site = executor.hostnames[0].split('.')[1]
self.executor = executor
def start(self):
'Starts the monitoring right before the benchmark'
self.start_time = int(time.time())
def stop(self):
'Stops the monitoring right after the benchmark'
self.end_time = int(time.time())
def save(self, experiment, benchname, beg_time):
'Save the results when time is no more critical'
filename_power = experiment.output_file+'_power'
os.makedirs(filename_power, exist_ok=True)
target = '%s/%s_%s_%s' % (filename_power, self.executor.hostnames[0], benchname, beg_time)
request = 'https://api.grid5000.fr/sid/sites/%s/metrics?metrics=wattmetre_power_watt&start_time=%s&end_time=%s&nodes=%s' % (self.site, self.start_time, self.end_time, self.hostnames)
delta = int(time.time())-self.end_time
if delta < 6:
time.sleep(6-delta)
res = requests.get(request)
data = res.text
raws = json.loads(data)
host_list = self.hostnames.split(',')
timestamps = {host:[] for host in host_list}
values = {host:[] for host in host_list}
for elements in raws:
device_id = elements['device_id']
timestamps[device_id].append(int(datetime.datetime.strptime(elements['timestamp'], "%Y-%m-%dT%H:%M:%S%z").timestamp()))
values[device_id].append(elements['value'])
result = [(host, timestamps[host], values[host]) for host in host_list]
with open(target, 'w') as file_id:
file_id.write(json.dumps(result))
......@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
setuptools.setup(
name="expetator",
version="0.1.1",
version="0.1.3",
author="Georges Da Costa",
author_email="georges.da-costa@irit.fr",
description="A framework for monitoring HPC applications using DVFS",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment