Compare commits
3 commits
831a85639b
...
294a4e1273
Author | SHA1 | Date | |
---|---|---|---|
294a4e1273 | |||
b54e31f4fd | |||
3d52b1b2c7 |
2 changed files with 28 additions and 3 deletions
|
@ -9,9 +9,11 @@ Python script which querries the database for a list of jobids and produces a fi
|
|||
Those files contain time-resolved power consumption data and are meant to be consumed by the utility in [monitoring/logs/scripts/plot_energy_logs.sh](../logs/README.md#scripts/plot_energy_logs.sh).
|
||||
|
||||
Requirements:
|
||||
- Python module sqlalchemy `python -m pip install sqlalchemy`
|
||||
|
||||
- Python module sqlalchemy `python -m pip install sqlalchemy`
|
||||
|
||||
Usage:
|
||||
|
||||
```bash
|
||||
ssh monitoring
|
||||
./get_detailed_power.py 234556 767869.hawk-pbs5
|
||||
|
|
|
@ -1,15 +1,36 @@
|
|||
import sqlalchemy as db
|
||||
import numpy as np
|
||||
from collections import OrderedDict
|
||||
import os.path
|
||||
|
||||
|
||||
def parse_arguments():
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Produce detailed power usage data for a list of jobids.')
|
||||
parser.add_argument('-v', '--verbose', action='store_true',
|
||||
help='Show database querries, etc.')
|
||||
parser.add_argument('jobid', type=parse_jobid,
|
||||
# nargs='+',
|
||||
help='Job ID such as "2260215" or "226015.hawk-pbs5"')
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
def parse_jobid(s):
|
||||
import re
|
||||
hawkpbs = r'.hawk-pbs5'
|
||||
jobid = re.sub(hawkpbs, '', s)
|
||||
if not jobid.isdigit():
|
||||
raise argparse.ArgumentTypeError(f'invalid job ID "{s}"')
|
||||
return jobid
|
||||
|
||||
def init_db():
|
||||
import sqlalchemy as db
|
||||
_verbose = False #True
|
||||
engine = db.create_engine('postgresql://hpc@hawk-monitor4:5432/coe_mon', echo=_verbose)
|
||||
conn = engine.connect()
|
||||
return conn
|
||||
|
||||
def init_query(jobid, interval):
|
||||
import sqlalchemy as db
|
||||
query_string = """with job as (
|
||||
select job_id, starttime, endtime, nodes from jobs where job_id='{jobid}.hawk-pbs5'
|
||||
),
|
||||
|
@ -148,8 +169,10 @@ class Power:
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
args = parse_arguments()
|
||||
|
||||
conn = init_db()
|
||||
jobid = "2260215"
|
||||
jobid = args.jobid
|
||||
interval = 5
|
||||
query = init_query(jobid, interval)
|
||||
|
||||
|
|
Loading…
Reference in a new issue