log all bash-command line commands and upload them centrally
[monitor.git] / commands / findall.py
1 #!/usr/bin/python 
2
3 from monitor import parser as parsermodule
4 from findbad import main as findbad_main
5 from findbadpcu import main as findbadpcu_main
6 from sitebad import main as sitebad_main
7 from nodebad import main as nodebad_main
8 from pcubad import main as pcubad_main
9 from monitor.wrapper import plccache
10 from monitor.database.info.model import  *
11 from monitor.common import  *
12 import sys
13
14 if __name__ == '__main__':
15
16         parser = parsermodule.getParser(['nodesets'])
17
18         parser.set_defaults( increment=False, dbname="findbad", cachenodes=False, 
19                                                 force=False, pcuselect=None, pcuid=None, pcu=None, checkpcu=False)
20         parser.add_option("", "--cachenodes", action="store_true",
21                                                 help="Cache node lookup from PLC")
22         parser.add_option("", "--dbname", dest="dbname", metavar="FILE", 
23                                                 help="Specify the name of the database to which the information is saved")
24         parser.add_option("-i", "--increment", action="store_true", dest="increment", 
25                                                 help="Increment round number to force refresh or retry")
26         parser.add_option("", "--force", action="store_true", dest="force", 
27                                                 help="Force probe without incrementing global 'round'.")
28         parser.add_option("", "--checkpcu", dest="checkpcu", action="store_true",
29                                                 help="whether to include PCUs in the site status")
30
31         parser = parsermodule.getParser(['defaults'], parser)
32         
33         cfg = parsermodule.parse_args(parser)
34
35         try:
36                 print "findbad"
37                 findbad_main()
38                 print "befor-len: ", len( [ i for i in session] )
39                 session.flush(); session.clear()
40                 print "after-len: ", len( [ i for i in session] )
41                 print "findbadpcu"
42                 findbadpcu_main()
43                 print "befor-len: ", len( [ i for i in session] )
44                 session.flush(); session.clear()
45                 print "after-len: ", len( [ i for i in session] )
46                 print "nodebad"
47                 nodebad_main()
48                 print "befor-len: ", len( [ i for i in session] )
49                 session.flush(); session.clear()
50                 print "after-len: ", len( [ i for i in session] )
51                 print "pcubad"
52                 pcubad_main()
53                 print "befor-len: ", len( [ i for i in session] )
54                 session.flush(); session.clear()
55                 print "after-len: ", len( [ i for i in session] )
56                 print "sitebad"
57                 sitebad_main()
58                 print "befor-len: ", len( [ i for i in session] )
59                 session.flush(); session.clear()
60                 print "after-len: ", len( [ i for i in session] )
61         except Exception, err:
62                 import traceback
63                 email_exception()
64                 print traceback.print_exc()
65                 print "Exception: %s" % err
66                 print "Saving data... exitting."
67                 sys.exit(0)