clarified email message in emailZabbix.
from glob import glob
import vxargs
from glob import glob
import vxargs
-import parser as parsermodule
+from monitor import parser as parsermodule
from automate import *
def build_vx_args(shell_cmd):
from automate import *
def build_vx_args(shell_cmd):
elif config.site:
site = api.GetSites(config.site)
l_nodes = api.GetNodes(site[0]['node_ids'], ['hostname'])
elif config.site:
site = api.GetSites(config.site)
l_nodes = api.GetNodes(site[0]['node_ids'], ['hostname'])
+ elif config.sitelist:
+ site_list = config.sitelist.split(',')
+ sites = api.GetSites(site_list)
+ node_ids = []
+ for s in sites:
+ node_ids += s['node_ids']
+ l_nodes = api.GetNodes(node_ids, ['hostname'])
l_nodes = [node['hostname'] for node in l_nodes]
l_nodes = [node['hostname'] for node in l_nodes]
print "Saving data... exitting."
sys.exit(0)
print "sleeping"
print "Saving data... exitting."
sys.exit(0)
print "sleeping"
- #print "final commit"
- #time.sleep(10)
if_new_set={'round' : global_round})
global_round = fbsync.round
if_new_set={'round' : global_round})
global_round = fbsync.round
if config.site is not None:
if config.site is not None:
site = api.GetSites(config.site)
l_nodes = api.GetNodes(site[0]['node_ids'], ['pcu_ids'])
pcus = []
site = api.GetSites(config.site)
l_nodes = api.GetNodes(site[0]['node_ids'], ['pcu_ids'])
pcus = []
pcus += node['pcu_ids']
# clear out dups.
l_pcus = [pcu for pcu in sets.Set(pcus)]
pcus += node['pcu_ids']
# clear out dups.
l_pcus = [pcu for pcu in sets.Set(pcus)]
+ elif config.sitelist:
+ site_list = config.sitelist.split(',')
+
+ sites = api.GetSites(site_list)
+ node_ids = []
+ for s in sites:
+ node_ids += s['node_ids']
+
+ l_nodes = api.GetNodes(node_ids, ['pcu_ids'])
+ pcus = []
+ for node in l_nodes:
+ pcus += node['pcu_ids']
+ # clear out dups.
+ l_pcus = [pcu for pcu in sets.Set(pcus)]
+
elif config.pcuselect is not None:
n, pcus = pcu_select(config.pcuselect)
print pcus
elif config.pcuselect is not None:
n, pcus = pcu_select(config.pcuselect)
print pcus
Thank you for your help,
-- PlanetLab Central (%(support_email)s)
"""
Thank you for your help,
-- PlanetLab Central (%(support_email)s)
"""
- node_discovered_subject = """Discovered {HOSTNAME} and online"""
+ node_discovered_subject = """Discovered host {HOSTNAME} w/ ip {IPADDRESS} and online"""
node_discovered = """
Thank you for registering and installing this machine:
node_discovered = """
Thank you for registering and installing this machine:
+ hostname {HOSTNAME} : ip {IPADDRESS}
Our monitoring infrastructure has detected it, and in the future it will alert you in the event of unexpected downtime.
Our monitoring infrastructure has detected it, and in the future it will alert you in the event of unexpected downtime.
- {TRIGGER.NAME}: {STATUS}
+ Discovered : Online
+ {TRIGGER.URL}
+
Thank you for your help,
-- PlanetLab Central (%(support_email)s)
"""
Thank you for your help,
-- PlanetLab Central (%(support_email)s)
"""
if parser == None:
parser = OptionParser()
if parser == None:
parser = OptionParser()
- parser.set_defaults(node=None, site=None, nodelist=None, nodeselect=None, nodegroup=None)
+ parser.set_defaults(node=None, site=None, sitelist=None, nodelist=None, nodeselect=None, nodegroup=None)
parser.add_option("", "--node", dest="node", metavar="hostname",
help="Provide a single node to operate on")
parser.add_option("", "--site", dest="site", metavar="site name",
help="Specify a single site to operate on")
parser.add_option("", "--node", dest="node", metavar="hostname",
help="Provide a single node to operate on")
parser.add_option("", "--site", dest="site", metavar="site name",
help="Specify a single site to operate on")
+ parser.add_option("", "--sitelist", dest="sitelist", metavar="site name",
+ help="Specify a list of sites, separated by ','")
parser.add_option("", "--nodegroup", dest="nodegroup", metavar="GroupName",
help="Provide the nodegroup for the list of nodes.")
parser.add_option("", "--nodelist", dest="nodelist", metavar="FILE",
parser.add_option("", "--nodegroup", dest="nodegroup", metavar="GroupName",
help="Provide the nodegroup for the list of nodes.")
parser.add_option("", "--nodelist", dest="nodelist", metavar="FILE",
# TODO: how to handle the weird, georgetown pcus, the drac faults, and ilo faults
except ExceptionPort, err:
rb_ret = str(err)
# TODO: how to handle the weird, georgetown pcus, the drac faults, and ilo faults
except ExceptionPort, err:
rb_ret = str(err)
+ except NameError, err:
+ rb_ret = str(err)
if __name__ == '__main__':
logger = logging.getLogger("monitor")
main()
if __name__ == '__main__':
logger = logging.getLogger("monitor")
main()
+ f = open("/tmp/rebootlog", 'a')
+ f.write("reboot %s\n" % sys.argv)
+ f.close()
from monitor.model import *
api = plc.getAuthAPI()
from monitor.model import *
api = plc.getAuthAPI()
+def main():
+ main2(config)
l_nodes = plccache.l_nodes
l_plcsites = plccache.l_sites
if config.site:
l_sites = [config.site]
l_nodes = plccache.l_nodes
l_plcsites = plccache.l_sites
if config.site:
l_sites = [config.site]
+ elif config.sitelist:
+ site_list = config.sitelist.split(',')
+ l_sites = site_list
else:
l_sites = [site['login_base'] for site in l_plcsites]
else:
l_sites = [site['login_base'] for site in l_plcsites]
parser.add_option("", "--site", dest="site", metavar="login_base",
help="Provide a single site to operate on")
parser.add_option("", "--site", dest="site", metavar="login_base",
help="Provide a single site to operate on")
- parser.add_option("", "--sitelist", dest="sitelist", metavar="file.list",
- help="Provide a list of files to operate on")
+ parser.add_option("", "--sitelist", dest="sitelist",
+ help="Provide a list of sites separated by ','")
config = parsermodule.parse_args(parser)
try:
config = parsermodule.parse_args(parser)
try:
except Exception, err:
import traceback
print traceback.print_exc()
except Exception, err:
import traceback
print traceback.print_exc()
def nodeaction_handler(self, tg_exceptions=None):
"""Handle any kind of error."""
def nodeaction_handler(self, tg_exceptions=None):
"""Handle any kind of error."""
- refurl = request.headers.get("Referer",link("pcu"))
- print refurl
-
- # TODO: do this more intelligently...
- uri_fields = urllib.splitquery(refurl)
- if uri_fields[1] is not None:
- val = query_to_dict(uri_fields[1])
- if 'pcuid' in val:
- pcuid = val['pcuid']
- elif 'hostname' in val:
- pcuid = FindbadNodeRecord.get_latest_by(hostname=val['hostname']).first().plc_pcuid
+
+ if 'pcuid' in request.params:
+ pcuid = request.params['pcuid']
+ refurl = request.headers.get("Referer",link("pcu"))
+ print refurl
+
+ # TODO: do this more intelligently...
+ uri_fields = urllib.splitquery(refurl)
+ if uri_fields[1] is not None:
+ val = query_to_dict(uri_fields[1])
+ if 'pcuid' in val:
+ pcuid = val['pcuid']
+ elif 'hostname' in val:
+ pcuid = FindbadNodeRecord.get_latest_by(hostname=val['hostname']).first().plc_pcuid
+ else:
+ pcuid=None
+ else:
+ pcuid=None
cherry_trail = cherrypy._cputil.get_object_trail()
for i in cherry_trail:
print "trail: ", i
print pcuid
cherry_trail = cherrypy._cputil.get_object_trail()
for i in cherry_trail:
print "trail: ", i
print pcuid
- return self.pcuview(pcuid, **dict(exceptions=tg_exceptions))
+ return self.pcuview(None, pcuid, **dict(exceptions=tg_exceptions))
def nodeaction(self, **data):
for item in data.keys():
def nodeaction(self, **data):
for item in data.keys():
print "REBOOT: %s" % hostname
ret = reboot.reboot_str(str(hostname))
print ret
print "REBOOT: %s" % hostname
ret = reboot.reboot_str(str(hostname))
print ret
- if ret: raise RuntimeError("Error using PCU: " + ret)
+ if ret: raise RuntimeError("Error using PCU: " + str(ret))
flash("Reboot appeared to work. All at most 5 minutes. Run ExternalScan to check current status.")
elif action == "ExternalScan":
flash("Reboot appeared to work. All at most 5 minutes. Run ExternalScan to check current status.")
elif action == "ExternalScan":