packages/admin/zabbix/files/zabbix_agentd.init

34 lines
825 B
Plaintext
Raw Normal View History

#!/bin/sh /etc/rc.common
# Copyright (C) 2008-2011 OpenWrt.org
START=60
zabbix: correct pidfile und update initscript zabbix_agentd will not start because the initscript checks an old path to the configfile and then zabbix_agentd uses the new path. (old /etc/zabbix/zabbix_agentd.conf new /etc/zabbix_agentd.conf) I think the new path is better as most people have only one zabbix tool installed on their embedded device. Further there is a problem with the pid-file: zabbix creates it by default in /tmp, and the init script creates a folder in /var/run/zabbix where the pid-file is expected. start-stop-daemon will not find the pid-file and cannot stop zabbix_agentd. So I changed the initscript and conffile to use the same pid-file. I actually chose /var/run/zabbix_agentd.conf instead of creating a subfolder or use /tmp. While doing that I redid the whole initscript and changed additionally: - move conffile to new location if is in the location from before changeset #32497 - only create zabbix users if there is no AllowRoot=1 in config - only support the pid-file path /var/run/zabbix_agentd.pid, check it in initscript and warn if it is changed. - don't log to a file in /tmp, but use syslog - only start one passive check agent instead of default 3 - don't search actively for a zabbix-server on 127.0.0.1 - don't set the hostname to "Zabbix server" but use system.hostname Signed-off-by: Stefan Hellermann <stefan@the2masters.de> Signed-off-by: Florian Fainelli <florian@openwrt.org> git-svn-id: svn://svn.openwrt.org/openwrt/packages@34492 3c298f89-4303-0410-b956-a3cf2f4a3e73
2012-12-04 16:21:02 +00:00
PROG=/usr/sbin/zabbix_agentd
CONFIG=/etc/zabbix_agentd.conf
SERVICE_PID_FILE=/var/run/zabbix_agentd.pid
start() {
zabbix: correct pidfile und update initscript zabbix_agentd will not start because the initscript checks an old path to the configfile and then zabbix_agentd uses the new path. (old /etc/zabbix/zabbix_agentd.conf new /etc/zabbix_agentd.conf) I think the new path is better as most people have only one zabbix tool installed on their embedded device. Further there is a problem with the pid-file: zabbix creates it by default in /tmp, and the init script creates a folder in /var/run/zabbix where the pid-file is expected. start-stop-daemon will not find the pid-file and cannot stop zabbix_agentd. So I changed the initscript and conffile to use the same pid-file. I actually chose /var/run/zabbix_agentd.conf instead of creating a subfolder or use /tmp. While doing that I redid the whole initscript and changed additionally: - move conffile to new location if is in the location from before changeset #32497 - only create zabbix users if there is no AllowRoot=1 in config - only support the pid-file path /var/run/zabbix_agentd.pid, check it in initscript and warn if it is changed. - don't log to a file in /tmp, but use syslog - only start one passive check agent instead of default 3 - don't search actively for a zabbix-server on 127.0.0.1 - don't set the hostname to "Zabbix server" but use system.hostname Signed-off-by: Stefan Hellermann <stefan@the2masters.de> Signed-off-by: Florian Fainelli <florian@openwrt.org> git-svn-id: svn://svn.openwrt.org/openwrt/packages@34492 3c298f89-4303-0410-b956-a3cf2f4a3e73
2012-12-04 16:21:02 +00:00
# Sometimes the agentd config was installed in /etc/zabbix/zabbix_agentd.conf
[ -f /etc/zabbix/zabbix_agentd.conf ] && mv /etc/zabbix/zabbix_agentd.conf ${CONFIG}
[ -f ${CONFIG} ] || return 1
grep -q "^PidFile=${SERVICE_PID_FILE}" ${CONFIG} || {
logger -s -t ${CONFIG} -p daemon.error "Only \"PidFile=${SERVICE_PID_FILE}\" supported"
return 1
}
zabbix: correct pidfile und update initscript zabbix_agentd will not start because the initscript checks an old path to the configfile and then zabbix_agentd uses the new path. (old /etc/zabbix/zabbix_agentd.conf new /etc/zabbix_agentd.conf) I think the new path is better as most people have only one zabbix tool installed on their embedded device. Further there is a problem with the pid-file: zabbix creates it by default in /tmp, and the init script creates a folder in /var/run/zabbix where the pid-file is expected. start-stop-daemon will not find the pid-file and cannot stop zabbix_agentd. So I changed the initscript and conffile to use the same pid-file. I actually chose /var/run/zabbix_agentd.conf instead of creating a subfolder or use /tmp. While doing that I redid the whole initscript and changed additionally: - move conffile to new location if is in the location from before changeset #32497 - only create zabbix users if there is no AllowRoot=1 in config - only support the pid-file path /var/run/zabbix_agentd.pid, check it in initscript and warn if it is changed. - don't log to a file in /tmp, but use syslog - only start one passive check agent instead of default 3 - don't search actively for a zabbix-server on 127.0.0.1 - don't set the hostname to "Zabbix server" but use system.hostname Signed-off-by: Stefan Hellermann <stefan@the2masters.de> Signed-off-by: Florian Fainelli <florian@openwrt.org> git-svn-id: svn://svn.openwrt.org/openwrt/packages@34492 3c298f89-4303-0410-b956-a3cf2f4a3e73
2012-12-04 16:21:02 +00:00
grep -q "^AllowRoot=1" ${CONFIG} || {
user_exists zabbix 53 || user_add zabbix 53
group_exists zabbix 53 || group_add zabbix 53
touch ${SERVICE_PID_FILE}
chown zabbix:zabbix ${SERVICE_PID_FILE}
}
zabbix: correct pidfile und update initscript zabbix_agentd will not start because the initscript checks an old path to the configfile and then zabbix_agentd uses the new path. (old /etc/zabbix/zabbix_agentd.conf new /etc/zabbix_agentd.conf) I think the new path is better as most people have only one zabbix tool installed on their embedded device. Further there is a problem with the pid-file: zabbix creates it by default in /tmp, and the init script creates a folder in /var/run/zabbix where the pid-file is expected. start-stop-daemon will not find the pid-file and cannot stop zabbix_agentd. So I changed the initscript and conffile to use the same pid-file. I actually chose /var/run/zabbix_agentd.conf instead of creating a subfolder or use /tmp. While doing that I redid the whole initscript and changed additionally: - move conffile to new location if is in the location from before changeset #32497 - only create zabbix users if there is no AllowRoot=1 in config - only support the pid-file path /var/run/zabbix_agentd.pid, check it in initscript and warn if it is changed. - don't log to a file in /tmp, but use syslog - only start one passive check agent instead of default 3 - don't search actively for a zabbix-server on 127.0.0.1 - don't set the hostname to "Zabbix server" but use system.hostname Signed-off-by: Stefan Hellermann <stefan@the2masters.de> Signed-off-by: Florian Fainelli <florian@openwrt.org> git-svn-id: svn://svn.openwrt.org/openwrt/packages@34492 3c298f89-4303-0410-b956-a3cf2f4a3e73
2012-12-04 16:21:02 +00:00
service_start ${PROG} -c ${CONFIG}
}
stop() {
zabbix: correct pidfile und update initscript zabbix_agentd will not start because the initscript checks an old path to the configfile and then zabbix_agentd uses the new path. (old /etc/zabbix/zabbix_agentd.conf new /etc/zabbix_agentd.conf) I think the new path is better as most people have only one zabbix tool installed on their embedded device. Further there is a problem with the pid-file: zabbix creates it by default in /tmp, and the init script creates a folder in /var/run/zabbix where the pid-file is expected. start-stop-daemon will not find the pid-file and cannot stop zabbix_agentd. So I changed the initscript and conffile to use the same pid-file. I actually chose /var/run/zabbix_agentd.conf instead of creating a subfolder or use /tmp. While doing that I redid the whole initscript and changed additionally: - move conffile to new location if is in the location from before changeset #32497 - only create zabbix users if there is no AllowRoot=1 in config - only support the pid-file path /var/run/zabbix_agentd.pid, check it in initscript and warn if it is changed. - don't log to a file in /tmp, but use syslog - only start one passive check agent instead of default 3 - don't search actively for a zabbix-server on 127.0.0.1 - don't set the hostname to "Zabbix server" but use system.hostname Signed-off-by: Stefan Hellermann <stefan@the2masters.de> Signed-off-by: Florian Fainelli <florian@openwrt.org> git-svn-id: svn://svn.openwrt.org/openwrt/packages@34492 3c298f89-4303-0410-b956-a3cf2f4a3e73
2012-12-04 16:21:02 +00:00
service_stop ${PROG}
}