From da396372eea1cedd0a7bd97eca66e12faa6bb984 Mon Sep 17 00:00:00 2001 From: Stephen Soltesz Date: Wed, 9 Apr 2008 17:17:59 +0000 Subject: [PATCH] - add reporting of pcu state --- www/printbadnodes.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/www/printbadnodes.py b/www/printbadnodes.py index 0c94595..9d5e6b3 100755 --- a/www/printbadnodes.py +++ b/www/printbadnodes.py @@ -3,11 +3,14 @@ import soltesz from config import config from optparse import OptionParser import string +from HyperText.HTML import A, BR, IMG, TABLE, TR, TH, TD, EM, quote_body +from HyperText.Documents import Document import sys categories = {} ssherror = False +fb = {} def sec2days(sec): if sec == "null": @@ -144,9 +147,32 @@ def ssh_error_to_str(str): return ssh_error +def pcu_state(pcu_id): + global fb + + if 'nodes' in fb and "id_%s" % pcu_id in fb['nodes'] \ + and 'values' in fb['nodes']["id_%s" % pcu_id]: + rec = fb['nodes']["id_%s" % pcu_id]['values'] + if 'reboot' in rec: + rb = rec['reboot'] + if rb == 0 or rb == "0": + return 0 + elif "NetDown" == rb or "Not_Run" == rb: + return 1 + else: + return -1 + else: + return -1 + else: + return -1 + def fields_to_html(fields, vals): global categories global ssherror + pcu_colorMap = { -1 : 'indianred', + 0 : 'darkseagreen', + 1 : 'gold', } + colorMap = { 'PING' : 'darkseagreen', 'NOPING': 'darksalmon', 'SSH': 'darkseagreen', @@ -199,6 +225,10 @@ def fields_to_html(fields, vals): r_str += "%s" % (bgcolor, f) elif f == 'PCU': if len(vals['plcnode']['pcu_ids']) > 0: + #print "pcu_id: %s
" % vals['plcnode']['pcu_ids'][0] + #print "state: %s
" % pcu_state(vals['plcnode']['pcu_ids'][0]) + #print "color: %s
" % pcu_colorMap[pcu_state(vals['plcnode']['pcu_ids'][0])] + bgcolor = "bgcolor='%s'" % pcu_colorMap[pcu_state(vals['plcnode']['pcu_ids'][0])] url = "PCU" % vals['plcnode']['pcu_ids'][0] r_str += "%s" % (bgcolor, url) else: @@ -211,7 +241,10 @@ def fields_to_html(fields, vals): def main(sitefilter, catfilter, statefilter, comonfilter, nodeonlyfilter): + global fb + db = soltesz.dbLoad(config.dbname) + fb = soltesz.dbLoad("findbadpcus") ## Field widths used for printing maxFieldLengths = { 'nodename' : -45, -- 2.47.0