simplify pcu bad logic
authorStephen Soltesz <soltesz@cs.princeton.edu>
Thu, 25 Jun 2009 23:03:12 +0000 (23:03 +0000)
committerStephen Soltesz <soltesz@cs.princeton.edu>
Thu, 25 Jun 2009 23:03:12 +0000 (23:03 +0000)
ignore additional fields in sitehistory record
just show days down rather than weeks.  weeks is confusing before 30 days

monitor/database/info/history.py
monitor/util/__init__.py
pcubad.py

index 19929a6..ec6f5ac 100644 (file)
@@ -67,7 +67,7 @@ class HistorySiteRecord(Entity):
 
        penalty_level   = Field(Int, default=0)
        penalty_applied = Field(Boolean, default=False)
-       acts_as_versioned(ignore=['last_changed', 'last_checked'])
+       acts_as_versioned(ignore=['last_changed', 'last_checked', 'message_status'])
 
        @classmethod
        def by_loginbase(cls, loginbase):
index 8986f7f..b3268d9 100644 (file)
@@ -26,8 +26,8 @@ def diff_time(timestamp, abstime=True):
                t = diff / (60*60*24)
                t_str = "%s days ago" % int(math.ceil(t))
        elif diff <= 60*60*24*30: # approx sec in month
-               t = diff / (60*60*24*7)
-               t_str = "%s wks ago" % int(math.ceil(t))
+               t = diff / (60*60*24)
+               t_str = "%s days ago" % int(math.ceil(t))
        elif diff > 60*60*24*30: # approx sec in month
                t = diff / (60*60*24*30)
                t_str = "%s mnths ago" % int(t)
index 59dfe7a..33a25be 100755 (executable)
--- a/pcubad.py
+++ b/pcubad.py
@@ -64,17 +64,20 @@ def check_pcu_state(rec, pcu):
 
        pcu_state = rec.reboot_trial_status
 
-       if ( pcu_state == 'NetDown' or pcu_state == 'Not_Run' or not ( pcu_state == 0 or pcu_state == "0" ) ) and \
-                       ( pcu.status == 'online' or pcu.status == 'good' ):
-               print "changed status from %s to offline" % pcu.status
-               pcu.status = 'offline'
-               pcu.last_changed = datetime.now()
-
-       if ( pcu_state == 0 or pcu_state == "0" ) and pcu.status not in [ 'online', 'good' ]:
+       # DOWN
+       if pcu_state not in [0, "0"] and pcu.status not in ['offline', 'down']:
+                       print "changed status from %s to offline" % pcu.status
+                       pcu.status = 'offline'
+                       pcu.last_changed = datetime.now()
+
+       # ONLINE
+       if pcu_state in [0, "0"] and pcu.status not in [ 'online', 'good' ]:
                print "changed status from %s to online" % pcu.status
                pcu.status = 'online'
                pcu.last_changed = datetime.now()
 
+
+       # STATE TRANSITIONS
        if pcu.status == 'online' and changed_greaterthan(pcu.last_changed, 0.5):
                #send thank you notice, or on-line notice.
                print "changed status from %s to good" % pcu.status
@@ -85,12 +88,11 @@ def check_pcu_state(rec, pcu):
                # send down pcu notice
                print "changed status from %s to down" % pcu.status
                pcu.status = 'down'
-               pcu.last_changed = datetime.now()
 
-       if ( pcu.status == 'offline' or pcu.status == 'down' ) and changed_greaterthan(pcu.last_changed, 2*30):
-               print "changed status from %s to down" % pcu.status
-               pcu.status = 'down'
-               pcu.last_changed = datetime.now()
+#      if pcu.status in [ 'offline', 'down' ] and changed_greaterthan(pcu.last_changed, 2*30):
+#              print "changed status from %s to down" % pcu.status
+#              pcu.status = 'down'
+#              pcu.last_changed = datetime.now()
 
 def checkAndRecordState(l_pcus, l_plcpcus):
        count = 0