Skip to content

Commit

Permalink
Updates and bug fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesletts committed Oct 24, 2014
1 parent d70d98d commit bcbac81
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 24 deletions.
3 changes: 2 additions & 1 deletion condor_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ getClassAds() {
-format 'Owner=%s\ ' Owner \
-format 'AccountingGroup=%s\ ' AccountingGroup \
-format 'Iwd=%s\ ' Iwd \
-format 'CRAB_ReqName=%s\ ' CRAB_ReqName \
-format 'HoldReasonCode=%i\ ' HoldReasonCode \
-format 'HoldReasonSubCode=%i\ ' HoldReasonSubCode \
-format 'HoldReason=%s\ ' HoldReason \
Expand Down Expand Up @@ -137,7 +138,7 @@ condor_exit_codes() {
#
# grep the explanation of a particular code(s).
#
grep \- $FILE | grep -o [0-9]*\ \-\ .* | sed 's/<.*>//g' \
grep \- $FILE | grep -v Topic | grep -o [0-9]*\ \-\ .* | sed 's/<.*>//g' \
| awk -F\- -v code=$CONDOR_EXIT_CODE '(code==$1%256){print $0}'
return 0
}
Expand Down
114 changes: 91 additions & 23 deletions multi-core.py
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,",
print

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)+",",
print
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()

0 comments on commit bcbac81

Please sign in to comment.