@@ -42,15 +42,15 @@ class StatesAccountingAgent(AgentModule):
42
42
43
43
# PilotsHistory fields
44
44
__pilotKeyFields = ["TaskQueueID" , "GridSite" , "GridType" , "Status" ]
45
- __pilotValueFields = ["Pilots " ]
45
+ __pilotValueFields = ["NumOfPilots " ]
46
46
47
47
def initialize (self ):
48
48
"""Standard initialization"""
49
49
# This agent will always loop every 15 minutes
50
50
self .am_setOption ("PollingTime" , 900 )
51
51
52
52
self .backends = self .am_getOption ("Backends" , "Accounting" ).replace (" " , "" ).split ("," )
53
- self .monitoringEnabled = Operations ().getValue ("monitoringEnabled" , " False" )
53
+ self .monitoringEnabled = Operations ().getValue ("monitoringEnabled" , False )
54
54
55
55
messageQueue = self .am_getOption ("MessageQueue" , "dirac.wmshistory" )
56
56
@@ -62,7 +62,7 @@ def initialize(self):
62
62
self .datastores ["Monitoring" ] = MonitoringReporter (
63
63
monitoringType = "WMSHistory" , failoverQueueName = messageQueue
64
64
)
65
- self .pilotReporter = MonitoringReporter (monitoringType = "PilotsHistory" )
65
+ self .pilotReporter = MonitoringReporter (monitoringType = "PilotsHistory" , failoverQueueName = messageQueue )
66
66
67
67
self .__jobDBFields = []
68
68
for field in self .__summaryKeyFieldsMapping :
@@ -77,32 +77,34 @@ def execute(self):
77
77
"""Main execution method"""
78
78
79
79
# PilotsHistory to Monitoring
80
+ self .log .info ("Committing PilotsHistory to Monitoring" )
80
81
if self .monitoringEnabled :
81
82
result = PilotAgentsDB .getSummarySnapshot (self .__pilotKeyFields )
82
83
now = Time .dateTime ()
83
84
if not result ["OK" ]:
84
85
self .log .error (
85
- "Can't get the PilotAgentsDB summary" , "%s: won't commit at this cycle" % result ["Message" ]
86
+ "Can't get the PilotAgentsDB summary" ,
87
+ "%s: won't commit PilotsHistory at this cycle" % result ["Message" ],
86
88
)
87
89
return S_ERROR ()
88
90
89
91
values = result ["Value" ][1 ]
90
92
for record in values :
91
93
record = record [1 :]
92
94
rD = {}
93
- for iP in range ( len ( self .__pilotKeyFields ) ):
95
+ for iP in enumerate ( self .__pilotKeyFields ):
94
96
rD [self .__pilotKeyFields [iP ]] = record [iP ]
95
97
record = record [len (self .__pilotKeyFields ) :]
96
- for iP in range ( len ( self .__pilotValueFields ) ):
98
+ for iP in enumerate ( self .__pilotValueFields ):
97
99
rD [self .__pilotValueFields [iP ]] = int (record [iP ])
98
100
rD ["timestamp" ] = int (Time .toEpoch (now ))
99
- self .log .verbose ("Adding following PilotsHistory record to Reporter: \n " , rD )
101
+ self .log .debug ("Adding following PilotsHistory record to Reporter: \n " , rD )
100
102
self .pilotReporter .addRecord (rD )
101
103
102
- self .log .info ("Committing PilotsHistory to Monitoring" )
104
+ self .log .info ("Committing to Monitoring... " )
103
105
result = self .pilotReporter .commit ()
104
106
if not result ["OK" ]:
105
- self .log .error ("Could not commit PilotsHistory to Monitoring" )
107
+ self .log .error ("Could not commit to Monitoring" )
106
108
return S_ERROR ()
107
109
self .log .verbose ("Done committing PilotsHistory to Monitoring" )
108
110
0 commit comments