[ZBX-18489] Setting custom PID file path in Server or Agent config file causes specified service cannot be started Created: 2020 Oct 13  Updated: 2021 Feb 03

Status: Need info
Project: ZABBIX BUGS AND ISSUES
Component/s: Agent (G), Server (S)
Affects Version/s: 5.0.3, 5.0.4
Fix Version/s: None

Type: Incident report Priority: Trivial
Reporter: Zoltan Nagy Assignee: Zabbix Support Team
Resolution: Unresolved Votes: 0
Labels: agent, problem, server, startup
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

CentOS 7, CentOS 8.1 in VMWare environment



 Description   

Steps to reproduce:

  1. Create a new directory anywhere on your system: mkdir /tmp/zabbix
  2. Set rights on this directory: chown -R zabbix:zabbix /tmp/zabbix
  3. Set rights on this directory: chmod -R 777 /tmp/zabbix
  4. Edit Zabbix agent configuration file: vim /etc/zabbix/zabbix_agentd.conf
  5. Change this line (comment out the original) PidFile=/tmp/zabbix/zabbix_agentd.pid
  6. Try to restart agent or server service: systemctl restart zabbix-agent
  7. After timeout you can read this in systemctl status zabbix-agent.service: Can't open PID file /run/zabbix/zabbix_agentd.pid (yet?)
  8. With original settings you can ran agent
  9. It happens also with Zabbix Server

Result:

systemctl status zabbix-agent.service

● zabbix-agent.service - Zabbix Agent
Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; enabled; vendor preset: disabled)
Active: activating (start) since Tue 2020-10-13 10:51:10 CEST; 13s ago
Process: 112891 ExecStop=/bin/kill -SIGTERM $MAINPID (code=exited, status=0/SUCCESS)
Process: 114998 ExecStart=/usr/sbin/zabbix_agentd -c $CONFFILE (code=exited, status=0/SUCCESS)
Main PID: 112549 (code=exited, status=0/SUCCESS)
Tasks: 6
CGroup: /system.slice/zabbix-agent.service
├─115000 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
├─115001 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
├─115002 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
├─115003 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
├─115004 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
└─115005 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]

Oct 13 10:51:10 myhost.tst.local systemd[1]: Starting Zabbix Agent...
Oct 13 10:51:10 myhost.tst.local systemd[1]: Can't open PID file /run/zabbix/zabbix_agentd.pid (yet?) a...tory
Hint: Some lines were ellipsized, use -l to show in full.

Expected:



 Comments   
Comment by Juris [ 2021 Feb 03 ]

Couldn't reproduce with 5.4.0alpha2 on a current Fedora 33:

jxl.spectre ~/scm/git/zabbix % grep -e '^PidFile' $HOME/.local/etc/zabbix_agentd.conf
PidFile=/tmp/zabbix/zabbix_agentd.pid
jxl.spectre ~/scm/git/zabbix % ls -ld /tmp/zabbix
drwxr-xr-x. 2 _zabbix _zabbix 40 Feb 3 12:08 /tmp/zabbix
jxl.spectre ~/scm/git/zabbix % sudo ./src/zabbix_agent/zabbix_agentd --foreground --config $HOME/.local/etc/zabbix_agentd.conf
Starting Zabbix Agent [Zabbix server]. Zabbix 5.4.0alpha2 (revision {ZABBIX_REVISION}).
Press Ctrl+C to exit.^Z
zsh: suspended sudo ./src/zabbix_agent/zabbix_agentd --foreground --config
jxl.spectre ~/scm/git/zabbix % bg
[1] + continued sudo ./src/zabbix_agentd/zabbix_agentd --foreground --config
jxl.spectre ~/scm/git/zabbix % ls -l /tmp/zabbix
total 4
rw-rw-r-. 1 _zabbix _zabbix 5 Feb 3 12:13 zabbix_agentd.pid
jxl.spectre ~/scm/git/zabbix % ps -fp `sudo cat /tmp/zabbix/zabbix_agentd.pid`
UID PID PPID C STIME TTY TIME CMD
_zabbix 19470 19468 0 12:13 pts/1 00:00:00 ./src/zabbix_agent/zabbix_agentd --foreground --config /home/jxl/.local/etc/zabbix_agentd.conf

and on OpenBSD 6.8 (-stable):

jxl.ph4nt0m ~/scm/git/zabbix % doas grep -e '^PidFile' /etc/zabbix/zabbix_agentd.conf
PidFile=/tmp/zabbix/zabbix_agentd.pid
jxl.ph4nt0m ~/scm/git/zabbix % \ls -ld /tmp/zabbix
{{drwxr-xr-x 2 _zabbix _zabbix 512 Feb 3 11:50 /tmp/zabbix
jxl.ph4nt0m ~/scm/git/zabbix % doas ./src/zabbix_agent/zabbix_agentd --foreground --config /etc/zabbix/zabbix_agentd.conf
Starting Zabbix Agent [Zabbix server]. Zabbix 5.4.0alpha2 (revision {ZABBIX_REVISION}).
Press Ctrl+C to exit.^Z
zsh: suspended doas ./src/zabbix_agent/zabbix_agentd --foreground --config
jxl.ph4nt0m ~/scm/git/zabbix % bg
[1] + continued doas ./src/zabbix_agent/zabbix_agentd --foreground --config
jxl.ph4nt0m ~/scm/git/zabbix % ls -l /tmp/zabbix
total 4
rw-rw-r- 1 _zabbix _zabbix 5 Feb 3 11:55 zabbix_agentd.pid
jsc.ph4nt0m ~ % ps -p `doas cat /tmp/zabbix/zabbix_agentd.pid`
PID TT STAT TIME COMMAND
8352 p3 I+ 0:00.03 ./src/zabbix_agent/zabbix_agentd --foreground --config /etc/zabbix/zabbix_agentd.conf

So forking and opening a pidfile works.

The output in your report indicates that the agent hasn't read the configuration, as it's still attempting to create the pidfile in it's run-time directory.

Does the agent user (zabbix) have the correct permissions to write to that directory? Where does the systemd service file come from? Does it use a PidFile= directive, that tries to monitor a different location?

Comment by Jurijs Klopovskis [ 2021 Feb 03 ]

Hi znagy,

Sorry for late response.

Have you also changes pid file path in the zabbix-agent systemd service file?

Comment by Jurijs Klopovskis [ 2021 Feb 03 ]

jxl, alpha2? It's not out yet

Comment by Juris [ 2021 Feb 03 ]

@yurii, sorry, that's a typo. Both tests were done with a build from 3de0b9cc.

EDIT: Now I get where I got the 2 from - the version banner in the output.

Generated at Thu Apr 24 07:23:07 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.