Hi,

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

Should I breakdown this patch into smaller parts?

Signed-off-by: Stefan Hellermann <ste...@the2masters.de>


Index: admin/zabbix/files/zabbix_agentd.init
===================================================================
--- admin/zabbix/files/zabbix_agentd.init       (Revision 33885)
+++ admin/zabbix/files/zabbix_agentd.init       (Arbeitskopie)
@@ -3,23 +3,31 @@
 
 START=60
 
-SERVICE_PID_FILE=/var/run/zabbix/zabbix_agentd.pid
+PROG=/usr/sbin/zabbix_agentd
+CONFIG=/etc/zabbix_agentd.conf
+SERVICE_PID_FILE=/var/run/zabbix_agentd.pid
 
 start() {
-       [ -f /etc/zabbix/zabbix_agentd.conf ] || return 1
-       user_exists zabbix 53 || user_add zabbix 53
-       group_exists zabbix 53 || group_add zabbix 53
-       [ -d /var/log/zabbix ] || {
-               mkdir -m0755 -p /var/log/zabbix
-               chown zabbix:zabbix /var/log/zabbix
+       # 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
        }
-       [ -d /var/run/zabbix ] || {
-               mkdir -m0755 -p /var/run/zabbix
-               chown zabbix:zabbix /var/run/zabbix
+
+       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}
        }
-       service_start /usr/sbin/zabbix_agentd
+
+       service_start ${PROG} -c ${CONFIG}
 }
 
 stop() {
-       service_stop /usr/sbin/zabbix_agentd
+       service_stop ${PROG}
 }
Index: admin/zabbix/patches/010-change-agentd-config.patch
===================================================================
--- admin/zabbix/patches/010-change-agentd-config.patch (Revision 0)
+++ admin/zabbix/patches/010-change-agentd-config.patch (Arbeitskopie)
@@ -0,0 +1,54 @@
+diff --git a/conf/zabbix_agentd.conf b/conf/zabbix_agentd.conf
+index ed04751..e714c4d 100644
+--- a/conf/zabbix_agentd.conf
++++ b/conf/zabbix_agentd.conf
+@@ -3,12 +3,8 @@
+ 
+ ############ GENERAL PARAMETERS #################
+ 
+-### Option: PidFile
+-#     Name of PID file.
+-#
+-# Mandatory: no
+-# Default:
+-# PidFile=/tmp/zabbix_agentd.pid
++# Only /var/run/zabbix_agentd.pid supported
++PidFile=/var/run/zabbix_agentd.pid
+ 
+ ### Option: LogFile
+ #     Name of log file.
+@@ -18,8 +14,6 @@
+ # Default:
+ # LogFile=
+ 
+-LogFile=/tmp/zabbix_agentd.log
+-
+ ### Option: LogFileSize
+ #     Maximum size of log file in MB.
+ #     0 - disable automatic log rotation.
+@@ -105,6 +99,7 @@ Server=127.0.0.1
+ # Range: 0-100
+ # Default:
+ # StartAgents=3
++StartAgents=1
+ 
+ ##### Active checks related
+ 
+@@ -120,8 +115,6 @@ Server=127.0.0.1
+ # Default:
+ # ServerActive=
+ 
+-ServerActive=127.0.0.1
+-
+ ### Option: Hostname
+ #     Unique, case sensitive hostname.
+ #     Required for active checks and must match hostname as configured on the 
server.
+@@ -131,8 +124,6 @@ ServerActive=127.0.0.1
+ # Default:
+ # Hostname=
+ 
+-Hostname=Zabbix server
+-
+ ### Option: HostnameItem
+ #     Item used for generating Hostname if it is undefined.
+ #     Ignored if Hostname is defined.
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to