This repository was archived by the owner on Sep 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathhtmlor.py
More file actions
executable file
·1557 lines (1350 loc) · 70.7 KB
/
htmlor.py
File metadata and controls
executable file
·1557 lines (1350 loc) · 70.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python
from assignSession import *
import time
from utils import getWorkLoad, campaignInfo, siteInfo, getWorkflows, unifiedConfiguration, getPrepIDs, componentInfo, getAllAgents, sendLog, moduleLock, dataCache, agentInfo, display_time, eosFile, eosRead, StartStopInfo, remainingDatasetInfo
import os
import json
from collections import defaultdict
import sys
from utils import monitor_dir, base_dir, phedex_url, reqmgr_url, monitor_pub_dir, unified_url_eos, monitor_eos_dir, monitor_pub_eos_dir, base_eos_dir, closeoutInfo, agent_speed_draining, statusHistory
import random
from JIRAClient import JIRAClient
def htmlor( caller = ""):
mlock = moduleLock(silent=True)
if mlock(): return
up = componentInfo(ignore=['mcm','wtc','jira'])
if not up.check(): return
#for backup in ['statuses.json','siteInfo.json','equalizor.json']:
# print "copying",backup,"to old location"
# os.system('env EOS_MGM_URL=root://eoscms.cern.ch eos cp %s/%s /afs/cern.ch/user/c/cmst2/www/unified/.'%(monitor_pub_dir, backup))
# #os.system('cp %s/%s %s/.'%(monitor_dir, backup, monitor_pub_dir))
try:
boost = json.loads(eosRead('%s/equalizor.json'%monitor_pub_dir))['modifications']
except:
boost = {}
#cache = getWorkflows(reqmgr_url,'assignment-approved', details=True)
cache = []
def getWL( wfn ):
cached = filter(lambda d : d['RequestName']==wfn, cache)
if cached:
wl = cached[0]
else:
wl = getWorkLoad(reqmgr_url,wfn)
return wl
def wfl(wf,view=False,p=False,ms=False,within=False,ongoing=False,status=False,update=False):
wfn = wf.name
wfs = wf.wm_status
wl = None
pid = None
wl_pid = None
pids=filter(lambda seg: seg.count('-')==2, wf.name.split('_'))
if len(pids):
pids = pids[:1]
pid=pids[0]
if not pids:
wl = getWL( wf.name )
pids = getPrepIDs( wl )
pid = pids[0]
wl_pid = pid
if 'task' in wf.name:
wl_pid = 'task_'+pid
text = "<div>%s</div> "%wfn
#text=', '.join([
#wfn,
#'<a href="https://cmsweb.cern.ch/reqmgr/view/details/%s" target="_blank">%s</a> '%(wfn,wfn),
#'<table><tr><td>%s</td></tr></table>'%(wfn),
#'<span>%s</span>'%(wfn),
#"<div>%s</div> "%wfn,
#'(%s)'%wfs])
text+=', '.join([
'(%s)'%wfs,
'<a href="https://%s/reqmgr2/fetch?rid=%s" target="_blank">dts</a>'%(reqmgr_url,wfn),
##'<a href="https://cmsweb.cern.ch/reqmgr/view/details/%s" target="_blank">dts-req1</a>'%wfn,
#TOFIX '<a href=https://cmsweb.cern.ch/reqmgr/view/showWorkload?requestName=%s target="_blank">wkl</a>'%wfn,
#'<a href="https://%s/couchdb/reqmgr_workload_cache/%s" target="_blank">wfc</a>'%(reqmgr_url,wfn),
'<a href="https://%s/reqmgr2/data/request?name=%s" target="_blank">req</a>'%(reqmgr_url,wfn),
#'<a href="https://cmsweb.cern.ch/reqmgr/reqMgr/request?requestName=%s" target="_blank">dwkc</a>'%wfn,
#TOFIX '<a href="https://cmsweb.cern.ch/reqmgr/view/splitting/%s" target="_blank">spl</a>'%wfn,
'<a href="https://cms-pdmv.cern.ch/stats/?RN=%s" target="_blank">vw</a>'%wfn,
'<a href="https://cms-pdmv.cern.ch/stats/restapi/get_one/%s" target="_blank">vwo</a>'%wfn,
'<a href="https://cms-logbook.cern.ch/elog/Workflow+processing/?mode=full&reverse=0&reverse=1&npp=20&subtext=%s&sall=q" target="_blank">elog</a>'%pid,
'<a href="https://cms-gwmsmon.cern.ch/prodview/%s" target="_blank">pv</a>'%wfn,
#deprecated '<a href="https://cmsweb.cern.ch/reqmgr/reqMgr/outputDatasetsByRequestName/%s" target="_blank">out</a>'%wfn,
'<a href="closeout.html#%s" target="_blank">clo</a>'%wfn,
'<a href="statuses.html#%s" target="_blank">st</a>'%wfn,
'<a href="https://%s/couchdb/workloadsummary/_design/WorkloadSummary/_show/histogramByWorkflow/%s" target="_blank">perf</a>'%(reqmgr_url,wfn),
#'<a href="http://dabercro.web.cern.ch/dabercro/unified/showlog/?search=%s" target="_blank">history</a>'%(pid),
'<a href="https://cms-unified.web.cern.ch/cms-unified/showlog/?search=%s" target="_blank">history</a>'%(pid),
])
if within and (not view or wfs=='completed'):
wl = getWL( wfn )
dataset =None
if 'InputDataset' in wl:
dataset = wl['InputDataset']
if 'Task1' in wl and 'InputDataset' in wl['Task1']:
dataset = wl['Task1']['InputDataset']
if dataset:
text+=', '.join(['',
'<a href=https://cmsweb.cern.ch/das/request?input=%s target=_blank>input</a>'%dataset,
'<a href=https://cmsweb.cern.ch/phedex/prod/Data::Subscriptions#state=create_since=0;filter=%s target=_blank>sub</a>'%dataset,
'<a href=https://cmsweb.cern.ch/phedex/datasvc/xml/prod/subscriptions?dataset=%s&collapse=n target=_blank>ds</a>'%dataset,
'<a href=https://cmsweb.cern.ch/phedex/datasvc/xml/prod/blockreplicas?dataset=%s target=_blank>rep</a>'%dataset,
])
if p:
cached = filter(lambda d : d['RequestName']==wfn, cache)
if cached:
wl = cached[0]
else:
wl = getWorkLoad('cmsweb.cern.ch',wfn)
text+=', (%s)'%(wl['RequestPriority'])
pass
if pid:
if ms:
mcm_s = json.loads(os.popen('curl https://cms-pdmv.cern.ch/mcm/public/restapi/requests/get_status/%s --insecure'%pid).read())[pid]
text+=', <a href="https://cms-pdmv.cern.ch/mcm/requests?prepid=%s" target="_blank">mcm (%s)</a>'%(pid,mcm_s)
else:
text+=', <a href="https://cms-pdmv.cern.ch/mcm/requests?prepid=%s" target="_blank">mcm</a>'%(pid)
text+=', <a href="https://dmytro.web.cern.ch/dmytro/cmsprodmon/workflows.php?prep_id=%s" target="_blank">ac</a>'%(wl_pid)
text += ', <a href="https://%s/couchdb/workqueue/_design/WorkQueue/_rewrite/elementsInfo?request=%s" target="_blank">gq</a>'%(reqmgr_url,wfn)
text += ', <a href="https://its.cern.ch/jira/issues/?jql=(text~%s OR text~task_%s) AND project = CMSCOMPPR" target="_blank">jira</a>'% (pid, pid)
if status:
if wf.status.startswith('assistance'):
text+=', <a href="assistance.html#%s" target="_blank">assist</a>'%wfn
text+=' : %s '%(wf.status)
#if view and not wfs in ['acquired','assigned','assignment-approved']:
# text+='<a href="https://cms-pdmv.web.cern.ch/cms-pdmv/stats/growth/%s.gif" target="_blank"><img src="https://cms-pdmv.web.cern.ch/cms-pdmv/stats/growth/%s.gif" style="height:50px"></a>'%(wfn.replace('_','/'),wfn.replace('_','/'))
if ongoing:
#wl = getWL( wfn )
#if 'running' in wl['RequestStatus']:
if wfs!='acquired':
text+='<a href="https://cms-gwmsmon.cern.ch/prodview/%s" target="_blank"><img src="https://cms-gwmsmon.cern.ch/prodview/graphs/%s/daily" style="height:50px"></a>'%(wfn,wfn)
if ongoing:
if not os.path.isfile('%s/report/%s'%(monitor_dir,wfn)):
if (random.random() < 0.005):
#print wfn,"report absent, doing it"
print wfn,"report absent, NOT doing i. Too expensive"
pass
#os.system('python Unified/showError.py -w %s'%(wfn))
#text += '<a href=report/%s target=_blank>report</a>'%wfn
else:
#print wfn,"report absent, could be doing it"
pass
else:
text += '<a href=report/%s target=_blank>report</a>'%wfn
#text += ' <a href=%/report/%s target=_blank>e_report</a>'%(unified_url_eos,wfn)
#date2 = time.strftime('%Y-%m-%d+%H:%M', time.gmtime())
#date1 = time.strftime('%Y-%m-%d+%H:%M', time.gmtime(time.mktime(time.gmtime())-(30*24*60*60)) )
#text+=', <a href="http://dashb-cms-job.cern.ch/dashboard/templates/web-job2/#table=Jobs&date1=%s&date2=%s&sortby=site&task=wmagent_%s"> 1m</a>'%( date1, date2, wfn )
#date1 = time.strftime('%Y-%m-%d+%H:%M', time.gmtime(time.mktime(time.gmtime())-(7*24*60*60)) )
#text+=', <a href="http://dashb-cms-job.cern.ch/dashboard/templates/web-job2/#table=Jobs&date1=%s&date2=%s&sortby=site&task=wmagent_%s"> 1w</a>'%( date1, date2, wfn )
#date1 = time.strftime('%Y-%m-%d+%H:%M', time.gmtime(time.mktime(time.gmtime())-(1*24*60*60)) )
#text+=', <a href="http://dashb-cms-job.cern.ch/dashboard/templates/web-job2/#table=Jobs&date1=%s&date2=%s&sortby=site&task=wmagent_%s">1d</a>'%( date1, date2, wfn )
#date1 = time.strftime('%Y-%m-%d+%H:%M', time.gmtime(time.mktime(time.gmtime())-(5*60*60)) )
#text+=', <a href="http://dashb-cms-job.cern.ch/dashboard/templates/web-job2/#table=Jobs&date1=%s&date2=%s&sortby=site&task=wmagent_%s"> 5h</a>'%( date1, date2, wfn )
#date1 = time.strftime('%Y-%m-%d+%H:%M', time.gmtime(time.mktime(time.gmtime())-(1*60*60)) )
#text+=', <a href="http://dashb-cms-job.cern.ch/dashboard/templates/web-job2/#table=Jobs&date1=%s&date2=%s&sortby=site&task=wmagent_%s"> 1h</a>'%( date1, date2, wfn )
if ongoing and wfn in boost:
for task in boost[wfn]:
overflow = boost[wfn][task].get('ReplaceSiteWhitelist',None)
if not overflow:
overflow = boost[wfn][task].get('AddWhitelist',None)
if overflow:
text+=',boost (<a href=public/equalizor.json>%d</a>)'%len(overflow)
#text+="<hr>"
return text
def phl(phid):
text=', '.join([
str(phid),
'<a href="https://cmsweb.cern.ch/phedex/prod/Request::View?request=%s" target="_blank">vw</a>'%phid,
'<a href="https://cmsweb.cern.ch/phedex/prod/Data::Subscriptions?reqfilter=%s" target="_blank">sub</a>'%phid,
])
return text
def ol(out):
return '<a href="https://cmsweb.cern.ch/das/request?input=%s" target="_blank"> %s</a>'%(out,out)
def lap( comment ):
l = time.mktime(time.gmtime())
spend = l-lap.start
lap.start =l
print "Spend %d [s] for %s"%( spend, comment )
lap.start = time.mktime(time.gmtime())
## start to write it
html_doc = eosFile('%s/index.html'%monitor_dir)
print "Updating the status page ..."
UC = unifiedConfiguration()
if not caller:
try:
#caller = sys._getframe(1).f_code.co_name
caller = sys.argv[0].split('/')[-1].replace('.py','')
print "caller is"
print caller
except Exception as es:
caller = 'none found'
print "not getting frame"
print str(es)
summary_content = {}
view_not_a_module = ['agentInfo','componentInfo']
view_modules = ['injector','batchor','assignor','completor','GQ','equalizor','checkor','recoveror','actor','closor']+view_not_a_module
all_modules = list(set(view_modules + ['actor','addHoc','assignor','batchor','checkor','closor','completor','efficiencor','equalizor','htmlor','injector','messagor','recoveror','remainor','showError']))
html_doc.write("""
<html>
<head>
<META HTTP-EQUIV="refresh" CONTENT="900">
<script type="text/javascript">
function showhide(id) {
var e = document.getElementById(id);
e.style.display = (e.style.display == 'block') ? 'none' : 'block';
}
</script>
</head>
<body>
<br>
Last update on <b>%s(CET), %s(GMT)</b>
<br>
<hr>
<a href=info.txt target=_blank title="Some basic running info">info</a>
<a href=logs/ target=_blank title="Directory containing all the logs">logs</a>
<a href=http://cms-unified.web.cern.ch/cms-unified/joblogs/ target=_blank title="Directory containing logs of jobs that failed with critical errors">job logs</a>
<a href=http://cms-unified.web.cern.ch/cms-unified/condorlogs/ target=_blank title="Directory containing condor logs of jobs ">condor logs</a>
<a href=logs/last.log target=_blank title="Log of the last module that has run">last</a>
<a href=statuses.html title="Unified statuses">statuses</a>
<a href=https://dmytro.web.cern.ch/dmytro/cmsprodmon/ target=_blank>prod mon</a>
<a href=https://%s/wmstats/index.html target=_blank>wmstats</a>
<a href=http://t3serv001.mit.edu/~cmsprod/IntelROCCS/Detox/SitesInfo.txt target=_blank>detox</a>
<a href=http://dynamo.mit.edu/dynamo/detox.php target=_blank>dynamo</a>
<a href=locked.html>space</a>
<a href=outofspace.html>out of space</a>
<a href=remaining.html>locked</a>
<a href=logs/subscribor/last.log target=_blank>blocks</a>
<br>
<a href=data.html>json interfaces</a>
<a href=logs/addHoc/last.log>add-hoc op</a>
<a href=https://cmssst.web.cern.ch/cmssst/man_override/cgi/manualOverride.py/prodstatus target=_blank title="Link to a restricted page to override sites status">sites override</a>
<a href=https://cms-unified.web.cern.ch/cms-unified/showlog/?search=warning target=_blank><b><font color=orange>warning</b></font></a>
<a href=https://cms-unified.web.cern.ch/cms-unified/showlog/?search=critical target=_blank><b><font color=red>all critical</b></font></a>
<a href=https://its.cern.ch/jira/projects/CMSCOMPPR/issues target=_blank>JIRA</a>
<a href=toperror.html target=_blank>top errors</a>
<br>
%s
<hr>
<a href=https://dmytro.web.cern.ch/dmytro/cmsprodmon/><img src=https://dmytro.web.cern.ch/dmytro/cmsprodmon/images/campaign-RunningCpus.png style="height:150px"></a>
<a href=https://cms-gwmsmon.cern.ch/prodview><img src=https://cms-gwmsmon.cern.ch/prodview/graphs/prioritysummarycpusinuse/weekly style="height:150px" alt="Click here if it does not load"></a>
<a href=https://cms-gwmsmon.cern.ch/prodview><img src=https://cms-gwmsmon.cern.ch/prodview/graphs/prioritysummarycpuspending/weekly/log style="height:150px" alt="Click here if it does not load"></a>
<hr>
<br>
""" %(time.asctime(time.localtime()),
time.asctime(time.gmtime()),
reqmgr_url,
', '.join(['<a href=https://cms-unified.web.cern.ch/cms-unified/showlog/?search=critical&module=%s&limit=100 target=_blank><b><font color=red>%s</b></font></a>'%(m,m) for m in ['heartbeat']+view_modules])
)
)
text=""
count=0
count_by_campaign=defaultdict(lambda : defaultdict(int))
for wf in session.query(Workflow).filter(Workflow.status.startswith('considered')).all():
wl = getWL( wf.name )
count_by_campaign[wl['Campaign']][int(wl['RequestPriority'])]+=1
#print wf.name
text+="<li> %s (%d) </li> \n"%(wfl(wf,p=True), int(wl['RequestPriority']))
count+=1
text_by_c=""
for c in count_by_campaign:
text_by_c+='<li><a href=https://dmytro.web.cern.ch/dmytro/cmsprodmon/workflows.php?campaign=%s&in_production=1>%s</a> <a href="https://its.cern.ch/jira/issues/?jql=text~%s AND project = CMSCOMPPR">JIRA</a> (%d) : '%( c,c,c, sum(count_by_campaign[c].values()) )
for p in sorted(count_by_campaign[c].keys()):
text_by_c+="%d (%d), "%(p,count_by_campaign[c][p])
text_by_c+="</li>"
html_doc.write("""
Worflow next to handle (%d) <a href=https://cms-pdmv.cern.ch/mcm/batches?status=new&page=-1 target="_blank"> batches</a> <a href=logs/injector/last.log target=_blank>log</a> <a href=logs/transferor/last.log target=_blank>postlog</a>
<a href="javascript:showhide('considered')">[Click to show/hide]</a>
<br>
<div id="considered" style="display:none;">
<ul>
<li> By workflow (%d) </li><a href="javascript:showhide('considered_bywf')">[Click to show/hide]</a><div id="considered_bywf" style="display:none;">
<ul>
%s
</ul></div>
<li> By campaigns (%d) </li><a href="javascript:showhide('considered_bycamp')">[Click to show/hide]</a><div id="considered_bycamp" style="display:none;">
<ul>
%s
</ul></div>
</ul>
</div>
"""%(count,
count, text,
len(count_by_campaign), text_by_c))
lap( 'done with considered' )
text=""
count=0
count_by_campaign=defaultdict(lambda : defaultdict(int))
for wf in session.query(Workflow).filter(Workflow.status=='staging').all():
wl = getWL( wf.name )
count_by_campaign[wl['Campaign']][int(wl['RequestPriority'])]+=1
text+="<li> %s (%d)</li> \n"%(wfl(wf,within=True), int(wl['RequestPriority']))
count+=1
text_by_c=""
summary_content['staging'] = count
summary_content['staging_by_campaign'] = len(count_by_campaign)
for c in count_by_campaign:
text_by_c+='<li><a href=https://dmytro.web.cern.ch/dmytro/cmsprodmon/workflows.php?campaign=%s&in_production=1>%s</a> <a href="https://its.cern.ch/jira/issues/?jql=text~%s AND project = CMSCOMPPR">JIRA</a> (%d) : '%( c,c,c, sum(count_by_campaign[c].values()) )
for p in sorted(count_by_campaign[c].keys()):
text_by_c+="%d (%d), "%(p,count_by_campaign[c][p])
text_by_c+="</li>"
html_doc.write("""
Worflow waiting in staging (%d) <a href=logs/transferor/last.log target=_blank>log</a> <a href=logs/stagor/last.log target=_blank>postlog</a>
<a href="javascript:showhide('staging')">[Click to show/hide]</a>
<br>
<div id="staging" style="display:none;">
<ul>
<li> By workflow (%d) </li><a href="javascript:showhide('staging_bywf')">[Click to show/hide]</a><div id="staging_bywf" style="display:none;">
<ul>
%s
</ul></div>
<li> By campaigns (%d) </li><a href="javascript:showhide('staging_bycamp')">[Click to show/hide]</a><div id="staging_bycamp" style="display:none;">
<ul>
%s
</ul></div>
</ul>
</div>
"""%(count,
count, text,
len(count_by_campaign), text_by_c))
lap ( 'done with staging' )
text_bytr="<ul>"
count=0
transfer_per_wf = defaultdict(list)
all_active = sorted(set([ts.phedexid for ts in session.query(TransferImp).filter(TransferImp.active == True).all()]))
for phedexid in all_active:
hide = True
t_count = 0
stext=""
for imp in session.query(TransferImp).filter(TransferImp.phedexid == phedexid).all():
w = imp.workflow
if not w: continue
hide &= (w.status != 'staging' )
if w.status in ['considered','staging','staged']:
stext += "<li> %s </li>\n"%( wfl(w,status=True))
transfer_per_wf[w].append( imp.phedexid )
t_count +=1
stext = '<li> %s serves %d workflows<br><a href="javascript:showhide(\'%s\')">[show/hide]</a> <div id="%s" style="display:none;"><ul>\n'%( phl(phedexid),
t_count,
phedexid,
phedexid) + stext
stext+="</ul></li>\n"
if hide:
#text+="<li> %s not needed anymore to start running (does not mean it went through completely)</li>"%phl(ts.phedexid)
pass
else:
count+=1
text_bytr+=stext
text_bytr+="</ul>"
text_bywf="<ul>"
for wf in transfer_per_wf:
text_bywf += "<li> %s </li>"%(wfl(wf,within=True))
text_bywf += '<a href=javascript:showhide("transfer_%s")>[Click to show/hide] %d transfers</a>'% (wf.name, len(transfer_per_wf[wf]))
text_bywf += '<div id="transfer_%s" style="display:none;">'% wf.name
text_bywf += "<ul>"
for pid in sorted(transfer_per_wf[wf]):
text_bywf += "<li> %s </li>"%(phl(pid))
text_bywf += "</ul></div><hr>"
text_bywf += '</ul>'
try:
stuck_transfer = json.loads(eosRead('%s/stuck_transfers.json'%monitor_pub_dir))
except:
stuck_transfer = {}
print "eos is screwing with us"
html_doc.write("""
Transfer on-going (%d) <a href=http://cmstransferteam.web.cern.ch/cmstransferteam/ target=_blank>dashboard</a> <a href=logs/transferor/last.log target=_blank>log</a> <a href=logs/stagor/last.log target=_blank>postlog</a> <a href=public/stuck_transfers.json target=_blank> %d stuck</a>
<a href="javascript:showhide('transfer')">[Click to show/hide]</a>
<br>
<div id="transfer" style="display:none;">
<ul>
<li> By Workflow
<a href="javascript:showhide('transfer_bywf')">[Click to show/hide]</a>
<div id="transfer_bywf" style="display:none;">
%s
</div>
</li>
<li> By transfer request
<a href="javascript:showhide('transfer_byreq')">[Click to show/hide]</a>
<div id="transfer_byreq" style="display:none;">
%s
</div>
</li>
</ul>
</div>
"""%(count,
len( stuck_transfer ),
text_bywf,
text_bytr))
summary_content['stuck_placement'] = len(stuck_transfer)
lap( 'done with transfers' )
text=""
count=0
count_by_campaign=defaultdict(lambda : defaultdict(int))
for wf in session.query(Workflow).filter(Workflow.status=='staged').all():
wl = getWL( wf.name )
count_by_campaign[wl['Campaign']][int(wl['RequestPriority'])]+=1
text+="<li> %s </li> \n"%wfl(wf,p=True)
count+=1
text_by_c=""
for c in count_by_campaign:
text_by_c+='<li><a href=https://dmytro.web.cern.ch/dmytro/cmsprodmon/workflows.php?campaign=%s&in_production=1>%s</a> <a href="https://its.cern.ch/jira/issues/?jql=text~%s AND project = CMSCOMPPR">JIRA</a> (%d) : '%( c,c,c, sum(count_by_campaign[c].values()) )
for p in sorted(count_by_campaign[c].keys()):
text_by_c+="%d (%d), "%(p,count_by_campaign[c][p])
text_by_c+="</li>"
html_doc.write("""Worflow ready for assigning (%d) <a href=logs/stagor/last.log target=_blank>log</a> <a href=logs/assignor/last.log target=_blank>postlog</a> <a href=GQ.txt target=_blank> GQ</a>
<a href="javascript:showhide('staged')">[Click to show/hide]</a>
<br>
<div id="staged" style="display:none;">
<br>
<ul>
<li> By workflow (%d) </li><a href="javascript:showhide('staged_bywf')">[Click to show/hide]</a><div id="staged_bywf" style="display:none;">
<ul>
%s
</ul></div>
<li> By campaigns (%d) </li><a href="javascript:showhide('staged_bycamp')">[Click to show/hide]</a><div id="staged_bycamp" style="display:none;">
<ul>
%s
</ul></div>
</ul>
</div>
"""%(count,
count, text,
len(count_by_campaign), text_by_c))
lap( 'done with staged' )
lines=[]
count_by_campaign=defaultdict(lambda : defaultdict(int))
count = 0
for wf in session.query(Workflow).filter(Workflow.status=='away').all():
wl = getWL( wf.name )
count_by_campaign[wl['Campaign']][int(wl['RequestPriority'])]+=1
#color = 'orange' if wf.name in relvals else 'black' ## this difference of color can be put back somehow using batchInfo
color = 'black'
lines.append("<li> <font color=%s>%s</font> <hr></li>"%(color,wfl(wf,view=True,ongoing=True)))
count += 1
text_by_c=""
summary_content['ongoing'] = count
summary_content['ongoing_by_campaign'] = len(count_by_campaign)
for c in sorted(count_by_campaign.keys()):
text_by_c+="""
<li> <a href=https://dmytro.web.cern.ch/dmytro/cmsprodmon/workflows.php?campaign=%s>%s</a> <a href=https://dmytro.web.cern.ch/dmytro/cmsprodmon/requests.php?in_production=1&campaign=%s>(%d)</a>
<a href=https://dmytro.web.cern.ch/dmytro/cmsprodmon/campaign.php?campaign=%s>mon</a>
<a href=https://dmytro.web.cern.ch/dmytro/cmsprodmon/requests.php?in_production=1&rsort=6&status=running&campaign=%s>top</a>
<a href=https://cms-pdmv.cern.ch/pmp/historical?r=%s target=_blank>pmp</a>
"""%( c,c,c,
sum(count_by_campaign[c].values()),c,c,c )
for p in sorted(count_by_campaign[c].keys()):
text_by_c+="%d (%d), "%(p,count_by_campaign[c][p])
text_by_c += '<img src=https://dmytro.web.cern.ch/dmytro/cmsprodmon/images/%s-history_nevents-limit-30.png style="height:70px">'% (c)
text_by_c += '<img src=https://dmytro.web.cern.ch/dmytro/cmsprodmon/images/%s-history_requests-limit-30.png style="height:70px">'% (c)
text_by_c+="</li>"
lines.sort()
html_doc.write("""
Worflow on-going (%d) <a href=https://dmytro.web.cern.ch/dmytro/cmsprodmon/requests_in_production.php target=_blank>ongoing</a> <a href=https://cms-logbook.cern.ch/elog/Workflow+processing/?mode=summary target=_blank>elog</a> <a href=https://cms-gwmsmon.cern.ch/prodview target=_blank>queues</a> <a href=logs/assignor/last.log target=_blank>log</a> <a href=logs/checkor/last.log target=_blank>postlog</a> <a href=logs/equalizor/last.log target=_blank>equ</a> <a href=logs/completor/last.log target=_blank>comp</a> <a href="https://dmytro.web.cern.ch/dmytro/cmsprodmon/requests.php?in_production=1&rsort=6&older=3">lasting</a>
<a href="javascript:showhide('away')">[Click to show/hide]</a>
<br>
<div id="away" style="display:none;">
<ul>
<li>By workflow (%d) </li>
<a href="javascript:showhide('away_bywf')">[Click to show/hide]</a><div id="away_bywf" style="display:none;">
<ul>
%s
</ul></div>
<li> By campaigns (%d) </li><a href="javascript:showhide('away_bycamp')">[Click to show/hide]</a><div id="away_bycamp" style="display:none;">
<ul>
%s
</ul></div>
</ul>
</div>
"""%(len(lines),
len(lines),
'\n'.join(lines),
len(count_by_campaign),
text_by_c
))
lap ( 'done with away' )
text=""
count=0
#for wf in session.query(Workflow).filter(Workflow.status == 'assistance-custodial').all():
for wf in session.query(Workflow).filter(Workflow.status.startswith('assistance')).filter(Workflow.status.contains('custodial')).all():
text+="<li> %s </li> \n"%wfl(wf,view=True,update=True,status=True)
count+=1
text+="</ul></div>\n"
html_doc.write("""Worflow that are closing (%d)
<a href=closeout.html target=_blank>closeout</a>
<a href=logs/checkor/last.log target=_blank>log</a> <a href=logs/closor/last.log target=_blank>postlog</a>
<a href="javascript:showhide('closing')">[Click to show/hide]</a>
<br>
<div id="closing" style="display:none;">
<br>
<ul>
"""%count)
html_doc.write(text)
lap ( 'done with closing' )
assistance_by_type = defaultdict(list)
text=""
count=0
for wf in session.query(Workflow).filter(Workflow.status.startswith('assistance-')).all():
assistance_by_type[wf.status].append( wf )
count+=1
for assistance_type in sorted(assistance_by_type.keys()):
text += "<li> %s (%d) <a href=\"javascript:showhide('%s')\">[Click to show/hide]</a><br><div id=\"%s\" style=\"display:none;\"><ul>"%( assistance_type,
len(assistance_by_type[assistance_type]),
assistance_type,
assistance_type,
)
for wf in assistance_by_type[assistance_type]:
text+="<li> %s <hr></li> \n"%wfl(wf,view=True,within=True,status=True,update=True)
text += "</ul></div></li>\n"
html_doc.write("""Worflow which need assistance (%d)
<a href=assistance.html target=_blank>assistance</a>
<a href=logs/checkor/last.log target=_blank>log</a> <a href=logs/recoveror/last.log target=_blank>postlog</a>
<a href=https://dmytro.web.cern.ch/dmytro/cmsprodmon/requests.php?in_production=1&rsort=6&older=3&status=validation target=_blank>lasting</a>
<a href="javascript:showhide('assistance')">[Click to show/hide]</a>
<br>
<div id="assistance" style="display:none;">
<br>
<ul>
%s
</ul>
</div>
"""%(count, text))
lap ( 'done with assistance' )
text=""
count=0
for wf in session.query(Workflow).filter(Workflow.status == 'close').all():
text+="<li> %s </li> \n"%wfl(wf)
count+=1
text+="</ul></div>\n"
html_doc.write("""Worflow ready to close (%d)
<a href=logs/checkor/last.log target=_blank>log</a> <a href=logs/closor/last.log target=_blank>postlog</a>
<a href="javascript:showhide('close')">[Click to show/hide]</a>
<br>
<div id="close" style="display:none;">
<br>
<ul>
"""%count)
html_doc.write(text)
lap ( 'done with annoucing' )
text=""
count=0
for wf in session.query(Workflow).filter(Workflow.status=='trouble').all():
text+="<li> %s </li> \n"%wfl(wf)
count+=1
text+="</ul></div>\n"
html_doc.write("""Worflow with issue (%d) <a href=logs/closor/last.log target=_blank>log</a> <a href=logs/injector/last.log target=_blank>postlog</a>
<a href="javascript:showhide('trouble')">[Click to show/hide]</a>
<br>
<div id="trouble" style="display:none;">
<br>
<ul>
"""%count)
html_doc.write(text)
lap ( 'done with trouble' )
text=""
count=0
for wf in session.query(Workflow).filter(Workflow.status=='forget').all():
text+="<li> %s </li> \n"%wfl(wf)
count+=1
text+="</ul></div>\n"
html_doc.write("""
Worflow to forget (%d) <a href=logs/injector/last.log target=_blank>log</a> <a href=logs/lockor/last.log target=_blank>postlog</a>
<a href="javascript:showhide('forget')">[Click to show/hide]</a>
<br>
<div id="forget" style="display:none;">
<br>
<ul>
"""%count)
html_doc.write(text)
lap ( 'done with forget' )
text=""
count=0
for wf in session.query(Workflow).filter(Workflow.status=='done').all():
text+="<li> %s </li> \n"%wfl(wf)#,ms=True)
count+=1
text+="</ul></div>\n"
html_doc.write("""
Worflow through (%d) <a href=logs/closor/last.log target=_blank>log</a> <a href=logs/lockor/last.log target=_blank>postlog</a>
<a href="javascript:showhide('done')">[Click to show/hide]</a>
<br>
<div id="done" style="display:none;">
<br>
<ul>
"""%count)
html_doc.write(text)
lap ( 'done with done' )
wfs = session.query(Workflow).filter(Workflow.status.endswith('-unlock')).all()
html_doc.write(" Workflows unlocked : %s <a href=logs/lockor/last.log target=_blank>log</a><br>"%(len(wfs)))
lap ( 'done with unlocked' )
text=""
lines_thisweek=[]
lines_lastweek=[]
now = time.mktime(time.gmtime())
this_week = int(time.strftime("%W",time.gmtime()))
start_time_two_weeks_ago = time.mktime(time.gmtime(now - (20*24*60*60))) # 20
last_week = int(time.strftime("%W",time.gmtime(now - ( 7*24*60*60))))
all_locks = [l.item.split('#')[0] for l in session.query(Lock).filter(Lock.lock == True).all() if l.item]
try:
waiting_custodial = json.loads(eosRead('%s/waiting_custodial.json'%monitor_dir))
except Exception as e:
print str(e)
print "eos is screwing with us"
waiting_custodial = {}
all_pending_approval_custodial = dict([(k,item) for k,item in waiting_custodial.items() if 'nodes' in item and not any([node['decided'] for node in item['nodes'].values()]) ])
n_pending_approval = len( all_pending_approval_custodial )
#n_pending_approval = len([item for item in waiting_custodial.values() if 'nodes' in item and not any([node['decided'] for node in item['nodes'].values() ])])
try:
missing_approval_custodial = json.loads(eosRead('%s/missing_approval_custodial.json'%monitor_dir))
except Exception as e:
print str(e)
print "eos is screwing with us"
missing_approval_custodial = {}
try:
stuck_custudial = json.loads(eosRead('%s/stuck_custodial.json'%monitor_pub_dir))
except Exception as e:
stuck_custudial = {}
print str(e)
print "eos is screwing with us"
try:
lagging_custudial = json.loads(eosRead('%s/lagging_custodial.json'%monitor_dir))
except Exception as e:
lagging_custudial = {}
print str(e)
print "eos is screwing with us"
if len(stuck_custudial):
stuck_string = ', <font color=red>%d appear to be <a href=public/stuck_custodial.json>stuck</a></font>'% len(stuck_custudial)
else:
stuck_string = ''
if len(missing_approval_custodial):
long_approve_string = ', <font color=red>%d more than %d days</font>'%( len(missing_approval_custodial), UC.get('transfer_timeout'))
else:
long_approve_string = ''
output_within_two_weeks=session.query(Output).filter(Output.date>=start_time_two_weeks_ago).all()
waiting_custodial_string=""
waiting_custodial_strings=[]
for ds in waiting_custodial:
out = None
## lots of it will be within two weeks
of = filter(lambda odb: odb.datasetname == ds, output_within_two_weeks)
if of:
out = of[0]
else:
out = session.query(Output).filter(Output.datasetname == ds).first()
if out:
info = waiting_custodial[out.datasetname]
action = 'going'
if out.datasetname in all_pending_approval_custodial:
action = '<font color=red>pending</font>'
try:
size = str(info['size'])
except:
size = "x"
destination = ",".join(info['nodes'].keys())
if not destination:
destination ='<font color=red>NO SITE</font>'
a_waiting_custodial_string = "<li>on week %s : %s %s</li>"%(
time.strftime("%W (%x %X)",time.gmtime(out.date)),
ol(out.datasetname),
' %s [GB] %s to %s on %s (<a href="https://cmsweb.cern.ch/phedex/datasvc/xml/prod/requestlist?dataset=%s&node=T*MSS">%d missing</a>)'%( size, action, destination, time.asctime(time.gmtime(info['checked'])), out.datasetname, info['nmissing'])
)
waiting_custodial_strings.append( (out.date, a_waiting_custodial_string) )
waiting_custodial_strings.sort( key = lambda i:i[0] )
waiting_custodial_string="\n".join( [i[1] for i in waiting_custodial_strings] )
#start_time_two_weeks_ago = time.mktime(time.strptime("15-0-%d"%(this_week-2), "%y-%w-%W"))
per_day_this_week = defaultdict(int)
for out in output_within_two_weeks:
if not out.workflow:
print "This is a problem with",out.datasetname
continue
if out.workflow.status in ['done-unlock','done','clean','clean-out','clean-unlock']:
custodial=''
if out.datasetname in waiting_custodial:
info = waiting_custodial[out.datasetname]
try:
try:
size = str(info['size'])
except:
size = "x"
destination = ",".join(info['nodes'].keys())
if not destination:
destination ='<font color=red>NO SITE</font>'
action = 'going'
if out.datasetname in all_pending_approval_custodial:
action = '<font color=red>pending</font>'
custodial=' %s [GB] %s to %s on %s (<a href="https://cmsweb.cern.ch/phedex/datasvc/xml/prod/requestlist?dataset=%s&node=T*MSS">%d missing</a>)'%( size, action, destination, time.asctime(time.gmtime(info['checked'])), out.datasetname, info['nmissing'])
except Exception as e:
#print info
#print str(e)
pass
elif out.datasetname in all_locks:
custodial='<font color=green>LOCKED</font>'
out_week = int(time.strftime("%W",time.gmtime(out.date)))
out_day = int(time.strftime("%j",time.gmtime(out.date)))
##only show current week, and the previous.
if last_week==out_week:
lines_lastweek.append("<li>on week %s : %s %s</li>"%(
time.strftime("%W (%x %X)",time.gmtime(out.date)),
ol(out.datasetname),
custodial
)
)
if this_week==out_week:
per_day_this_week[out_day]+=1
lines_thisweek.append("<li>on week %s : %s %s</li>"%(
time.strftime("%W (%x %X)",time.gmtime(out.date)),
ol(out.datasetname),
custodial
)
)
lines_thisweek.sort()
lines_lastweek.sort()
per_day_s = ", ".join([ "day %s (%d)"%( day, per_day_this_week[day]) for day in sorted(per_day_this_week.keys()) ])
html_doc.write("""Output produced (%d) <a href=https://dmytro.web.cern.ch/dmytro/cmsprodmon/requests.php?in_disagreement=1 target=_blank>disagreements</a>
<a href="javascript:showhide('output')">[Click to show/hide]</a>
<br>
<div id="output" style="display:none;">
<br>
<ul>
<li> %d waiting to go to tape</li>
<ul>
<li> %d waiting for tape approval%s</li>
<li> %d are not completed after %d days%s</li>
<li> Full list (%d) <a href="javascript:showhide('waiting-custodial')">[Click to show/hide]</a>
<div id="waiting-custodial" style="display:none;">
<ul>
%s
</ul>
</div>
</li>
</ul>
<li> Last week (%d) </li><a href="javascript:showhide('output_lastweek')">[Click to show/hide]</a><div id="output_lastweek" style="display:none;"><ul>
%s
</ul></div>
<li> This week (%d) %s </li><a href="javascript:showhide('output_thisweek')">[Click to show/hide]</a><div id="output_thisweek" style="display:none;"><ul>
%s
</ul></div></div>
"""%( len(lines_lastweek)+len(lines_thisweek),
len(waiting_custodial),
n_pending_approval,long_approve_string,
len(lagging_custudial),UC.get('transfer_timeout'),stuck_string,
len(waiting_custodial),waiting_custodial_string,
len(lines_lastweek),
'\n'.join(lines_lastweek),
len(lines_thisweek), per_day_s,
'\n'.join(lines_thisweek))
)
summary_content['last_week'] = len(lines_lastweek)
lap ( 'done with output' )
html_doc.write("""Job installed
<a href="javascript:showhide('acron')">[Click to show/hide]</a>
<br>
<div id="acron" style="display:none;">
<br>""")
## dump of acrontab
html_doc.write("""
<pre>
%s
%s
</pre>
"""%(os.getenv('USER'),
os.popen('acrontab -l | grep -i unified | grep -v \# |sort -k 6').read()))
per_module = defaultdict(list)
last_module = defaultdict( str )
ssi = StartStopInfo()
now = time.mktime(time.localtime())## the date in the log is in local time
ssi.purge(now, 15 ) ## remove all >15 days old doc
for module_name in all_modules:
if module_name in ['messagor','cleanor']: continue
per_module[module_name] = ssi.get(module_name, metric='lap')
last_module[ module_name] = ssi.get(module_name, metric='start')
if last_module[ module_name]:
last_module[ module_name] = max(last_module[ module_name])
else:
print "no mongod record of SS for",module_name
last_module[ module_name] = None
html_doc.write("Module running time<br>")
html_doc.write("<table border=1><thead><tr><th>Module</th><th>Last Ran</th><th>Last Runtime</th><th>Avg Runtime</th></tr></thead>")
for m in sorted(last_module.keys()):
last_time = last_module[m]
if not last_time: continue
heart_beat_time_out = 12
since_last = now-last_time
if since_last > (heart_beat_time_out*60*60): #6h heart beat
sendLog('heartbeat',"The module %s has not ran in %s hours, now %s"%(m, heart_beat_time_out, display_time( since_last )), level='critical')
else:
print "module %s has ran last since %s"%( m , display_time( since_last ))
last_module[m] = "%s ago"%( display_time( since_last ) )
for m in sorted(per_module.keys()):
#,spends in per_module.items():
spends = per_module[m]
if spends:
avg = sum(spends)/float(len(spends))
lasttime = spends[-1]
else:
avg = lasttime = 0
html_doc.write("""
<tr>
<td width=300>%s</td>
<td width=300>%s</td>
<td width=300>%s</td>
<td width=300>%s</td>
</tr>"""%(m,
last_module[m],
display_time(lasttime),
display_time(avg)
))
html_doc.write("</table>")
html_doc.write("</div>\n")
lap ( 'done with jobs' )
text=""
count=0
CI = campaignInfo()
#for (c,info) in CI.campaigns.items():
for c in sorted(CI.campaigns.keys()):
info = CI.campaigns[c]
#if 'go' in info and info['go']:
if 'go' in info and info['go']:
text+="<li><font color=green>%s</font>"%c
else:
text+="<li><font color=red>%s</font>"%c
text += '<img src=https://dmytro.web.cern.ch/dmytro/cmsprodmon/images/%s-history_nevents-limit-30.png style="height:70px">'% (c)
text += '<img src=https://dmytro.web.cern.ch/dmytro/cmsprodmon/images/%s-history_requests-limit-30.png style="height:70px">'% (c)
text += """
<a href="javascript:showhide('campaign_%s')">[Click to show/hide]</a><br><div id="campaign_%s" style="display:none;">
"""%( c, c )
text += "<br><pre>%s</pre> </div></li>"%json.dumps( info, indent=2)
count+=1
html_doc.write("""Campaign configuration
<a href="javascript:showhide('campaign')">[Click to show/hide]</a>
<br>
<div id="campaign" style="display:none;">
<br>
<ul>
%s
</ul></div>
"""%(text))
text=""
count=0
n_column = 4
SI = siteInfo()
#date1m = time.strftime('%Y-%m-%d+%H:%M', time.gmtime(time.mktime(time.gmtime())-(30*24*60*60)) )
#date7d = time.strftime('%Y-%m-%d+%H:%M', time.gmtime(time.mktime(time.gmtime())-(7*24*60*60)) )
#date1d = time.strftime('%Y-%m-%d+%H:%M', time.gmtime(time.mktime(time.gmtime())-(24*60*60)) )
#date1h = time.strftime('%Y-%m-%d+%H:%M', time.gmtime(time.mktime(time.gmtime())-(1*60*60)) )
#date5h = time.strftime('%Y-%m-%d+%H:%M', time.gmtime(time.mktime(time.gmtime())-(5*60*60)) )
now = time.strftime('%Y-%m-%d+%H:%M', time.gmtime())
upcoming = json.loads( eosRead('%s/GQ.json'%monitor_dir))
text +='<ul>'
# """
#<ul><li>Sites in use<br><a href="javascript:showhide('site_types')">[Click to show/hide]</a></li>
#<ul>"""
for_max_running = dataCache.get('gwmsmon_prod_site_summary')
upcoming_by_site = defaultdict( lambda : defaultdict(int))
available_ratios = defaultdict(float)
upcoming_ratios = defaultdict(float)
for team,agents in getAllAgents(reqmgr_url).items():
for agent in agents:
if not 'WMBS_INFO' in agent: continue
if not 'sitePendCountByPrio' in agent['WMBS_INFO']: continue
for site in agent['WMBS_INFO']['sitePendCountByPrio']:
a = sum(agent['WMBS_INFO']['sitePendCountByPrio'][site].values())
#print site,team,a
#print a
#print agent['WMBS_INFO']['sitePendCountByPrio'][site]
if a: upcoming_by_site[team][site] += a
try:
sites_full = json.loads(eosRead('%s/sites_full.json'%base_eos_dir))
except:
sites_full = []
for t in ['sites_T0s_all','sites_T1s_all','sites_T2s_all','sites_T3s_all']:
# text+="""
#<li>%s<a href="javascript:showhide('%s')">[Click to show/hide]</a><br>
#<div id="%s" style="display:none;">
#<table border=1>
#"""%( t, t, t)
text +='<li>%s<div id="%s"><table border=1>'%( t, t )
c=0
for site in sorted(getattr(SI,t)):
site_se = SI.CE_to_SE(site)
cpu = SI.cpu_pledges[site] if site in SI.cpu_pledges else 'N/A'
disk = SI.disk[site_se] if site_se in SI.disk else 'N/A'
if c==0:
text+="<tr>"
if not disk:
ht_disk = '<a href=remaining_%s.html><font color=red>Disk available: %s</font></a>'%(SI.CE_to_SE(site),disk)
else:
ht_disk = 'Disk available: %s'%disk
up_com = ""
usage = for_max_running[site]['CpusInUse'] if site in for_max_running else 0
ht_cpu = 'CPU current/max: %s / %s'%(usage,cpu)
if site_se in upcoming: