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)
44 # TODO: for any site that is in the db, call zabbixsite.delete_site()
48 # no need to define hosts?
49 # add template? It appears that the xml-based tempate system is sufficient.