+ blacklist.py -- manages a node blacklist on which no actions should ever be
[monitor.git] / dumpact.py
1 #!/usr/bin/python
2
3 # Read in the act_* databases and print out a human readable version
4
5 import sys
6 import time
7 import getopt
8 import soltesz
9
10 def main():
11
12         act_all = soltesz.dbLoad(sys.argv[1])
13         plcdb_hn2lb = soltesz.dbLoad("plcdb_hn2lb")
14         s_nodenames = ""
15         sickdb = {}
16
17         sorted_keys = act_all.keys()
18         sorted_keys.sort()
19         for nodename in sorted_keys:
20                 diag_nodelist = act_all[nodename]
21                 lb = plcdb_hn2lb[nodename]
22                 if lb not in sickdb:
23                         sickdb[lb] = {}
24                 sickdb[lb][nodename] = diag_nodelist
25
26         sorted_keys = sickdb.keys()
27         sorted_keys.sort()
28         for loginbase in sorted_keys:
29                 nodedict = sickdb[loginbase]
30                 sort_nodekeys = nodedict.keys()
31                 sort_nodekeys.sort()
32                 print "%s :" % loginbase
33                 for nodename in sort_nodekeys:
34                         if len(act_all[nodename]) == 0:
35                                 print "%20s : %-40s has no events" % (loginbase, nodename)
36                         else:
37                                 l_ev = act_all[nodename]
38                                 print "    %s" % nodename
39                                 for diag_node in l_ev:
40                                         #s_time=time.strftime("%Y/%m/%d %H:%M:%S",time.gmtime(ev[1]))
41                                         keys = diag_node.keys()
42                                         keys.sort()
43                                         for k in keys:
44                                                 if "message" not in k and "msg" not in k:
45                                                         print "\t'%s' : %s" % (k, diag_node[k])
46                                         print "\t--"
47
48         print s_nodenames
49
50         
51 if __name__ == '__main__':
52         main()