From: Stephen Soltesz <soltesz@cs.princeton.edu>
Date: Thu, 3 Dec 2009 02:45:58 +0000 (+0000)
Subject: reformat time install_date to timestamp when returned by advanced query
X-Git-Tag: Monitor-3.0-26~9
X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=0ab12188e17261dd130208731b65f5f042969659;p=monitor.git

reformat time install_date to timestamp when returned by advanced query
1/3 of online nodes in PLC did not have the /usr/boot/plnode.txt file, so add
a secondary check to install_date to check for another file in /usr/boot/
---

diff --git a/monitor/scanapi.py b/monitor/scanapi.py
index 16e1fd2..88bd513 100644
--- a/monitor/scanapi.py
+++ b/monitor/scanapi.py
@@ -236,9 +236,9 @@ class ScanNodeInternal(ScanInterface):
 					echo "{"
 					echo '  "kernel_version":"'`uname -a`'",'
 					echo '  "bmlog":"'`ls /tmp/bm.log`'",'
-					echo '  "bootcd_version":"'`cat /mnt/cdrom/bootme/ID`'",'
+					echo '  "bootcd_version":"'`cat /mnt/cdrom/bootme/ID || cat /usr/bootme/ID`'",'
 					echo '  "boot_server":"'`cat /mnt/cdrom/bootme/BOOTSERVER`'",'
-					echo '  "install_date":"'`python -c "import os,time,stat; print time.ctime(os.stat('/usr/boot/plnode.txt')[stat.ST_CTIME])"`'",'
+					echo '  "install_date":"'`python -c "import os,time,stat; print time.ctime(os.stat('/usr/boot/plnode.txt')[stat.ST_CTIME])" || python -c "import os,time,stat; print  time.ctime(os.stat('/usr/boot/cacert.pem')[stat.ST_CTIME])"`'",'
 					echo '  "nm_status":"'`ps ax | grep nm.py | grep -v grep`'",'
 					echo '  "dns_status":"'`host boot.planet-lab.org 2>&1`'",'
 					echo '  "iptables_status":"'`iptables -t mangle -nL | awk '$1~/^[A-Z]+$/ {modules[$1]=1;}END{for (k in modules) {if (k) printf "%s ",k;}}'`'",'
diff --git a/web/MonitorWeb/monitorweb/controllers.py b/web/MonitorWeb/monitorweb/controllers.py
index 74b2770..3d68fe6 100644
--- a/web/MonitorWeb/monitorweb/controllers.py
+++ b/web/MonitorWeb/monitorweb/controllers.py
@@ -53,8 +53,8 @@ class NodeQueryFields(widgets.WidgetsList):
 	external_dns_status = widgets.CheckBox(label="Hostname Resolves?")
 	kernel_version = widgets.CheckBox(label="Kernel")
 	bootcd_version = widgets.CheckBox(label="BootCD")
-        boot_server = widgets.CheckBox(label="Boot Server")
-        install_date = widgets.CheckBox(label="Installation Date")
+	boot_server = widgets.CheckBox(label="Boot Server")
+	install_date = widgets.CheckBox(label="Installation Date")
 	observed_status = widgets.CheckBox(label="Observed Status")
 	uptime = widgets.CheckBox(label="Uptime")
 	traceroute = widgets.CheckBox(label="Traceroute")
@@ -341,6 +341,8 @@ class Root(controllers.RootController, MonitorXmlrpcServer):
 				else:
 					agg = node.to_dict()
 				agg.update(agg['plc_node_stats'])
+				if agg['install_date']:
+					agg['install_date'] = time.mktime(time.strptime(agg['install_date'], "%a %b %d %H:%M:%S %Y"))
 				if agg['kernel_version']:
 					agg['kernel_version'] = agg['kernel_version'].split()[2]
 				if 'traceroute' in data and agg['traceroute']: