2 |
|
|
3 |
|
import sys, getopt, string |
4 |
|
|
5 |
< |
from FwkJobRep.ReportParser import readJobReport |
5 |
> |
from ProdCommon.FwkJobRep.ReportParser import readJobReport |
6 |
|
from DashboardAPI import apmonSend, apmonFree |
7 |
|
|
8 |
|
|
58 |
|
# load FwkJobRep |
59 |
|
jobReport = readJobReport(input)[0] |
60 |
|
|
61 |
< |
exit_satus = '' |
61 |
> |
exit_status = '' |
62 |
|
|
63 |
< |
# get ExitStatus of last error |
64 |
< |
if len(jobReport.errors) != 0 : |
65 |
< |
exit_status = str(jobReport.errors[-1]['ExitStatus']) |
66 |
< |
else : |
67 |
< |
exit_status = str(0) |
63 |
> |
##### temporary fix for FJR incomplete #### |
64 |
> |
fjr = open (input) |
65 |
> |
len_fjr = len(fjr.readlines()) |
66 |
> |
if (len_fjr <= 6): |
67 |
> |
### 50115 - cmsRun did not produce a valid/readable job report at runtime |
68 |
> |
exit_status = str(50115) |
69 |
> |
else: |
70 |
> |
# get ExitStatus of last error |
71 |
> |
if len(jobReport.errors) != 0 : |
72 |
> |
exit_status = str(jobReport.errors[-1]['ExitStatus']) |
73 |
> |
else : |
74 |
> |
exit_status = str(0) |
75 |
|
|
76 |
|
# get i/o statistics |
77 |
|
storageStatistics = str(jobReport.storageStatistics) |
79 |
|
# dashboard report dictionary |
80 |
|
dashboard_report = {} |
81 |
|
|
82 |
+ |
##Brian's patch to sent number of events procedded to the Dashboard |
83 |
+ |
# Add NoEventsPerRun to the Dashboard report |
84 |
+ |
eventsPerRun = 0 |
85 |
+ |
for inputFile in jobReport.inputFiles: |
86 |
+ |
try: |
87 |
+ |
eventsRead = str(inputFile.get('EventsRead', 0)) |
88 |
+ |
eventsRead = int(eventsRead.strip()) |
89 |
+ |
except: |
90 |
+ |
continue |
91 |
+ |
eventsPerRun += eventsRead |
92 |
+ |
dashboard_report['NoEventsPerRun'] = eventsPerRun |
93 |
+ |
dashboard_report['NbEvPerRun'] = eventsPerRun |
94 |
+ |
dashboard_report['NEventsProcessed'] = eventsPerRun |
95 |
+ |
#print "Total number of events:", eventsPerRun |
96 |
+ |
## |
97 |
+ |
|
98 |
|
# check if storageStatistics is valid |
99 |
|
if storageStatistics.find('Storage statistics:') != -1 : |
100 |
|
# report form: { 'protocol' : { 'action' : [attempted,succedeed,total-size,total-time,min-time,max-time] , ... } , ... } |
103 |
|
data_fields = data.split(';') |
104 |
|
for data_field in data_fields: |
105 |
|
# parse: format protocol/action = attepted/succedeed/total-size/total-time/min-time/max-time |
106 |
+ |
if data_field == ' ' or not data_field or data_field == '': |
107 |
+ |
continue |
108 |
|
key = data_field.split('=')[0].strip() |
109 |
|
item = data_field.split('=')[1].strip() |
110 |
|
protocol = str(key.split('/')[0].strip()) |
123 |
|
else : |
124 |
|
report[protocol][action] = [attempted,succeeded,total_size,total_time,min_time,max_time] |
125 |
|
else : |
126 |
< |
report[protocol] = {'action' : [attempted,succeeded,total_size,total_time,min_time,max_time] } |
126 |
> |
report[protocol] = {action : [attempted,succeeded,total_size,total_time,min_time,max_time] } |
127 |
|
|
128 |
|
if debug : |
129 |
|
for protocol in report.keys() : |
137 |
|
dashboard_report['MonitorID'] = MonitorID |
138 |
|
dashboard_report['MonitorJobID'] = MonitorJobID |
139 |
|
for protocol in report.keys() : |
140 |
< |
if 'read' in report[protocol].keys() : |
141 |
< |
try: |
142 |
< |
size = float(report[protocol]['read'][2]) |
143 |
< |
time = float(report[protocol]['read'][3]) |
144 |
< |
dashboard_report['io_'+protocol] = size/time*1000 |
145 |
< |
except: |
121 |
< |
pass |
140 |
> |
for action in report[protocol].keys() : |
141 |
> |
try: size = float(report[protocol][action][2]) |
142 |
> |
except: size = 'NULL' |
143 |
> |
try: time = float(report[protocol][action][3])/1000 |
144 |
> |
except: time = 'NULL' |
145 |
> |
dashboard_report['io_'+protocol+'_'+action] = str(size)+'_'+str(time) |
146 |
|
|
147 |
|
if debug : |
148 |
< |
print dashboard_report |
148 |
> |
ordered = dashboard_report.keys() |
149 |
> |
ordered.sort() |
150 |
> |
for key in ordered: |
151 |
> |
print key,'=',dashboard_report[key] |
152 |
|
|
153 |
|
# send to DashBoard |
154 |
|
apmonSend(MonitorID, MonitorJobID, dashboard_report) |
159 |
|
for key in dashboard_report.keys() : |
160 |
|
exit_string += ';' + str(key) + '=' + str(dashboard_report[key]) |
161 |
|
|
162 |
+ |
|
163 |
+ |
|
164 |
|
return exit_string |
165 |
|
|
166 |
|
|