5 from monitor.wrapper import plc
6 from monitor import database
9 from monitor.database.dborm import session
13 plcdb = database.dbLoad("l_plcsites")
14 netid2ip = database.dbLoad("plcdb_netid2ip")
15 lb2hn = database.dbLoad("plcdb_lb2hn")
17 def get_site_iplist(loginbase):
18 node_list = lb2hn[loginbase]
20 # TODO: ip_list string cannot be longer than 255 characters.
21 # TODO: if it is, then we need to break up the discovery rule.
23 for node in node_list:
24 ip = netid2ip[node['nodenetwork_ids'][0]]
25 if len(ip_list) > 0: ip_list += ","
30 def add_loginbase(loginbase):
32 techs = plc.getTechEmails(loginbase)
33 pis = plc.getPIEmails(loginbase)
34 iplist = get_site_iplist(loginbase)
36 print "zabbixsite.setup_site('%s', %s, %s, '%s')" % (loginbase,techs, pis, iplist)
37 zabbixsite.setup_site(loginbase, techs, pis, iplist)
39 if __name__=="__main__":
40 #sites = api.GetSites({'peer_id' : None}, ['login_base'])
41 for loginbase in ['princeton', 'princetondsl', 'monitorsite']:
42 add_loginbase(loginbase)
46 ## Scripts : includes external scripts to:
51 # define technical contact, principal investigator groups
52 # define a Group for every site
55 # define a User for every user with admin/tech/pi roles
56 # get passwords from a combination of site&name, perhaps?
57 # I'm guessing we could use the grpid or userid as part of the passwd,
58 # so that it varies in general, and can be guessed from the templates
61 ## Discovery Rules and Actions
62 # define a discovery rule for every site's hosts.
63 # define discovery action for online hosts.
65 ## Messages & Escalations
66 # define actions and escellations for trigger sources:
70 # add host group for every site
71 # add host group for global network (PLC name)
74 # no need to define hosts?
75 # add template? It appears that the xml-based tempate system is sufficient.