# Get service config - may override defaults
[ -f /etc/sysconfig/zabbix_agentd ] && . /etc/sysconfig/zabbix_agentd
-pidfile="/var/run/zabbix/zabbix_agentd.pid"
+# Try to get configured PidFile or set default
+get_pid() {
+ local config="$1"
+ local pidfile
+ test -f "$config" && pidfile=$(awk -F= '/^ *PidFile/ {print $2}' "$config")
+ # Fallback to zabbix_agentd default pidfile
+ test -n "$pidfile" || pidfile=/var/run/zabbix/zabbix_agentd.pid
+ echo "$pidfile"
+}
+
+pidfile=$(get_pid /etc/zabbix/zabbix_agentd.conf)
start() {
# Check if the service is already running?
# Get service config - may override defaults
[ -f /etc/sysconfig/zabbix_proxy ] && . /etc/sysconfig/zabbix_proxy
-pidfile="/var/run/zabbix/zabbix_proxy.pid"
+# Try to get configured PidFile or set default
+get_pid() {
+ local config="$1"
+ local pidfile
+ test -f "$config" && pidfile=$(awk -F= '/^ *PidFile/ {print $2}' "$config")
+ # Fallback to zabbix_proxy default pidfile
+ test -n "$pidfile" || pidfile=/var/run/zabbix/zabbix_proxy.pid
+ echo "$pidfile"
+}
+
+pidfile=$(get_pid /etc/zabbix/zabbix_proxy.conf)
start() {
# Check if the service is already running?
# Set default shutdown timeout if it is not set in service config
ZABBIX_SHUTDOWN_TIMEOUT=${ZABBIX_SHUTDOWN_TIMEOUT:-60}
-pidfile="/var/run/zabbix/zabbix_server.pid"
+# Try to get configured PidFile or set default
+get_pid() {
+ local config="$1"
+ local pidfile
+ test -f "$config" && pidfile=$(awk -F= '/^ *PidFile/ {print $2}' "$config")
+ # Fallback to zabbix_server default pidfile
+ test -n "$pidfile" || pidfile=/var/run/zabbix/zabbix_server.pid
+ echo "$pidfile"
+}
+
+pidfile=$(get_pid /etc/zabbix/zabbix_server.conf)
start() {
# Check if the service is already running?