From 8ed0efd101dc969d4d0218829a3c0f689607f0e2 Mon Sep 17 00:00:00 2001 From: Stephen Soltesz Date: Tue, 11 Dec 2007 22:49:15 +0000 Subject: [PATCH] Added a variety of filters to limit the nodes displayed. Also, added a 'nodesonly' option --- www/printbadnodes.py | 75 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 65 insertions(+), 10 deletions(-) diff --git a/www/printbadnodes.py b/www/printbadnodes.py index 2f86db7..0c94595 100755 --- a/www/printbadnodes.py +++ b/www/printbadnodes.py @@ -210,7 +210,7 @@ def fields_to_html(fields, vals): -def main(sitefilter): +def main(sitefilter, catfilter, statefilter, comonfilter, nodeonlyfilter): db = soltesz.dbLoad(config.dbname) ## Field widths used for printing @@ -318,12 +318,38 @@ def main(sitefilter): d2.sort(cmp=cmpCategory) + if catfilter != None: cf = re.compile(catfilter) + else: cf = None + + if statefilter != None: stf = re.compile(statefilter) + else: stf = None + + if comonfilter != None: cmf = re.compile(comonfilter) + else: cmf = None + #l_loginbase = bysite.keys() #l_loginbase.sort() - print "" + if nodeonlyfilter == None: + print "
" + prev_sitestring = "" for row in d2: + vals = row + + if (catfilter != None and cf.match(vals['category']) == None): + continue + + if (statefilter != None and stf.match(vals['state']) == None): + continue + + if (comonfilter != None and comonfilter in vals['comonstats'] and vals['comonstats'][comonfilter] != 'null'): + continue + + if nodeonlyfilter != None: + print vals['nodename'] + continue + site_string = row['site_string'] if site_string != prev_sitestring: print "" - print "
" @@ -334,7 +360,7 @@ def main(sitefilter): prev_sitestring = site_string - vals = row + # convert uname values into a single kernel version string if 'kernel' in vals: kernel = vals['kernel'].split() @@ -372,6 +398,10 @@ def main(sitefilter): vals['reboot'] = "%s" % vals['reboot'] vals['reboot'] = vals['reboot'].replace(" ", "_") + if 'nodename' in vals: + url = "%s" % (vals['nodename'], vals['nodename']) + vals['nodename'] = url + try: str_fields = [] count = 0 @@ -386,8 +416,9 @@ def main(sitefilter): print "\n
" - print "" + if nodeonlyfilter == None: + print "
" + print "" keys = categories.keys() keys.sort() for cat in keys: @@ -395,7 +426,8 @@ def main(sitefilter): print "" % cat print "" % categories[cat] print "" - print "
Total %s%s
" + if nodeonlyfilter == None: + print "" @@ -412,10 +444,31 @@ if __name__ == '__main__': myfilter = form.getvalue("site") else: myfilter = None + + if form.has_key('category'): + mycategory = form.getvalue("category") + else: + mycategory = None + + if form.has_key('state'): + mystate = form.getvalue("state") + else: + mystate = None + + if form.has_key('comon'): + mycomon = form.getvalue("comon") + else: + mycomon = None + + if form.has_key('nodeonly'): + mynodeonly = form.getvalue("nodeonly") + else: + mynodeonly = None + parser = OptionParser() parser.set_defaults(cmpdays=False, comon="sshstatus", - fields="nodename,ping,ssh,pcu,category,state,kernel,bootcd", + fields="nodename,ping,ssh,pcu,category,state,comonstats,kernel,bootcd", dbname="findbad", # -070724-1", cmpping=False, cmpdns=False, @@ -437,9 +490,11 @@ if __name__ == '__main__': config = config(parser) config.parse_args() print "Content-Type: text/html\r\n" - print "\n" + if mynodeonly == None: + print "\n" if len(sys.argv) > 1: if sys.argv[1] == "ssherror": ssherror = True - main(myfilter) - print "\n" + main(myfilter, mycategory, mystate, mycomon,mynodeonly) + if mynodeonly == None: + print "\n" -- 2.45.2