[wiki] MonitStatus: "status ok" == biiieenn
Et un peu de refactoring mineur.
This commit is contained in:
parent
2fa78d722c
commit
5f3fb2915a
1 changed files with 6 additions and 3 deletions
|
@ -14,6 +14,9 @@ Exemple :
|
||||||
|
|
||||||
statusfolder = '/usr/scripts/var/monit/status'
|
statusfolder = '/usr/scripts/var/monit/status'
|
||||||
|
|
||||||
|
def is_ok(state):
|
||||||
|
return state.lower() in ['running','accessible', 'status ok']
|
||||||
|
|
||||||
def NotRunningHosts() :
|
def NotRunningHosts() :
|
||||||
"""
|
"""
|
||||||
Retourne la liste des hotes ou Monit ne tourne pas ou que
|
Retourne la liste des hotes ou Monit ne tourne pas ou que
|
||||||
|
@ -93,7 +96,7 @@ def AllStatusOff () :
|
||||||
for s in status[h][t].keys() :
|
for s in status[h][t].keys() :
|
||||||
|
|
||||||
# on supprime un status s'il est Up
|
# on supprime un status s'il est Up
|
||||||
if status[h][t][s]['status'].lower() in ['running','accessible'] :
|
if is_ok(status[h][t][s]['status']):
|
||||||
status[h][t].pop(s)
|
status[h][t].pop(s)
|
||||||
|
|
||||||
# reste-t-il des services dans le groupe
|
# reste-t-il des services dans le groupe
|
||||||
|
@ -126,7 +129,7 @@ def FormatService(Type, Service, Data, f) :
|
||||||
result += f.text(Service)
|
result += f.text(Service)
|
||||||
result += f.strong(0)
|
result += f.strong(0)
|
||||||
result += f.table_cell(0)
|
result += f.table_cell(0)
|
||||||
if Data['status'].lower() in ['running','accessible'] :
|
if is_ok(Data['status']):
|
||||||
result += f.table_cell(1,{'style':'background-color:lime'})
|
result += f.table_cell(1,{'style':'background-color:lime'})
|
||||||
else :
|
else :
|
||||||
result += f.table_cell(1,{'style':'background-color:red'})
|
result += f.table_cell(1,{'style':'background-color:red'})
|
||||||
|
@ -267,7 +270,7 @@ def execute(macro, filtre) :
|
||||||
|
|
||||||
# création de la chaine de retour
|
# création de la chaine de retour
|
||||||
code = f.table_cell(0)
|
code = f.table_cell(0)
|
||||||
if s['status'].lower() in ['running','accessible'] :
|
if is_ok(s['status']):
|
||||||
code += f.table_cell(1,{'style':'background-color:lime'})
|
code += f.table_cell(1,{'style':'background-color:lime'})
|
||||||
else :
|
else :
|
||||||
code += f.table_cell(1,{'style':'background-color:red'})
|
code += f.table_cell(1,{'style':'background-color:red'})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue