+# 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_agent2 default pidfile
+ test -n "$pidfile" || pidfile=/tmp/zabbix_agent2.pid
+ echo "$pidfile"
+}
+
+pidfile=$(get_pid /etc/zabbix/zabbix_agent2.conf)