X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=www%2Fprintbadnodes.py;h=0c94595f40b83fd6cada5f8c69a860323f05205f;hb=7fb16f5280e051758cfe5de4bf034f4be3f275a3;hp=671a9c6ac11592f2fafce515df06252c9a39cfdf;hpb=b85bdef86b694aefe529ac870f756a3291f96ad2;p=monitor.git diff --git a/www/printbadnodes.py b/www/printbadnodes.py index 671a9c6..0c94595 100755 --- a/www/printbadnodes.py +++ b/www/printbadnodes.py @@ -63,7 +63,7 @@ def cmpState(l1, l2): return cmpMap(l1,l2,'state', map) def cmpCategoryVal(v1, v2): - map = array_to_priority_map([ None, 'ALPHA', 'PROD', 'OLDBOOTCD', 'UNKNOWN', 'ERROR', ]) + map = array_to_priority_map([ None, 'ALPHA', 'PROD', 'OLDBOOTCD', 'UNKNOWN', 'FORCED', 'ERROR', ]) return cmpValMap(v1,v2,map) def cmpCategory(l1, l2): @@ -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 @@ -258,6 +258,11 @@ def main(sitefilter): # d2 was an array of [{node}, {}, ...] # the bysite is a loginbase dict of [{node}, {node}] d2 = [] + import re + if sitefilter != None: + sf = re.compile(sitefilter) + else: + sf = None for nodename in l_nodes: vals=d_n[nodename]['values'] v = {} @@ -283,7 +288,7 @@ def main(sitefilter): v['site_string'] = site_string v['loginbase'] = loginbase - if (sitefilter != None and loginbase == sitefilter) or sitefilter == None: + if (sitefilter != None and sf.match(loginbase) != None) or sitefilter == None: d2.append(v) @@ -313,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 "
" @@ -329,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() @@ -367,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 @@ -381,8 +416,9 @@ def main(sitefilter): print "\n
" - print "" + if nodeonlyfilter == None: + print "
" + print "" keys = categories.keys() keys.sort() for cat in keys: @@ -390,27 +426,49 @@ def main(sitefilter): print "" % cat print "" % categories[cat] print "" - print "
Total %s%s
" + if nodeonlyfilter == None: + print "" -import cgi -import cgitb; -cgitb.enable() -import sys -form = cgi.FieldStorage() -myfilter = None -if form.has_key('site'): - myfilter = form.getvalue("site") -else: +if __name__ == '__main__': + import cgi + import cgitb; + cgitb.enable() + import sys + + form = cgi.FieldStorage() myfilter = None + if form.has_key('site'): + 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 -if __name__ == '__main__': 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, @@ -432,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"