def selfcheck self messages if Definition_h RMQ_ACTIVE restarted excee

 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
def selfcheck(self):
messages = []
if Definition_h.RMQ_ACTIVE:
restarted, exceededRestarts = self.restartDeadRmqClients()
if exceededRestarts:
self.writeSelfcheckReport(huselfcheck.STATUS_ERROR,
"The maximum allowed number of restarts for RabbitMQ client has been exceeded. Commspooler has been automatically stopped.")
self.stop()
if restarted:
messages.append(
(huselfcheck.STATUS_ERROR, self.formatRestartedClients(restarted))
)
if not self.lockFileExists():
messages.append(
(huselfcheck.STATUS_ERROR, "Commspooler is not running properly, no lock file present. "
"Action: Commspooler Process should be restarted.")
)
idleTime = self._commMonitor.getIdleTime() * 60
if idleTime >= Definition_h.COMMSPOOLER_IDLE_TIME_THRESHOLD_MIN:
messages.append(
(huselfcheck.STATUS_ERROR, "Commspooler is not running properly, no communications have been executed during the last {idleTime} minutes. "
"Action: Commspooler process should be restarted".format(idleTime=idleTime))
)
hungupTasks = self._commMonitor.getHungupTasks()
if hungupTasks:
commIds = ", ".join(str(t.comm.id) for t in hungupTasks if t.comm.id)
messages.append(
(huselfcheck.STATUS_ERROR, "Communications with ids {commIds} have hung up. "
"Action: Check commspooler logs for detailed info on these communications.".format(commIds=commIds))
)
status, fullMessage = self.buildSelfcheckReport2(messages)
self.writeSelfcheckReport(status, fullMessage)
def buildSelfcheckReport2(self, messages):
currentStatus = huselfcheck.STATUS_OK
for status, _ in messages:
# picking the most severe status
if huselfcheck.compareStatus(status, currentStatus) > 0:
currentStatus = status
fullMessage = "\n".join(messages) or "Ready."
return currentStatus, fullMessage