X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=findbad.py;h=6420f99c1efdafb498c67b68deb47c7193ba31a0;hb=refs%2Fheads%2F1.0;hp=ce41d3034e74b0f918ce5c3c774e9a6f392daa30;hpb=c3f2afdc81c6711c3825c82e2cd4970671575438;p=monitor.git diff --git a/findbad.py b/findbad.py index ce41d30..6420f99 100755 --- a/findbad.py +++ b/findbad.py @@ -5,6 +5,7 @@ import sys import string import time import config +import util.file # QUERY all nodes. @@ -55,6 +56,8 @@ def collectPingAndSSH(nodename, cohash): echo ' "bmlog":"'`ls /tmp/bm.log`'",' echo ' "bootcd":"'`cat /mnt/cdrom/bootme/ID`'",' echo ' "nm":"'`ps ax | grep nm.py | grep -v grep`'",' + echo ' "readonlyfs":"'`touch /var/log/monitor 2>&1 ; touch /vservers/monitor.log 2>&1`'",' + echo ' "dns":"'`host boot.planet-lab.org 2>&1`'",' echo ' "princeton_comon":"'`ls -d /vservers/princeton_comon`'",' ID=`grep princeton_comon /etc/passwd | awk -F : '{if ( $3 > 500 ) { print $3}}'` @@ -69,11 +72,17 @@ EOF """) values['sshport'] = port break else: - values.update({'kernel': "", 'bmlog' : "", 'bootcd' : '', 'nm' : - '', 'princeton_comon' : '', 'princeton_comon_running' : '', - 'princeton_comon_procs' : '', 'sshport' : None}) + values.update({'kernel': "", 'bmlog' : "", 'bootcd' : '', + 'nm' : '', + 'readonlyfs' : '', + 'dns' : '', + 'princeton_comon' : '', + 'princeton_comon_running' : '', + 'princeton_comon_procs' : '', 'sshport' : None}) except: print traceback.print_exc() + from nodecommon import email_exception + email_exception() sys.exit(1) ### RUN SSH ###################### @@ -86,14 +95,14 @@ EOF """) oval = values['kernel'] if "2.6.17" in oval or "2.6.2" in oval: values['ssh'] = 'SSH' - values['category'] = 'ALPHA' + values['category'] = 'PROD' if "bm.log" in values['bmlog']: values['state'] = 'DEBUG' else: values['state'] = 'BOOT' elif "2.6.12" in oval or "2.6.10" in oval: values['ssh'] = 'SSH' - values['category'] = 'PROD' + values['category'] = 'OLDPROD' if "bm.log" in values['bmlog']: values['state'] = 'DEBUG' else: @@ -196,6 +205,8 @@ EOF """) except: b_except = True traceback.print_exc() + from nodecommon import email_exception + email_exception() plc_lock.release() if b_except: return (None, None) @@ -209,7 +220,7 @@ EOF """) values['pcu'] = "NOPCU" site_id = d_node[0]['site_id'] last_contact = d_node[0]['last_contact'] - nodegroups = [ i['name'] for i in api.GetNodeGroups(d_node[0]['nodegroup_ids']) ] + nodegroups = [ i['groupname'] for i in api.GetNodeGroups(d_node[0]['nodegroup_ids']) ] values['plcnode'] = {'status' : 'SUCCESS', 'pcu_ids': pcu, 'boot_state' : d_node[0]['boot_state'], @@ -233,6 +244,8 @@ EOF """) except: b_except = True traceback.print_exc() + from nodecommon import email_exception + email_exception() plc_lock.release() if b_except: return (None, None) @@ -342,13 +355,13 @@ def main(): cohash = cotop.coget(cotop_url) l_nodes = syncplcdb.create_plcdb() if config.nodelist: - f_nodes = config.getListFromFile(config.nodelist) + f_nodes = util.file.getListFromFile(config.nodelist) l_nodes = filter(lambda x: x['hostname'] in f_nodes, l_nodes) elif config.node: f_nodes = [config.node] l_nodes = filter(lambda x: x['hostname'] in f_nodes, l_nodes) elif config.nodegroup: - ng = api.GetNodeGroups({'name' : config.nodegroup}) + ng = api.GetNodeGroups({'groupname' : config.nodegroup}) l_nodes = api.GetNodes(ng[0]['node_ids']) elif config.site: site = api.GetSites(config.site) @@ -359,7 +372,8 @@ def main(): # perform this query after the above options, so that the filter above # does not break. if config.nodeselect: - l_nodes = node_select(config.nodeselect) + fb = database.dbLoad("findbad") + l_nodes = node_select(config.nodeselect, fb['nodes'].keys(), fb) print "fetching %s hosts" % len(l_nodes) @@ -373,7 +387,7 @@ if __name__ == '__main__': parser = parsermodule.getParser(['nodesets']) - parser.set_defaults( increment=False, dbname="findbadnodes", cachenodes=False) + parser.set_defaults( increment=False, dbname="findbad", cachenodes=False) parser.add_option("", "--cachenodes", action="store_true", help="Cache node lookup from PLC") parser.add_option("", "--dbname", dest="dbname", metavar="FILE", @@ -389,6 +403,8 @@ if __name__ == '__main__': main() except Exception, err: print traceback.print_exc() + from nodecommon import email_exception + email_exception() print "Exception: %s" % err print "Saving data... exitting." database.dbDump(config.dbname, externalState)