import reboot
from reboot import pcu_name
-import soltesz
+import database
+import moncommands
import plc
import comon
import threadpool
except:
try:
print "GetPCU from file %s" % pcuname
- l_pcus = soltesz.dbLoad("pculist")
+ l_pcus = database.dbLoad("pculist")
for i in l_pcus:
if i['pcu_id'] == pcuname:
l_pcu = i
l_node = plc.getNodes(node_ids, ['hostname', 'last_contact', 'node_id', 'ports'])
except:
try:
- plc_nodes = soltesz.dbLoad("l_plcnodes")
+ plc_nodes = database.dbLoad("l_plcnodes")
for n in plc_nodes:
if n['node_id'] in node_ids:
l_node.append(n)
d_site = d_site[0]
except:
try:
- plc_sites = soltesz.dbLoad("l_plcsites")
+ plc_sites = database.dbLoad("l_plcsites")
for site in plc_sites:
if site['site_id'] == site_id:
d_site = site
#### RUN NMAP ###############################
if continue_probe:
- nmap = soltesz.CMD()
+ nmap = moncommands.CMD()
(oval,eval) = nmap.run_noexcept("nmap -oG - -P0 -p22,23,80,443,5869,9100,16992 %s | grep Host:" % pcu_name(values))
# NOTE: an empty / error value for oval, will still work.
(values['portstatus'], continue_probe) = nmap_portstatus(oval)
count += 1
print "%d %s %s" % (count, nodename, externalState['nodes'][pcu_id]['values'])
- soltesz.dbDump(config.dbname, externalState)
+ database.dbDump(config.dbname, externalState)
if errors is not None:
pcu_id = "id_%s" % nodename
errorState[pcu_id] = errors
- soltesz.dbDump("findbadpcu_errors", errorState)
+ database.dbDump("findbadpcu_errors", errorState)
# this will be called when an exception occurs within a thread
def handle_exception(request, result):
pass
# WAIT while all the work requests are processed.
+ begin = time.time()
while 1:
try:
time.sleep(1)
tp.poll()
+ # if more than two hours
+ if time.time() - begin > (60*60*1):
+ print "findbadpcus.py has run out of time!!!!!!"
+ database.dbDump(config.dbname, externalState)
+ os._exit(1)
except KeyboardInterrupt:
print "Interrupted!"
break
def main():
global externalState
- l_pcus = soltesz.if_cached_else_refresh(1, config.refresh, "pculist", lambda : plc.GetPCUs())
- externalState = soltesz.if_cached_else(1, config.dbname, lambda : externalState)
+ l_pcus = database.if_cached_else_refresh(1, config.refresh, "pculist", lambda : plc.GetPCUs())
+ externalState = database.if_cached_else(1, config.dbname, lambda : externalState)
cohash = {}
if config.increment:
# update global round number to force refreshes across all nodes
externalState['round'] += 1
- if config.filename == None and config.pcuid == None:
+ if 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.filename is not None:
- l_pcus = config.getListFromFile(config.filename)
+ elif config.nodelist is not None:
+ l_pcus = config.getListFromFile(config.nodelist)
l_pcus = [int(pcu) for pcu in l_pcus]
elif config.pcuid is not None:
l_pcus = [ config.pcuid ]
from config import config
from optparse import OptionParser
parser = OptionParser()
- parser.set_defaults(filename=None,
+ parser.set_defaults(nodelist=None,
increment=False,
pcuid=None,
dbname="findbadpcus",
cachenodes=False,
refresh=False,
)
- parser.add_option("-f", "--nodelist", dest="filename", metavar="FILE",
+ parser.add_option("-f", "--nodelist", dest="nodelist", metavar="FILE",
help="Provide the input file for the node list")
parser.add_option("", "--pcuid", dest="pcuid", metavar="id",
help="Provide the id for a single pcu")
traceback.print_exc()
print "Exception: %s" % err
print "Saving data... exitting."
- soltesz.dbDump(config.dbname, externalState)
+ database.dbDump(config.dbname, externalState)
sys.exit(0)