git://git.onelab.eu
/
monitor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
merge from improvements on the 1.0 branch:
[monitor.git]
/
nodeinfo.py
diff --git
a/nodeinfo.py
b/nodeinfo.py
index
fc27781
..
9afed5c
100755
(executable)
--- a/
nodeinfo.py
+++ b/
nodeinfo.py
@@
-1,18
+1,19
@@
#!/usr/bin/python
#!/usr/bin/python
-import plc
+
from monitor.wrapper
import plc
api = plc.getAuthAPI()
api = plc.getAuthAPI()
-import database
-import reboot
+from monitor import *
+from monitor import util
+from monitor import parser as parsermodule
-import time
-from model import *
-from nodecommon import *
-
-import util.file
+from monitor import database
+from pcucontrol import reboot
-import parser as parsermodule
+import time
+from monitor.model import *
+from monitor.common import *
+#from monitor.model import node_end_record, PersistFlags
parser = parsermodule.getParser()
parser.set_defaults(node=None,
parser = parsermodule.getParser()
parser.set_defaults(node=None,
@@
-43,12
+44,17
@@
def plc_print_nodeinfo(plcnode):
diff_time(plcnode['last_contact']), plcnode['key'])
def fb_print_nodeinfo(fbnode):
diff_time(plcnode['last_contact']), plcnode['key'])
def fb_print_nodeinfo(fbnode):
+ pf = PersistFlags(fbnode['hostname'], 1, db='node_persistflags')
+ try:
+ fbnode['last_change'] = diff_time(pf.last_changed)
+ except:
+ fbnode['last_change'] = diff_time(time.time())
print " Checked: ",
if 'checked' in fbnode:
print "%11.11s " % diff_time(fbnode['checked'])
else:
print "Unknown"
print " Checked: ",
if 'checked' in fbnode:
print "%11.11s " % diff_time(fbnode['checked'])
else:
print "Unknown"
- print "\t state | ssh | pcu | bootcd | category | kernel"
+ print "\t state | ssh | pcu | bootcd | category |
last change |
kernel"
if fbnode['bootcd']:
fbnode['bootcd'] = fbnode['bootcd'].split()[-1]
else:
if fbnode['bootcd']:
fbnode['bootcd'] = fbnode['bootcd'].split()[-1]
else:
@@
-59,7
+65,7
@@
def fb_print_nodeinfo(fbnode):
fbnode['state'] = "none"
if len(fbnode['kernel'].split()) > 2:
fbnode['kernel'] = fbnode['kernel'].split()[2]
fbnode['state'] = "none"
if len(fbnode['kernel'].split()) > 2:
fbnode['kernel'] = fbnode['kernel'].split()[2]
- print "\t %(state)5s | %(ssh)5.5s | %(pcu)5.5s | %(bootcd)6.6s | %(category)8.8s | %(kernel)s" % fbnode
+ print "\t %(state)5s | %(ssh)5.5s | %(pcu)5.5s | %(bootcd)6.6s | %(category)8.8s | %(
last_change)11s | %(
kernel)s" % fbnode
def act_print_nodeinfo(actnode, header):
if header[0]:
def act_print_nodeinfo(actnode, header):
if header[0]:
@@
-72,8
+78,7
@@
def act_print_nodeinfo(actnode, header):
if 'rt' in actnode and 'Status' in actnode['rt']:
print "\t %5.5s %5.5s | %8.8s | %15.15s | %s" % \
(actnode['rt']['Status'], actnode['rt']['id'][7:],
if 'rt' in actnode and 'Status' in actnode['rt']:
print "\t %5.5s %5.5s | %8.8s | %15.15s | %s" % \
(actnode['rt']['Status'], actnode['rt']['id'][7:],
- actnode['category'], actnode['action'][0],
- actnode['msg_format'][:-1])
+ actnode['category'], actnode['action'][0], actnode['info'][1:])
else:
if type(actnode['action']) == type([]):
action = actnode['action'][0]
else:
if type(actnode['action']) == type([]):
action = actnode['action'][0]
@@
-132,22
+137,25
@@
if config.findbad:
util.file.setFileFromList(file, config.args)
os.system("./findbad.py --cachenodes --debug=0 --dbname=findbad --increment --nodelist %s" % file)
util.file.setFileFromList(file, config.args)
os.system("./findbad.py --cachenodes --debug=0 --dbname=findbad --increment --nodelist %s" % file)
-fb = database.dbLoad("findbad")
-act_all = database.dbLoad("act_all")
-
for node in config.args:
config.node = node
plc_nodeinfo = api.GetNodes({'hostname': config.node}, None)[0]
for node in config.args:
config.node = node
plc_nodeinfo = api.GetNodes({'hostname': config.node}, None)[0]
- fb_node
info = fb['nodes'][config.node]['values']
-
+ fb_node
rec = FindbadNodeRecord.get_latest_by(hostname=node)
+ fb_nodeinfo = fb_noderec.to_dict()
plc_print_nodeinfo(plc_nodeinfo)
plc_print_nodeinfo(plc_nodeinfo)
+
+ fb_nodeinfo['hostname'] = node
fb_print_nodeinfo(fb_nodeinfo)
if fb_nodeinfo['pcu'] == "PCU":
pcu = reboot.get_pcu_values(fb_nodeinfo['plcnode']['pcu_ids'][0])
fb_print_nodeinfo(fb_nodeinfo)
if fb_nodeinfo['pcu'] == "PCU":
pcu = reboot.get_pcu_values(fb_nodeinfo['plcnode']['pcu_ids'][0])
- pcu_print_info(pcu, config.node)
+
if pcu:
pcu_print_info(pcu, config.node)
+ try:
+ act_all = database.dbLoad("act_all")
+ except:
+ act_all = {}
if config.node in act_all and len(act_all[config.node]) > 0:
header = [True]
if config.node in act_all and len(act_all[config.node]) > 0:
header = [True]