"
# look for hosts and services status
for i, val in enumerate(cfg):
if i % 2 == 0:
print "
"
else:
print "
"
print "
\
%s
" % val
totalOK = totalNOK = 0
for idx, v in enumerate(cfg[val]['members']):
# reset file cursor
self.infile.seek(0)
style = target = ''
if v.find(':') == -1:
status = self.find_host_status(v.strip())
if status != '4':
target = "%s" \
% (v.strip(), v.strip())
else:
target = v.strip()
style = hStatus[int(status)]
if status != '0':
totalNOK += 1
else:
totalOK += 1
else:
status = self.find_service_status(v.split(':')[0].strip(),
v.split(':')[1].strip())
if status != '5':
target = "%s" \
% (v.split(':')[0].strip(), v.split(':')[1].strip(),
v.split(':')[1].strip())
else:
target = v.strip()
style = sStatus[int(status)]
if status != '0':
totalNOK += 1
else:
totalOK += 1
if idx % 4 == 0:
print "
%s
" % (style, target)
else:
print "
%s
" % (style, target)
# do we have subgroups?
if len(cfg[val].keys()) > 1:
for idxj, j in enumerate(cfg[val].keys()[1:]):
# reset number of failed members
num_failed = 0
# special flag is unknown member found
# probably mistyped in configuration
# mark whole subgroup as white if one unknown found
num_unknown = 0
# to which service group this belongs?
group = cfg[val][j]['group'].strip()
# loop thru members in subgroup
for idx, k in enumerate(cfg[val][j]['members']):
self.infile.seek(0)
style = target = ''
# is it host?
if k.find(':') == -1:
status = self.find_host_status(k.strip())
if status != '0':
if status == '4':
num_unknown += 1
num_failed += 1
else:
status = self.find_service_status(k.split(':')[0].strip(),
k.split(':')[1].strip())
if status != '0':
if status == '5':
num_unknown += 1
num_failed += 1
if num_failed > 0:
totalNOK += 1
# did they all failed?
if len(cfg[val][j]['members']) == num_failed:
style = sStatus[2] # critical status
else:
style = sStatus[1] # warning status
# was there any unknown member?
if num_unknown > 0:
style = sStatus[5] # give white color
else:
totalOK += 1
style = sStatus[0]
if idxj % 4 == 0:
print "