X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=nodehistory.py;h=6302823f0f9dd58603761463ef08d1da77d65f00;hb=e283978522ef1017ed3591bdbd2aa194a59de5b1;hp=16e48a2401a507de21ad95cc7a73fc4078bc53d1;hpb=d0652340b89d51c6115edb13d5c7c72b34dea66f;p=monitor.git diff --git a/nodehistory.py b/nodehistory.py index 16e48a2..6302823 100755 --- a/nodehistory.py +++ b/nodehistory.py @@ -1,10 +1,9 @@ #!/usr/bin/python import plc -import auth -api = plc.PLC(auth.auth, auth.plc) +api = plc.getAuthAPI() -import soltesz +import database import reboot import time from datetime import datetime, timedelta @@ -12,22 +11,24 @@ import calendar import sys import time -from model import * -from nodecommon import * +from monitor.model import * +from monitor.common import * def get_filefromglob(d, str): import os import glob # TODO: This is aweful. path = "archive-pdb" - archive = soltesz.SPickle(path) + archive = database.SPickle(path) glob_str = "%s*.%s.pkl" % (d.strftime("%Y-%m-%d"), str) os.chdir(path) #print glob_str - file = glob.glob(glob_str)[0] + #file = glob.glob(glob_str)[0] + files = glob.glob(glob_str) #print "loading %s" % file os.chdir("..") - return file[:-4] + files_chng = [ file[:-4] for file in files ] + return files_chng #fb = archive.load(file[:-4]) @@ -44,9 +45,10 @@ def fb_print_nodeinfo(fbnode, verbose, date=None): else: fbnode['bootcd'] = "unknown" fbnode['state'] = color_boot_state(get_current_state(fbnode)) + fbnode['boot_state'] = getvalue(fbnode, 'plcnode/boot_state') if len(fbnode['kernel'].split()) >= 3: fbnode['kernel'] = fbnode['kernel'].split()[2] - print " %(state)5s | %(ssh)5.5s | %(pcu)5.5s | %(bootcd)6.6s | %(category)8.8s | %(kernel)s" % fbnode + print " %(state)5s | %(boot_state)s | %(ssh)5.5s | %(pcu)5.5s | %(bootcd)6.6s | %(category)8.8s | %(kernel)s" % fbnode def pcu_print_info(pcuinfo, hostname): print " Checked: ", @@ -74,10 +76,9 @@ def pcu_print_info(pcuinfo, hostname): (reboot.pcu_name(pcuinfo), pcuinfo['username'], pcuinfo['password']) def main(): - from config import config - from optparse import OptionParser + import parser as parsermodule - parser = OptionParser() + parser = parsermodule.getParser() parser.set_defaults(node=None, fields='state', fromtime=None) parser.add_option("", "--node", dest="node", metavar="nodename.edu", help="A single node name to add to the nodegroup") @@ -85,11 +86,10 @@ def main(): help="Which record field to extract from all files.") parser.add_option("", "--fromtime", dest="fromtime", metavar="YYYY-MM-DD", help="Specify a starting date from which to begin the query.") - config = config(parser) - config.parse_args() + config = parsermodule.parse_args(parser) path = "archive-pdb" - archive = soltesz.SPickle(path) + archive = database.SPickle(path) if config.fromtime: begin = config.fromtime @@ -108,17 +108,19 @@ def main(): verbose = 1 while True: - file = get_filefromglob(d, "production.findbad") - #file = "%s.production.findbad" % d.strftime("%Y-%m-%d") try: - fb = archive.load(file) - if config.node in fb['nodes']: - fb_nodeinfo = fb['nodes'][config.node]['values'] - fb_print_nodeinfo(fb_nodeinfo, verbose, d.strftime("%Y-%m-%d")) + for file in get_filefromglob(d, "production.findbad"): + #file = get_filefromglob(d, "production.findbad") + #file = "%s.production.findbad" % d.strftime("%Y-%m-%d") + fb = archive.load(file) + if config.node in fb['nodes']: + fb_nodeinfo = fb['nodes'][config.node]['values'] + fb_print_nodeinfo(fb_nodeinfo, verbose, d.strftime("%Y-%m-%d")) + + del fb + verbose = 0 - del fb - verbose = 0 except KeyboardInterrupt: sys.exit(1) except: