(no commit message)
[monitor.git] / sitebad.py
index cf5ab4e..6c09c1c 100755 (executable)
@@ -44,6 +44,8 @@ def getnodesup(nodelist):
        up = 0
        for node in nodelist:
                try:
+                       # NOTE: adding a condition for nodehist.haspcu would include pcus
+                       #               in the calculation
                        nodehist = HistoryNodeRecord.findby_or_create(hostname=node['hostname'])
                        nodebl   = BlacklistRecord.get_by(hostname=node['hostname'])
                        if (nodehist is not None and nodehist.status != 'down') or \
@@ -51,6 +53,7 @@ def getnodesup(nodelist):
                                up = up + 1
                except:
                        import traceback
+                       email_exception(node['hostname'])
                        print traceback.print_exc()
        return up
 
@@ -74,7 +77,7 @@ def check_site_state(rec, sitehist):
                        print "changed status from %s to good" % sitehist.status
                        sitehist.status = 'good'
 
-       if not sitehist.new:
+       elif not sitehist.new:
        
                if sitehist.status != 'offline' and sitehist.status != 'down':
                        sitehist.last_changed = datetime.now()