X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=zabbix%2Fzabbixsync.py;h=fd2126e7179cc06704d21c95159e2b9bf16e6674;hb=170be1fae6fd5956641668443245c50fbf7fd566;hp=8c078e78f9748302785acd6ed63e1134de80a3c1;hpb=ac841d414d7b09f8a0b7883bcdba0eeb6aede69f;p=monitor.git diff --git a/zabbix/zabbixsync.py b/zabbix/zabbixsync.py index 8c078e7..fd2126e 100755 --- a/zabbix/zabbixsync.py +++ b/zabbix/zabbixsync.py @@ -37,39 +37,30 @@ def add_loginbase(loginbase): zabbixsite.setup_site(loginbase, techs, pis, iplist) if __name__=="__main__": - #sites = api.GetSites({'peer_id' : None}, ['login_base']) - for loginbase in ['princeton', 'princetondsl', 'monitorsite']: - add_loginbase(loginbase) - session.flush() + from monitor import parser as parsermodule + parser = parsermodule.getParser() + parser.set_defaults( setupglobal=False, syncsite=True, site=None) + parser.add_option("", "--setupglobal", action="store_true", dest="setupglobal", + help="Setup global settings.") + parser.add_option("", "--nosite", action="store_true", dest="syncsite", + help="Do not sync sites.") + parser.add_option("", "--site", dest="site", + help="Sync only given site name.") + opts = parsermodule.parse_args(parser) -## Scripts : includes external scripts to: -# - reboot.py -# - nmap + if opts.setupglobal: + zabbixsite.setup_global() -## UserGroups -# define technical contact, principal investigator groups -# define a Group for every site + if opts.syncsite: + query = {'peer_id' : None} + if opts.site: + query.update({'login_base' : opts.site}) -## Users -# define a User for every user with admin/tech/pi roles -# get passwords from a combination of site&name, perhaps? -# I'm guessing we could use the grpid or userid as part of the passwd, -# so that it varies in general, and can be guessed from the templates -# add user to groups + sites = api.GetSites(query, ['login_base']) + for site in sites: + add_loginbase(site['login_base']) + session.flush() -## Discovery Rules and Actions -# define a discovery rule for every site's hosts. -# define discovery action for online hosts. + # TODO: for any removed site that is in the db, call zabbixsite.delete_site() -## Messages & Escalations -# define actions and escellations for trigger sources: -# - unreachable host, - -## HostGroups -# add host group for every site -# add host group for global network (PLC name) - -## Hosts & Templates -# no need to define hosts? -# add template? It appears that the xml-based tempate system is sufficient.