import pickle
noserial=False
try:
- from PHPSerialize import *
- from PHPUnserialize import *
+ from util.PHPSerialize import *
+ from util.PHPUnserialize import *
except:
#print >>sys.stderr, "PHPSerial db type not allowed."
noserial=True
import string
import time
import config
+import util.file
# QUERY all nodes.
cohash = cotop.coget(cotop_url)
l_nodes = syncplcdb.create_plcdb()
if config.nodelist:
- f_nodes = config.getListFromFile(config.nodelist)
+ f_nodes = util.file.getListFromFile(config.nodelist)
l_nodes = filter(lambda x: x['hostname'] in f_nodes, l_nodes)
elif config.node:
f_nodes = [config.node]
import string
import time
import socket
+import util.file
+import plc
+import sets
import signal
# update global round number to force refreshes across all nodes
externalState['round'] += 1
- if config.nodelist == None and config.pcuid == None:
+ if config.site is not None:
+ api = plc.getAuthAPI()
+ site = api.GetSites(config.site)
+ l_nodes = api.GetNodes(site[0]['node_ids'], ['pcu_ids'])
+ pcus = []
+ for node in l_nodes:
+ pcus += node['pcu_ids']
+ l_pcus = [pcu for pcu in sets.Set(pcus)]
+
+ elif config.nodelist == None and config.pcuid == None:
print "Calling API GetPCUs() : refresh(%s)" % config.refresh
l_pcus = [pcu['pcu_id'] for pcu in l_pcus]
elif config.nodelist is not None:
- l_pcus = config.getListFromFile(config.nodelist)
+ l_pcus = util.file.getListFromFile(config.nodelist)
l_pcus = [int(pcu) for pcu in l_pcus]
elif config.pcuid is not None:
l_pcus = [ config.pcuid ]
parser.set_defaults(nodelist=None,
increment=False,
pcuid=None,
+ site=None,
dbname="findbadpcus",
cachenodes=False,
refresh=False,
)
parser.add_option("-f", "--nodelist", dest="nodelist", metavar="FILE",
help="Provide the input file for the node list")
+ parser.add_option("", "--site", dest="site", metavar="FILE",
+ help="Get all pcus associated with the given site's nodes")
parser.add_option("", "--pcuid", dest="pcuid", metavar="id",
help="Provide the id for a single pcu")
+
parser.add_option("", "--cachenodes", action="store_true",
help="Cache node lookup from PLC")
parser.add_option("", "--dbname", dest="dbname", metavar="FILE",
# SERVER PATHS
MONITOR_HOSTNAME=monitor.planet-lab.org
-MONITOR_SCRIPT_ROOT=
-MONITOR_DATA_ROOT=
-MONITOR_DATA_ROOTWEB=/var/www/cgi-bin/pdb
-MONITOR_ARCHIVE_ROOT=
+MONITOR_SCRIPT_ROOT=/usr/share/monitor-server
+MONITOR_DATA_ROOT=/var/lib/monitor-server
+MONITOR_ARCHIVE_ROOT=/usr/share/monitor-server/archive-pdb
[commandline]
debug=0
l_nodes = syncplcdb.create_plcdb()
l_plcnodes = database.dbLoad("l_plcnodes")
- if config.node:
- l_nodes = [config.node]
- else:
- l_nodes = [node['hostname'] for node in l_plcnodes]
+ l_nodes = get_nodeset(config)
+ #if config.node:
+ # l_nodes = [config.node]
+ ##else:
+ # l_nodes = [node['hostname'] for node in l_plcnodes]
checkAndRecordState(l_nodes, l_plcnodes)
import struct
import reboot
import time
+import util.file
+import plc
from monitor import database
from unified_model import PersistFlags
esc = struct.pack('i', 27)
return l
def color_pcu_state(fbnode):
- import plc
if 'plcnode' in fbnode and 'pcu_ids' in fbnode['plcnode'] and len(fbnode['plcnode']['pcu_ids']) > 0 :
values = reboot.get_pcu_values(fbnode['plcnode']['pcu_ids'][0])
tup = time.strptime(str, "%m/%d/%Y")
ret = datetime.fromtimestamp(time.mktime(tup))
return ret
+
+def get_nodeset(config):
+ """
+ Given the config values passed in, return the set of hostnames that it
+ evaluates to.
+ """
+ api = plc.getAuthAPI()
+ l_nodes = database.dbLoad("l_plcnodes")
+
+ if config.nodelist:
+ f_nodes = util.file.getListFromFile(config.nodelist)
+ l_nodes = filter(lambda x: x['hostname'] in f_nodes, l_nodes)
+ elif config.node:
+ f_nodes = [config.node]
+ l_nodes = filter(lambda x: x['hostname'] in f_nodes, l_nodes)
+ elif config.nodegroup:
+ ng = api.GetNodeGroups({'name' : config.nodegroup})
+ l_nodes = api.GetNodes(ng[0]['node_ids'], ['hostname'])
+ elif config.site:
+ site = api.GetSites(config.site)
+ l_nodes = api.GetNodes(site[0]['node_ids'], ['hostname'])
+
+ l_nodes = [node['hostname'] for node in l_nodes]
+
+ # perform this query after the above options, so that the filter above
+ # does not break.
+ if config.nodeselect:
+ fb = database.dbLoad("findbad")
+ l_nodes = node_select(config.nodeselect, fb['nodes'].keys(), fb)
+
+ return l_nodes
+
#!/usr/bin/python
-import monitorconfig
+import config
print "<?php"
-for attr in dir(monitorconfig):
- val = monitorconfig.__getattribute__(attr)
- if attr[0].isupper():
+for attr in dir(config):
+ val = config.__getattribute__(attr)
+ if attr[0].isupper() and attr[1].isupper():
print "define('%s', '%s'); " % (attr, val)
print "?>"
import traceback
api = plc.getAuthAPI()
-loginbase = "princeton"
+loginbase = sys.argv[1] # "princeton"
try:
site = api.GetSites(loginbase)[0]
* had to mount -t devpts devpts /dev/pts to get ssh to work inside the
chroot. also, disable the pam modules in /etc/pam.d/sshd
+ * auto configuration for php configuration.
+ maybe run translation of monitor.conf before loading monitorconfig.php?
+
* A setup script of some kind would be nice that walked through :
- writing monitorconfig.py
- creation of monitorconfig.php
- run syncplcdb.py
- testapi.py
- findbad.py on sample site.
+ - nodebad.py
+ - nodequery.py
+ - nodegroups.py
+ - findbadpcus.py
- loads webpage for those retreived values to confirm setup succeeded.
- * reimplement the config.py / .config mechanism. i'd like for many commands
+ * reimplement the config.py / .config mechanism. I'd like for many commands
to share very similar argument or argument sets, as well as have some
common config options. I'm not sure the best way to do this.
- python supports load-once modules, so subsequent imports refer to the
same module object.
+ * have package pull in threadpool from easy_install
- * Find a better location to place and pull the PKL files currently in the pdb
- directory. Ultimately, these should be stored in a real DB. Until then,
- they should sit in a location that is accessible from the www scripts,
- backend scripts, and user utilities.
+ * place PKL files in a real database
* clean up plc.py; there's a lot of redundent code.
configuration,
policy,
data model,
+ data access,
object interfaces.
Lower priority:
availble with PLC.
Done:
+ * Find a better location to place and pull the PKL files currently in the pdb
+ directory. Ultimately, these should be stored in a real DB. Until then,
+ they should sit in a location that is accessible from the www scripts,
+ backend scripts, and user utilities.
* nodebad loads plc_hn2lb unconditionally
* nodeinfo loads act_all unconditionally
* change findbad.py default db name
<?php
+# TODO: clean up this aweful hack.
+system("/usr/share/monitor-server/phpconfig.py > /var/www/cgi-bin/monitor/monitorconfig.php");
include 'monitorconfig.php';
-define("PICKLE_PATH", MONITOR_DATA_ROOTWEB);
+define("PICKLE_PATH", MONITOR_DATA_ROOT);
class Pickle
{