summaryrefslogtreecommitdiff
path: root/net-mgmt/zabbix32-server/files/zabbix_agentd.in
diff options
context:
space:
mode:
Diffstat (limited to 'net-mgmt/zabbix32-server/files/zabbix_agentd.in')
-rw-r--r--net-mgmt/zabbix32-server/files/zabbix_agentd.in55
1 files changed, 55 insertions, 0 deletions
diff --git a/net-mgmt/zabbix32-server/files/zabbix_agentd.in b/net-mgmt/zabbix32-server/files/zabbix_agentd.in
new file mode 100644
index 000000000000..12dff564ac47
--- /dev/null
+++ b/net-mgmt/zabbix32-server/files/zabbix_agentd.in
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+# PROVIDE: zabbix_agentd
+# REQUIRE: DAEMON
+# KEYWORD: shutdown
+#
+# Add the following lines to /etc/rc.conf.local or /etc/rc.conf to
+# enable zabbix_agentd:
+#
+# zabbix_agentd_enable (bool): Set to NO by default. Set it to YES to
+# enable zabbix_agentd.
+# zabbix_agentd_config (string): Set to the standard config file path by
+# default.
+# zabbix_agentd_pidfile (string): Location of the zabbix_agent pid file
+# Default is /var/run/zabbix/zabbix_agentd.pid
+#
+
+. /etc/rc.subr
+
+name="zabbix_agentd"
+rcvar=zabbix_agentd_enable
+
+load_rc_config $name
+
+: ${zabbix_agentd_enable:=NO}
+: ${zabbix_agentd_config:=%%ETCDIR%%/${name}.conf}
+: ${zabbix_agentd_pidfile:=/var/run/zabbix/zabbix_agentd.pid}
+
+command="%%PREFIX%%/sbin/${name}"
+required_files="${zabbix_agentd_config}"
+
+start_precmd=zabbix_agentd_precmd
+status_precmd=zabbix_agentd_precmd
+stop_precmd=zabbix_agentd_precmd
+
+zabbix_agentd_precmd()
+{
+ if get_pidfile_from_conf PidFile ${zabbix_agentd_config}; then
+ pidfile="$_pidfile_from_conf"
+ else
+ pidfile=${zabbix_agentd_pidfile}
+ local rundir=${zabbix_agentd_pidfile%/*}
+ if [ ! -d $rundir ] ; then
+ install -d -m 0755 -o zabbix -g zabbix $rundir
+ fi
+ fi
+
+ # This shouldn't be necessary with pidfile, but empirically it was the
+ # only way to reap the parent PID instead of all PIDs from
+ # check_process, which may leak SysV IPC objects and prevent restart
+ # and/or race condition on restart.
+ rc_pid=$(check_pidfile ${pidfile} ${command})
+}
+
+run_rc_command "$1"