import vxargs
from monitor import parser as parsermodule
+from monitor import common
from automate import *
def build_vx_args(shell_cmd):
if not os.path.exists(outdir):
os.system('mkdir -p %s' % outdir)
- if config.site is not None or \
- config.nodeselect is not None or \
- config.nodegroup is not None:
- print "TODO: implement support for nodeselect and site queries."
- print "%s %s %s" % (config.site, config.nodeselect, config.nodegroup)
- sys.exit(1)
+ #if config.site is not None or \
+ # config.nodeselect is not None or \
+ # config.nodegroup is not None:
+ # print "TODO: implement support for nodeselect and site queries."
+ # print "%s %s %s" % (config.site, config.nodeselect, config.nodegroup)
+ # sys.exit(1)
- if config.nodelist == None and config.node == None:
- filelist="nocomon.txt"
- filelist = vxargs.getListFromFile(open(filelist,'r'))
+ nodelist = common.get_nodeset(config)
+
+ if len(nodelist) > 0:
+ filelist = [ (x, '') for x in nodelist ]
elif os.path.exists(str(config.nodelist)) and os.path.isfile(config.nodelist):
filelist = vxargs.getListFromFile(open(config.nodelist,'r'))
elif os.path.exists(str(config.nodelist)) and os.path.isdir(config.nodelist):
rsync -qv -az -e ssh root@janine.cs.princeton.edu:/vservers/boot-current/var/log/*-filesystem* /var/lib/monitor/filesystem
rsync -qv -az -e ssh root@janine.cs.princeton.edu:/vservers/boot-current/var/log/*-checkrpm* /var/lib/monitor/checkrpm
+rsync -qv -az -e ssh root@janine.cs.princeton.edu:/vservers/boot-current/var/log/bm/ /var/lib/monitor/bmlogs/
from monitor.wrapper import plc, plccache
from monitor.scanapi import *
-from nodequery import verify,query_to_dict,node_select
+from monitor.query import verify,query_to_dict,node_select
import traceback
from monitor.common import nmap_port_status
action_type=logtype,
log_path=short_log_path,
error_string=err)
- session.flush(); session.clear()
return
def get_bootmanager_log(self):
bm_name = bootmanager_log_name(self.node)
download(self.c, "/tmp/bm.log", "%s/%s" % (config.MONITOR_BOOTMANAGER_LOG, bm_name))
+ #email_exception(self.node, "collected BM log for %s" % self.node)
bootmanager_log_action(self.node, bm_name, "collected_bm.log")
os.system("cp %s/%s %s/bm.%s.log" % (config.MONITOR_BOOTMANAGER_LOG, bm_name, config.MONITOR_BOOTMANAGER_LOG, self.node))
log = open("%s/bm.%s.log" % (config.MONITOR_BOOTMANAGER_LOG, self.node), 'r')
return log
-
-# def get_dmesg(self):
-# self.c.modules.os.system("dmesg > /var/log/dmesg.bm.log")
-# download(self.c, "/var/log/dmesg.bm.log", "log/dmesg.%s.log" % self.node)
-# log = open("log/dmesg.%s.log" % self.node, 'r')
-# return log
-#
-# def get_bootmanager_log(self):
-# download(self.c, "/tmp/bm.log", "log/bm.%s.log.gz" % self.node)
-# #os.system("zcat log/bm.%s.log.gz > log/bm.%s.log" % (self.node, self.node))
-# os.system("cp log/bm.%s.log.gz log/bm.%s.log" % (self.node, self.node))
-# log = open("log/bm.%s.log" % self.node, 'r')
-# return log
-
def dump_plconf_file(self):
c = self.c
self.c.modules.sys.path.append("/tmp/source/")
print "...Downloading bm.log from %s" %hostname
log = conn.get_bootmanager_log()
+ bm_log_data = log.read() # get data
+ log.seek(0) # reset fd pointer for fdspawn
child = fdpexpect.fdspawn(log)
if hasattr(config, 'collect') and config.collect: return "collect"
args = {}
args['hostname'] = hostname
args['sequence'] = s
- args['bmlog'] = conn.get_bootmanager_log().read()
+ args['bmlog'] = bm_log_data
args['viart'] = False
args['saveact'] = True
args['ccemail'] = True
args = {}
args['hostname'] = hostname
args['sequence'] = s
- args['bmlog'] = conn.get_bootmanager_log().read()
+ args['bmlog'] = bm_log_data
args['viart'] = False
args['saveact'] = True
args['ccemail'] = True
if not found_within(recent_actions, 'nodeconfig_notice', 3.5):
args = {}
args['hostname'] = hostname
- args['bmlog'] = conn.get_bootmanager_log().read()
+ args['bmlog'] = bm_log_data
sitehist.sendMessage('nodeconfig_notice', **args)
conn.dump_plconf_file()
else:
print "...NOTIFYING OWNERS OF MINIMAL HARDWARE FAILURE on %s!!!" % hostname
args = {}
args['hostname'] = hostname
- args['bmlog'] = conn.get_bootmanager_log().read()
+ args['bmlog'] = bm_log_data
sitehist.sendMessage('minimalhardware_notice', **args)
else:
# NOTE: do not add a new action record
import struct
from monitor import reboot
from monitor import util
+from monitor import query
from monitor.wrapper import plc
from datetime import datetime, timedelta
# perform this query after the above options, so that the filter above
# does not break.
if config.nodeselect:
- fbquery = FindbadNodeRecord.get_all_latest()
+ fbquery = HistoryNodeRecord.query.all()
node_list = [ n.hostname for n in fbquery ]
- l_nodes = node_select(config.nodeselect, node_list, None)
+ l_nodes = query.node_select(config.nodeselect, node_list, None)
return l_nodes
bootcd_version = Field(String,default=None)
nm_status = Field(String,default=None)
fs_status = Field(String,default=None)
+ iptables_status = Field(String,default=None)
dns_status = Field(String,default=None)
external_dns_status = Field(Boolean,default=True)
uptime = Field(String,default=None)
--- /dev/null
+#!/usr/bin/python
+
+import os
+import re
+import sys
+import glob
+import time
+import string
+import traceback
+
+from monitor.common import *
+from monitor.database.info.model import FindbadNodeRecord, FindbadPCURecord
+
+class NoKeyException(Exception): pass
+
+def first(path):
+ indexes = path.split(".")
+ return indexes[0]
+
+def get(fb, path):
+ indexes = path.split(".")
+ values = fb
+ for index in indexes:
+ if values and index in values:
+ values = values[index]
+ elif values == {}:
+ values = ""
+ else:
+ print values, index
+ raise NoKeyException(index)
+ return values
+
+def verifyType(constraints, data):
+ """
+ constraints is a list of key, value pairs.
+ # [ {... : ...}==AND , ... , ... , ] == OR
+ """
+ con_or_true = False
+ for con in constraints:
+ #print "con: %s" % con
+ if len(con.keys()) == 0:
+ con_and_true = False
+ else:
+ con_and_true = True
+
+ for key in con.keys():
+ #print "looking at key: %s" % key
+ if data is None:
+ con_and_true = False
+ break
+
+ try:
+ get(data,key)
+ o = con[key]
+ if o.name() == "Match":
+ if get(data,key) is not None:
+ value_re = re.compile(o.value)
+ con_and_true = con_and_true & (value_re.search(get(data,key)) is not None)
+ else:
+ con_and_true = False
+ elif o.name() == "ListMatch":
+ if get(data,key) is not None:
+ match = False
+ for listitem in get(data,key):
+ value_re = re.compile(o.value)
+ if value_re.search(listitem) is not None:
+ match = True
+ break
+ con_and_true = con_and_true & match
+ else:
+ con_and_true = False
+ elif o.name() == "Is":
+ con_and_true = con_and_true & (get(data,key) == o.value)
+ elif o.name() == "FilledIn":
+ con_and_true = con_and_true & (len(get(data,key)) > 0)
+ elif o.name() == "PortOpen":
+ if get(data,key) is not None:
+ v = get(data,key)
+ con_and_true = con_and_true & (v[str(o.value)] == "open")
+ else:
+ con_and_true = False
+ else:
+ value_re = re.compile(o.value)
+ con_and_true = con_and_true & (value_re.search(get(data,key)) is not None)
+
+ except NoKeyException, key:
+ print "missing key %s" % key,
+ pass
+ #print "missing key %s" % key
+ #con_and_true = False
+
+ con_or_true = con_or_true | con_and_true
+
+ return con_or_true
+
+def verifyDBrecord(constraints, record):
+ """
+ constraints is a list of key, value pairs.
+ # [ {... : ...}==AND , ... , ... , ] == OR
+ """
+ def has_key(obj, key):
+ try:
+ x = obj.__getattribute__(key)
+ return True
+ except:
+ return False
+
+ def get_val(obj, key):
+ try:
+ return obj.__getattribute__(key)
+ except:
+ return None
+
+ def get(obj, path):
+ indexes = path.split("/")
+ value = get_val(obj,indexes[0])
+ if value is not None and len(indexes) > 1:
+ for key in indexes[1:]:
+ if key in value:
+ value = value[key]
+ else:
+ raise NoKeyException(key)
+ return value
+
+ #print constraints, record
+
+ con_or_true = False
+ for con in constraints:
+ #print "con: %s" % con
+ if len(con.keys()) == 0:
+ con_and_true = False
+ else:
+ con_and_true = True
+
+ for key in con.keys():
+ #print "looking at key: %s" % key
+ if has_key(record, key):
+ value_re = re.compile(con[key])
+ if type([]) == type(get(record,key)):
+ local_or_true = False
+ for val in get(record,key):
+ local_or_true = local_or_true | (value_re.search(val) is not None)
+ con_and_true = con_and_true & local_or_true
+ else:
+ if get(record,key) is not None:
+ con_and_true = con_and_true & (value_re.search(get(record,key)) is not None)
+ else:
+ print "missing key %s" % key,
+ pass
+
+ con_or_true = con_or_true | con_and_true
+
+ return con_or_true
+
+def verify(constraints, data):
+ """
+ constraints is a list of key, value pairs.
+ # [ {... : ...}==AND , ... , ... , ] == OR
+ """
+ con_or_true = False
+ for con in constraints:
+ #print "con: %s" % con
+ if len(con.keys()) == 0:
+ con_and_true = False
+ else:
+ con_and_true = True
+
+ for key in con.keys():
+ #print "looking at key: %s" % key
+ if first(key) in data:
+ value_re = re.compile(con[key])
+ if type([]) == type(get(data,key)):
+ local_or_true = False
+ for val in get(data,key):
+ local_or_true = local_or_true | (value_re.search(val) is not None)
+ con_and_true = con_and_true & local_or_true
+ else:
+ if get(data,key) is not None:
+ con_and_true = con_and_true & (value_re.search(get(data,key)) is not None)
+ elif first(key) not in data:
+ print "missing key %s" % first(key)
+
+ con_or_true = con_or_true | con_and_true
+
+ return con_or_true
+
+def query_to_dict(query):
+
+ ad = []
+
+ or_queries = query.split('||')
+ for or_query in or_queries:
+ and_queries = or_query.split('&&')
+
+ d = {}
+
+ for and_query in and_queries:
+ (key, value) = and_query.split('=')
+ d[key] = value
+
+ ad.append(d)
+
+ return ad
+
+def pcu_in(fbdata):
+ #if 'plcnode' in fbdata:
+ if 'plc_node_stats' in fbdata:
+ if fbdata['plc_node_stats'] and 'pcu_ids' in fbdata['plc_node_stats']:
+ if len(fbdata['plc_node_stats']['pcu_ids']) > 0:
+ return True
+ return False
+
+def pcu_select(str_query, nodelist=None):
+ pcunames = []
+ nodenames = []
+ if str_query is None: return (nodenames, pcunames)
+
+ if True:
+ fbquery = FindbadNodeRecord.get_all_latest()
+ fb_nodelist = [ n.hostname for n in fbquery ]
+ if True:
+ # NOTE: this doesn't work when there are only a few records current.
+ # pcu_select should apply to all pcus globally, not just the most recent records.
+ fbpcuquery = FindbadPCURecord.get_all_latest()
+ fbpcu_list = [ p.plc_pcuid for p in fbpcuquery ]
+
+ dict_query = query_to_dict(str_query)
+ print "dict_query", dict_query
+ print 'length %s' % len(fbpcuquery)
+
+ #for pcurec in fbpcuquery:
+ # pcuinfo = pcurec.to_dict()
+ # if verify(dict_query, pcuinfo):
+ # #nodenames.append(noderec.hostname)
+ # #print 'appending %s' % pcuinfo['plc_pcuid']
+ # pcunames.append(pcuinfo['plc_pcuid'])
+
+ for noderec in fbquery:
+ if nodelist is not None:
+ if noderec.hostname not in nodelist: continue
+
+ fb_nodeinfo = noderec.to_dict()
+ if pcu_in(fb_nodeinfo):
+ pcu_id = get(fb_nodeinfo, 'plc_node_stats.pcu_ids')[0]
+ pcurec = FindbadPCURecord.get_by(plc_pcuid=pcu_id)
+
+ if pcurec:
+ pcuinfo = pcurec.to_dict()
+ if verify(dict_query, pcuinfo):
+ nodenames.append(noderec.hostname)
+ pcunames.append(pcuinfo['plc_pcuid'])
+
+ return (nodenames, pcunames)
+
+def node_select(str_query, nodelist=None, fb=None):
+
+ hostnames = []
+ if str_query is None: return hostnames
+
+ #print str_query
+ dict_query = query_to_dict(str_query)
+ #print dict_query
+
+ for node in nodelist:
+ #if nodelist is not None:
+ # if node not in nodelist: continue
+
+ try:
+ fb_noderec = None
+ #fb_noderec = FindbadNodeRecord.query.filter(FindbadNodeRecord.hostname==node).order_by(FindbadNodeRecord.date_checked.desc()).first()
+ fb_noderec = FindbadNodeRecord.get_latest_by(hostname=node)
+ except KeyboardInterrupt:
+ print "Exiting at user request: Ctrl-C"
+ sys.exit(1)
+ except:
+ print traceback.print_exc()
+ continue
+
+ if fb_noderec:
+ fb_nodeinfo = fb_noderec.to_dict()
+
+ #fb_nodeinfo['pcu'] = color_pcu_state(fb_nodeinfo)
+ #if 'plcnode' in fb_nodeinfo:
+ # fb_nodeinfo.update(fb_nodeinfo['plcnode'])
+
+ if verify(dict_query, fb_nodeinfo):
+ #print fb_nodeinfo.keys()
+ #print node #fb_nodeinfo
+ hostnames.append(node)
+ else:
+ #print "NO MATCH", node
+ pass
+
+ return hostnames
+
+
echo ' "bootcd_version":"'`cat /mnt/cdrom/bootme/ID`'",'
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;}}'`'",'
echo ' "princeton_comon_dir":"'`ls -d /vservers/princeton_comon`'",'
echo ' "uptime":"'`cat /proc/uptime`'",'
import time
from datetime import datetime,timedelta
-from nodequery import verify,query_to_dict,node_select
+from monitor.query import verify,query_to_dict,node_select
from monitor.common import *
api = plc.getAuthAPI()
-from nodequery import verify,query_to_dict,node_select
+from monitor.query import verify,query_to_dict,node_select
from monitor.common import *
from sets import Set
import sys
from monitor import database
from monitor.common import *
+from monitor.query import *
from monitor.model import Record
import glob
import os
from monitor import config
-class NoKeyException(Exception): pass
-
def daysdown_print_nodeinfo(fbnode, hostname):
fbnode['hostname'] = hostname
fbnode['daysdown'] = Record.getStrDaysDown(fbnode)
format += "%%(%s)s " % f
print format % fbnode
-def first(path):
- indexes = path.split(".")
- return indexes[0]
-
-def get(fb, path):
- indexes = path.split(".")
- values = fb
- for index in indexes:
- if values and index in values:
- values = values[index]
- else:
- raise NoKeyException(index)
- return values
-
-def verifyType(constraints, data):
- """
- constraints is a list of key, value pairs.
- # [ {... : ...}==AND , ... , ... , ] == OR
- """
- con_or_true = False
- for con in constraints:
- #print "con: %s" % con
- if len(con.keys()) == 0:
- con_and_true = False
- else:
- con_and_true = True
-
- for key in con.keys():
- #print "looking at key: %s" % key
- if data is None:
- con_and_true = False
- break
-
- try:
- get(data,key)
- o = con[key]
- if o.name() == "Match":
- if get(data,key) is not None:
- value_re = re.compile(o.value)
- con_and_true = con_and_true & (value_re.search(get(data,key)) is not None)
- else:
- con_and_true = False
- elif o.name() == "ListMatch":
- if get(data,key) is not None:
- match = False
- for listitem in get(data,key):
- value_re = re.compile(o.value)
- if value_re.search(listitem) is not None:
- match = True
- break
- con_and_true = con_and_true & match
- else:
- con_and_true = False
- elif o.name() == "Is":
- con_and_true = con_and_true & (get(data,key) == o.value)
- elif o.name() == "FilledIn":
- con_and_true = con_and_true & (len(get(data,key)) > 0)
- elif o.name() == "PortOpen":
- if get(data,key) is not None:
- v = get(data,key)
- con_and_true = con_and_true & (v[str(o.value)] == "open")
- else:
- con_and_true = False
- else:
- value_re = re.compile(o.value)
- con_and_true = con_and_true & (value_re.search(get(data,key)) is not None)
-
- except NoKeyException, key:
- print "missing key %s" % key,
- pass
- #print "missing key %s" % key
- #con_and_true = False
-
- con_or_true = con_or_true | con_and_true
-
- return con_or_true
-
-def verifyDBrecord(constraints, record):
- """
- constraints is a list of key, value pairs.
- # [ {... : ...}==AND , ... , ... , ] == OR
- """
- def has_key(obj, key):
- try:
- x = obj.__getattribute__(key)
- return True
- except:
- return False
-
- def get_val(obj, key):
- try:
- return obj.__getattribute__(key)
- except:
- return None
-
- def get(obj, path):
- indexes = path.split("/")
- value = get_val(obj,indexes[0])
- if value is not None and len(indexes) > 1:
- for key in indexes[1:]:
- if key in value:
- value = value[key]
- else:
- raise NoKeyException(key)
- return value
-
- #print constraints, record
-
- con_or_true = False
- for con in constraints:
- #print "con: %s" % con
- if len(con.keys()) == 0:
- con_and_true = False
- else:
- con_and_true = True
-
- for key in con.keys():
- #print "looking at key: %s" % key
- if has_key(record, key):
- value_re = re.compile(con[key])
- if type([]) == type(get(record,key)):
- local_or_true = False
- for val in get(record,key):
- local_or_true = local_or_true | (value_re.search(val) is not None)
- con_and_true = con_and_true & local_or_true
- else:
- if get(record,key) is not None:
- con_and_true = con_and_true & (value_re.search(get(record,key)) is not None)
- else:
- print "missing key %s" % key,
- pass
-
- con_or_true = con_or_true | con_and_true
-
- return con_or_true
-
-def verify(constraints, data):
- """
- constraints is a list of key, value pairs.
- # [ {... : ...}==AND , ... , ... , ] == OR
- """
- con_or_true = False
- for con in constraints:
- #print "con: %s" % con
- if len(con.keys()) == 0:
- con_and_true = False
- else:
- con_and_true = True
-
- for key in con.keys():
- #print "looking at key: %s" % key
- if first(key) in data:
- value_re = re.compile(con[key])
- if type([]) == type(get(data,key)):
- local_or_true = False
- for val in get(data,key):
- local_or_true = local_or_true | (value_re.search(val) is not None)
- con_and_true = con_and_true & local_or_true
- else:
- if get(data,key) is not None:
- con_and_true = con_and_true & (value_re.search(get(data,key)) is not None)
- elif first(key) not in data:
- print "missing key %s" % first(key)
-
- con_or_true = con_or_true | con_and_true
-
- return con_or_true
-
-def query_to_dict(query):
-
- ad = []
-
- or_queries = query.split('||')
- for or_query in or_queries:
- and_queries = or_query.split('&&')
-
- d = {}
-
- for and_query in and_queries:
- (key, value) = and_query.split('=')
- d[key] = value
-
- ad.append(d)
-
- return ad
-
-def pcu_in(fbdata):
- #if 'plcnode' in fbdata:
- if 'plc_node_stats' in fbdata:
- if fbdata['plc_node_stats'] and 'pcu_ids' in fbdata['plc_node_stats']:
- if len(fbdata['plc_node_stats']['pcu_ids']) > 0:
- return True
- return False
-
-def pcu_select(str_query, nodelist=None):
- pcunames = []
- nodenames = []
- if str_query is None: return (nodenames, pcunames)
-
- if True:
- fbquery = FindbadNodeRecord.get_all_latest()
- fb_nodelist = [ n.hostname for n in fbquery ]
- if True:
- # NOTE: this doesn't work when there are only a few records current.
- # pcu_select should apply to all pcus globally, not just the most recent records.
- fbpcuquery = FindbadPCURecord.get_all_latest()
- fbpcu_list = [ p.plc_pcuid for p in fbpcuquery ]
-
- dict_query = query_to_dict(str_query)
- print "dict_query", dict_query
- print 'length %s' % len(fbpcuquery.all())
-
- for pcurec in fbpcuquery:
- pcuinfo = pcurec.to_dict()
- if verify(dict_query, pcuinfo):
- #nodenames.append(noderec.hostname)
- #print 'appending %s' % pcuinfo['plc_pcuid']
- pcunames.append(pcuinfo['plc_pcuid'])
-
- #for noderec in fbquery:
- # if nodelist is not None:
- # if noderec.hostname not in nodelist: continue
-#
-# fb_nodeinfo = noderec.to_dict()
-# if pcu_in(fb_nodeinfo):
-# pcurec = FindbadPCURecord.get_latest_by(plc_pcuid=get(fb_nodeinfo,
-# 'plc_node_stats.pcu_ids')[0]).first()
-# if pcurec:
-# pcuinfo = pcurec.to_dict()
-# if verify(dict_query, pcuinfo):
-# nodenames.append(noderec.hostname)
-# pcunames.append(pcuinfo['plc_pcuid'])
- return (nodenames, pcunames)
-
-def node_select(str_query, nodelist=None, fb=None):
-
- hostnames = []
- if str_query is None: return hostnames
-
- #print str_query
- dict_query = query_to_dict(str_query)
- #print dict_query
-
- for node in nodelist:
- #if nodelist is not None:
- # if node not in nodelist: continue
-
- try:
- fb_noderec = None
- #fb_noderec = FindbadNodeRecord.query.filter(FindbadNodeRecord.hostname==node).order_by(FindbadNodeRecord.date_checked.desc()).first()
- fb_noderec = FindbadNodeRecord.get_latest_by(hostname=node)
- except KeyboardInterrupt:
- print "Exiting at user request: Ctrl-C"
- sys.exit(1)
- except:
- print traceback.print_exc()
- continue
-
- if fb_noderec:
- fb_nodeinfo = fb_noderec.to_dict()
-
- #fb_nodeinfo['pcu'] = color_pcu_state(fb_nodeinfo)
- #if 'plcnode' in fb_nodeinfo:
- # fb_nodeinfo.update(fb_nodeinfo['plcnode'])
-
- if verify(dict_query, fb_nodeinfo):
- #print fb_nodeinfo.keys()
- #print node #fb_nodeinfo
- hostnames.append(node)
- else:
- #print "NO MATCH", node
- pass
-
- return hostnames
-
-
def main():
from monitor import parser as parsermodule
elif config.select is not None:
nodelist = node_select(config.select, nodelist, fb)
elif config.pcuselect is not None:
+ print "thirhd node select"
nodelist, pculist = pcu_select(config.pcuselect, nodelist)
- if pculist:
- for pcu in pculist:
- print pcu
+ #if pculist:
+ # for pcu in pculist:
+ # print pcu
+ print "len: %s" % len(nodelist)
for node in nodelist:
config.node = node
- if node not in nodelist:
- continue
-
try:
# Find the most recent record
fb_noderec = FindbadNodeRecord.get_latest_by(hostname=node)
fields = None
fb_print_nodeinfo(fb_nodeinfo, node, fields)
- elif not config.select and 'state' in fb_nodeinfo:
+ elif not config.select and 'observed_status' in fb_nodeinfo:
fb_print_nodeinfo(fb_nodeinfo, node)
else:
+ print "passing..."
pass
if __name__ == "__main__":
from monitor.const import MINUP
from monitor.common import *
-from nodequery import verify,query_to_dict,node_select
+from monitor.query import verify,query_to_dict,node_select
from monitor.model import *
api = plc.getAuthAPI()
from monitor.database.info.model import *
from monitor.database.info.interface import *
-from nodequery import verify,query_to_dict,node_select
+from monitor.query import verify,query_to_dict,node_select
api = plc.getAuthAPI()
api = plc.getAuthAPI()
import sys
-import reboot
+#import reboot
from datetime import datetime, timedelta
-import database
+from monitor.database.info.model import *
import comon
from monitor.common import color_pcu_state, datetime_fromstr, email_exception
from nodehistory import get_filefromglob
from monitor.const import MINUP
from monitor.common import *
-from nodequery import verify,query_to_dict,node_select
+from monitor.query import verify,query_to_dict,node_select
from monitor.model import *
api = plc.getAuthAPI()
name = "%s %s %s (%s)" % (person['title'], person['first_name'], person['last_name'], person['email'])
if not name:
- print "no pis at %s" % loginbase
- sys.exit(1)
+ print "no PIs at %s" % loginbase
+ name = "no PIs"
+ #sys.exit(1)
date = time.strftime("%Y/%m/%d", time.gmtime(time.time()))
parser.set_defaults( select=None,
input=None,
frequency=False,
- package=False,
+ package=True,
)
parser.add_option("", "--input", dest="input",
help="the input file")
- parser.add_option("", "--select", dest="select",
+ parser.add_option("", "--pattern", dest="select",
help="the pattern to pull out from rpm list")
parser.add_option("", "--frequency", dest="frequency", action="store_true",
help="print the frequency of packages matched by select")
- parser.add_option("", "--package", dest="package", action="store_true",
+ parser.add_option("", "--disablepackage", dest="package", action="store_false",
help="print the frequency of each pl package")
(config, args) = parser.parse_args()
if len(sys.argv) == 1 or config.input is None:
return_sums[sum]['diff'] = set(rpms) - set(current_packages)
if config.frequency:
- print "Frequency for packages that matched: %s" % pattern
+ #print "Frequency for packages that matched: %s" % pattern
sum_list = []
for sum in return_sums:
sum_list.append((len(return_sums[sum]['hosts']), sum))
sum_list.sort(lambda a,b: cmp(b[0], a[0]))
for sum in sum_list:
- print sum[0], sum[1], map(lambda x: x.replace('.planetlab', ''), return_sums[sum[1]]['diff'])
+ #print sum[0], sum[1], map(lambda x: x.replace('.planetlab', ''), return_sums[sum[1]]['diff'])
+ print sum[0], sum[1], len(map(lambda x: x.replace('.planetlab', ''), return_sums[sum[1]]['diff']))
if __name__ == "__main__":
- main()
+ try:
+ main()
+ except IOError:
+ pass
-- If there's an existing database, these commands will upgrade it to the
-- current version
ALTER TABLE actionrecord ADD COLUMN log_path varchar DEFAULT NULL;
+
+ALTER TABLE findbadnoderecord ADD COLUMN iptables_status varchar DEFAULT NULL;
+ALTER TABLE findbadnoderecord_history ADD COLUMN iptables_status varchar DEFAULT NULL;
hostname = widgets.CheckBox(label="Hostname")
firewall = widgets.CheckBox(label="Firewall?")
+ fs_status = widgets.CheckBox(label="Filesystem Status")
ssh_status = widgets.CheckBox(label="SSH Status")
ssh_error = widgets.CheckBox(label="SSH Errors")
dns_status = widgets.CheckBox(label="DNS Status")
+ iptables_status = widgets.CheckBox(label="IP Tables Status")
nm_status = widgets.CheckBox(label="NM Status")
princeton_comon_dir = widgets.CheckBox(label="CoMon Dir")
princeton_comon_running = widgets.CheckBox(label="CoMon Running")
kernel_version = widgets.CheckBox(label="Kernel")
bootcd_version = widgets.CheckBox(label="BootCD")
observed_status = widgets.CheckBox(label="Observed Status")
+ uptime = widgets.CheckBox(label="Uptime")
port_status = widgets.CheckBox(label="Port Status")
rpms = widgets.CheckBox(label="RPM")
rpmvalue = widgets.TextField(label="RPM Pattern")
print "write data: %s" % abs_target_filename
util.file.dumpFile(abs_target_filename, log.file.read())
bootman.bootmanager_log_action(hostname, short_target_filename, logtype)
+ session.flush()
print "redirecting 3"
<!-- for keys show each th -->
<tr>
<span py:for="key in sorted(fields.keys())" >
- <th class="sortable plekit_table">${key}</th>
+ <span py:if="key == 'uptime'">
+ <th class="sortable-numeric plekit_table">${key}</th>
+ </span>
+ <span py:if="key != 'uptime'">
+ <th class="sortable plekit_table">${key}</th>
+ </span>
</span>
</tr>
</thead>