#
# Faiyaz Ahmed <faiyaza@cs.princeton.edu>
#
-# $Id: $
+# $Id: comon.py,v 1.4 2006/11/14 19:20:13 faiyaza Exp $
#
# Get CoMon data, unsorted, in CSV, and create a huge hash.
#
class Comon(Thread):
"""
+ cdb is the comon database (dictionary)
+ all buckets is a queue of all problem nodes. This gets sent to rt to find
+ tickets open for host.
"""
def __init__(self, cdb, allbuckets):
self.codata = cdb
self.updated = time.time()
self.allbuckets = allbuckets
- self.comonbkts = {"ssh": "sshstatus%20%3E%202h",
+ self.comonbkts = {"down" : "resptime%20==%200%20&&%20keyok==null",
+ "ssh": "sshstatus%20%3E%202h",
"clock_drift": "drift%20%3E%201m",
"dns": "dns1udp%20%3E%2080%20&&%20dns2udp%20%3E%2080",
- "disk": "resptime%20%3E%200%20&&%20gbfree%20%3C%205",
- "filerw": "filerw%3E0"}
+ "filerw": "filerw%3E0",
+ "dbg" : "keyok==0"}
Thread.__init__(self)
def __tohash(self,rawdata):
# Update individual buckekts. Hostnames only.
def updatebkts(self):
for (bkt,url) in self.comonbkts.items():
+ logger.debug("COMON: Updating bucket %s" % bkt)
tmp = self.coget(COMONURL + "&format=formatcsv&select='" + url + "'").keys()
setattr(self, bkt, tmp)
# Get time of update
self.updated = time.time()
# Make a Hash, put in self.
- self.codata = self.coget(COMONURL + "&format=formatcsv")
+ self.codata.update(self.coget(COMONURL + "&format=formatcsv"))
def coget(self,url):
rawdata = None
try:
- logger.debug("Trying - " + url)
coserv = urllib2.Request(url)
coserv.add_header('User-Agent',
'PL_Monitor +http://monitor.planet-lab.org/')
self.allbuckets.put(host)
def run(self):
- while 1:
- self.updatedb()
- self.updatebkts()
- self.push()
- time.sleep(COSLEEP)
+ self.updatedb()
+ self.updatebkts()
+ self.push()
def __repr__(self):
return self
t = Queue.Queue()
cdb = {}
a = Comon(cdb,t)
+ print a.comonbkts
a.start()
- time.sleep(3)
- print a.ssh
+
+ time.sleep(5)
+ print a.down
+
+ time.sleep(5)
+ #print cdb
+ for host in cdb.keys():
+ if cdb[host]['keyok'] == "0":
+ print("%s \t Bootstate %s nodetype %s kernver %s keyok %s" %(host, cdb[host]['bootstate'], cdb[host]['nodetype'], cdb[host]['kernver'], cdb[host]['keyok']))
+ print a.codata['michelangelo.ani.univie.ac.at']
#time.sleep(3)
#a.push()
#print a.filerw
- print a.coget(COMONURL + "&format=formatcsv&select='" + a.comonbkts['filerw'])
+ #print a.coget(COMONURL + "&format=formatcsv&select='" + a.comonbkts['filerw'])
os._exit(0)
if __name__ == '__main__':