X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=zabbix%2Fzabbixsite.py;h=e3bcfb43632053bfcf072267547af0ecf965b1b4;hb=a06427d1c9506ee93888e8f2f80b6c4bdd134527;hp=678c7567a4b1f0fb22c1e1ccb18e813895f67068;hpb=19ba97634589f5cce3719dbe0f96d94e3e148e1d;p=monitor.git diff --git a/zabbix/zabbixsite.py b/zabbix/zabbixsite.py index 678c756..e3bcfb4 100755 --- a/zabbix/zabbixsite.py +++ b/zabbix/zabbixsite.py @@ -4,12 +4,14 @@ from os import getcwd from os.path import dirname, exists, join import sys import md5 +import glob from monitor import config from monitor.database.dborm import zab_session as session from monitor.database.zabbixapi.model import * from monitor.database.zabbixapi.emailZabbix import * from monitor.database.zabbixapi import defines +from monitor.util.file import * @@ -88,15 +90,20 @@ def setup_global(): print "checking zabbix server host info" zabbixserver = Host.get_by(host="ZABBIX Server") if zabbixserver: - print "UPDATING Primary Zabbix server entry" - zabbixserver.host=config.MONITOR_HOSTNAME - zabbixserver.ip=config.MONITOR_IP - zabbixserver.dns=config.MONITOR_HOSTNAME - zabbixserver.useip=1 + print "Removing default Zabbix server entry" + zabbixserver.delete() + + # NOTE: creating a host and assigning a template cannot work + # due to the crazy item, trigger, action + # copying that the php code does during a host add. + # NOTE: Instead, reformat any *xml.in templates and import those + # during /etc/plc.d/monitor sync + for file in glob.glob("/usr/share/monitor/templates/*.xml.in"): + if 'zabbix_server' in file: + buf = loadFile(file) + args = {'hostname' : config.MONITOR_HOSTNAME, 'ip' : config.MONITOR_IP} + dumpFile(file[:-3], buf % args) - ############################ DEFAULT TEMPLATES - # pltemplate - via web, xml import - # TODO: os.system("curl --post default_templates.xml") ##################### SCRIPTS ## TODO: add calls to check/reset the boot states. @@ -143,7 +150,7 @@ def setup_site(loginbase, techemail, piemail, iplist): # HOST GROUP plc_host_group = HostGroup.find_or_create(name="MyPLC Hosts") site_host_group = HostGroup.find_or_create(name=HOSTGROUP_NAME % loginbase) - plctemplate = Host.get_by(host="Template_Linux_PLHost") + plctemplate = Host.get_by(host="Template_Linux_PLC_Host") escalation_action_name = ESCALATION_ACTION_NAME % loginbase discovery_action_name = DISCOVERY_ACTION_NAME % loginbase discovery_rule_name = DISCOVERY_RULE_NAME % loginbase