changes for 3.0
[monitor.git] / findbad.py
index 2aabe01..6420f99 100755 (executable)
@@ -56,7 +56,7 @@ 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`'",'
+                               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`'",'
 
@@ -81,6 +81,8 @@ EOF                   """)
                                                                'princeton_comon_procs' : '', 'sshport' : None})
        except:
                print traceback.print_exc()
+               from nodecommon import email_exception
+               email_exception()
                sys.exit(1)
 
        ### RUN SSH ######################
@@ -203,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)
@@ -216,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'],
@@ -240,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)
@@ -355,7 +361,7 @@ def main():
                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)
@@ -397,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)