3 # WARNING - you might need to set your locale before you can run this script
5 # export LANG=en_US.UTF-8
11 from NagiosConfig import NagiosConfig
13 SERVER="www.planet-lab.org"
16 options='h:o:Os:d:nNv'
18 usage_string="""Usage : %s [options] plc-id plc-passwd role
19 Outputs a nagios config for watching a given set of sites
20 Also writes a static HTML page for bookmarking site-centric queries to comon
22 -h plc-hostname To provide an alternate plc hostname
24 -o e-mail If you provide an e-mail address, all notifications
25 will be sent there. Otherwise, you'll need admin role
26 so that we can determine the respective PI's e-mails
27 -O same as -e with the plc-id as dest. e-mail
28 -s site-file You can provide a list of sites in a separate file
29 expected format is one line per site, site_id first
30 the default is to list all sites
31 -d dirname To specify an alternate output dir
33 -n Does not generate the nagios config
34 -N Does not generate the HTML page
35 -v Runs in verbose mode
36 """%(sys.argv[0],SERVER,DIRNAME)
48 opts,args = getopt.getopt(argv, options)
49 except getopt.GetoptError:
50 print "Unknown option"
80 print "Unknown option",o
83 if not len(args) == 3:
86 (plc_id,passwd,role) = args
90 # print plc_server,output_mail,dirname,opt_nagios,opt_html
91 # print plc_id,passwd,role,site_file
93 print "Connecting to %s and gathering data"%plc_server
94 config = NagiosConfig (plc_server,plc_id,passwd,role)
97 config.GatherData (output_mail,site_file)
100 print "Creating nagios config in %s"%dirname
101 config.WriteNagiosConfig (dirname)
104 html_page = "%s/comon.html"%dirname
105 config.WriteComonLinks (html_page)
109 if __name__ == "__main__":