From: Stephen Soltesz Date: Mon, 4 Aug 2008 21:56:36 +0000 (+0000) Subject: show days up to 14, display time up or down in nodegroup_dislplay X-Git-Tag: Monitor-1.0-6~11 X-Git-Url: http://git.onelab.eu/?p=monitor.git;a=commitdiff_plain;h=4b1825d8577cfd0266d8c4ac2254a96407e06112 show days up to 14, display time up or down in nodegroup_dislplay --- diff --git a/nodecommon.py b/nodecommon.py index 9469b81..40c892a 100644 --- a/nodecommon.py +++ b/nodecommon.py @@ -1,6 +1,7 @@ import struct import reboot +from unified_model import PersistFlags esc = struct.pack('i', 27) RED = esc + "[1;31m" GREEN = esc + "[1;32m" @@ -90,7 +91,7 @@ def diff_time(timestamp): elif diff < 60*60*24: # sec in day t = diff / (60*60) t_str = "%s hrs ago" % int(math.ceil(t)) - elif diff < 60*60*24*7: # sec in week + elif diff < 60*60*24*14: # sec in week t = diff / (60*60*24) t_str = "%s days ago" % int(math.ceil(t)) elif diff <= 60*60*24*30: # approx sec in month @@ -124,8 +125,10 @@ def nodegroup_display(node, fb, conf=None): #node['current'] = node['current'] node['pcu'] = fb['nodes'][node['hostname']]['values']['pcu'] node['lastupdate'] = diff_time(node['last_contact']) + pf = PersistFlags(node['hostname'], 1, db='node_persistflags') + node['lc'] = diff_time(pf.last_changed) - return "%(hostname)-42s %(boot_state)8s %(current)5s %(pcu)6s %(key)20.20s... %(kernel)43s %(lastupdate)12s " % node + return "%(hostname)-42s %(boot_state)8s %(current)5s %(pcu)6s %(key)10.10s... %(kernel)33s %(lastupdate)12s, %(lc)s" % node from model import * import database