-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d70d98d
commit bcbac81
Showing
2 changed files
with
93 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,113 @@ | ||
#!/usr/bin/python26 | ||
import sys | ||
import datetime | ||
import glob | ||
import json | ||
from pprint import pprint | ||
import sys | ||
|
||
print "0UNIX time,Date,Time,Pool Name,", | ||
|
||
print " Pool Name, Date, Time,", | ||
firstline=0 | ||
print "All,", | ||
print "Static,", | ||
print "Static Retiring,", | ||
print "Partitionable,", | ||
print "Partitionable Retiring,", | ||
|
||
print "All Idle,", | ||
print "Static Idle,", | ||
print "Static Retiring Idle,", | ||
print "Partitionable Idle,", | ||
print "Partitionable Retiring Idle,", | ||
|
||
print "All Idle %,", | ||
print "Static Idle %,", | ||
print "Static Retiring Idle %", | ||
print "Partitionable Idle %,", | ||
print "Partitionable Retiring Idle%" | ||
|
||
import glob | ||
FILES=glob.glob("/crabprod/CSstoragePath/Monitor-json/monitor-multicore-*.json") | ||
for FILE in FILES : | ||
|
||
with open(FILE) as json_data: | ||
d = json.load(json_data) | ||
json_data.close() | ||
#pprint(d) | ||
try : | ||
with open(FILE) as json_data: | ||
d = json.load(json_data) | ||
json_data.close() | ||
except ValueError : | ||
continue | ||
|
||
TABLES=d['Multi-core pilot monitoring'] | ||
if firstline==0 : | ||
firstline=1 | ||
for TABLE in sorted(TABLES) : | ||
if 'Cpus' in TABLE : | ||
print TABLE+" Total,"+TABLE+" Wasted,", | ||
|
||
POOL=FILE.split('-') | ||
print (POOL[3]+",").ljust(11), | ||
|
||
now=int(d['Multi-core pilot monitoring']['Time']) | ||
readable_date=datetime.datetime.utcfromtimestamp(now).strftime('%Y-%m-%d, %H:%M:%S,') | ||
print str(now)+",",readable_date, | ||
|
||
print readable_date, | ||
|
||
POOL=FILE.split('-') | ||
print (POOL[3]+",").ljust(11), | ||
|
||
totals={} | ||
wasted={} | ||
for TABLE in sorted(TABLES) : | ||
if 'Cpus' in TABLE : | ||
busy=0 | ||
total=0 | ||
for data in d['Multi-core pilot monitoring'][TABLE]['data']: | ||
if data[1]=="Busy" : busy+=data[2] | ||
total+=data[2] | ||
wasted=total-busy | ||
print str(total).rjust(6)+", "+str(wasted).rjust(6)+",", | ||
totals[TABLE]=float(total) | ||
wasted[TABLE]=float(total-busy) | ||
|
||
total_totals=float(totals['Total Cpus']) | ||
static_totals=float(totals['Static multi-core glidein Cpus']) | ||
static_retiring_totals=float(totals['Static multi-core retiring glidein Cpus']) | ||
partitionable_totals=float(totals['Dynamic glidein Cpus']+totals['Partitionable glidein Cpus']) | ||
partitionable_retiring_totals=float(totals['Dynamic retiring glidein Cpus']+totals['Partitionable retiring glidein Cpus']) | ||
|
||
print '{0:6.0f},'.format(total_totals), | ||
print '{0:6.0f},'.format(static_totals), | ||
print '{0:6.0f},'.format(static_retiring_totals), | ||
print '{0:6.0f},'.format(partitionable_totals), | ||
print '{0:6.0f},'.format(partitionable_retiring_totals), | ||
|
||
total_wasted=float(wasted['Total Cpus']) | ||
static_wasted=float(wasted['Static multi-core glidein Cpus']) | ||
static_retiring_wasted=float(wasted['Static multi-core retiring glidein Cpus']) | ||
partitionable_wasted=float(wasted['Dynamic glidein Cpus']+wasted['Partitionable glidein Cpus']) | ||
partitionable_retiring_wasted=float(wasted['Dynamic retiring glidein Cpus']+wasted['Partitionable retiring glidein Cpus']) | ||
|
||
print '{0:6.0f},'.format(total_wasted), | ||
print '{0:6.0f},'.format(static_wasted), | ||
print '{0:6.0f},'.format(static_retiring_wasted), | ||
print '{0:6.0f},'.format(partitionable_wasted), | ||
print '{0:6.0f},'.format(partitionable_retiring_wasted), | ||
|
||
try : | ||
total_wasted/=totals['Total Cpus'] | ||
except ZeroDivisionError : | ||
total_wasted=0. | ||
|
||
try : | ||
static_wasted/=totals['Static multi-core glidein Cpus'] | ||
except ZeroDivisionError : | ||
static_wasted=0. | ||
|
||
try : | ||
static_retiring_wasted/=totals['Static multi-core glidein Cpus'] | ||
except ZeroDivisionError : | ||
static_retiring_wasted=0. | ||
|
||
try : | ||
partitionable_wasted/=(totals['Dynamic glidein Cpus']+totals['Partitionable glidein Cpus']) | ||
except ZeroDivisionError : | ||
partitionable_wasted=0. | ||
|
||
try : | ||
partitionable_retiring_wasted/=(totals['Dynamic glidein Cpus']+totals['Partitionable glidein Cpus']) | ||
except ZeroDivisionError : | ||
partitionable_retiring_wasted=0. | ||
|
||
print '{0:5.1f}%,'.format(100.0*total_wasted), | ||
print '{0:5.1f}%,'.format(100.0*static_wasted), | ||
print '{0:5.1f}%,'.format(100.0*static_retiring_wasted), | ||
print '{0:5.1f}%,'.format(100.0*partitionable_wasted), | ||
print '{0:5.1f}%'.format(100.0*partitionable_retiring_wasted) | ||
|
||
sys.exit() |