[ZBX-8893] Zabbix Agentd always return code 0 Created: 2014 Oct 13  Updated: 2019 Dec 10

Status: Open
Project: ZABBIX BUGS AND ISSUES
Component/s: Agent (G)
Affects Version/s: 2.4.0
Fix Version/s: None

Type: Incident report Priority: Trivial
Reporter: Christian Reizlein Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux



 Description   

zabbix agentd always return code 0 when started regardless it failed or not, making it really hard to code a proper init script and tell exactly if process started or not.

I have created of test scenario where i make it fail to start by finding to a used port, but the return code is always 0, it should be 1 at least

Example on how to reproduce:

zabbix@hostname:/opt/zabbix/test/sbin > ./zabbix_agentd -c /opt/zabbix/test/etc/zabbix_agentd.conf
zabbix@hostname:/opt/zabbix/test/sbin > echo $?      
0  

At this point you should think it succeded, but it failed

zabbix@hostname:/opt/zabbix/test/sbin > tail ../logs/zabbix_agentd.log 
   319:20141013:150151.826 listener failed: bind() for [[-]:10050] failed: [98] Address already in use



 Comments   
Comment by Christian Reizlein [ 2014 Oct 14 ]

This will probably also affect zabbix_server and proxy daemon, i will try to replicate the same scenario and launch a second process or try to bind to a used port or with a invalid configuration file and see if it returns 0 or 1.

Comment by Christian Reizlein [ 2014 Oct 14 ]

I have made some more testing with zabbix_server and _proxy and both act the same.
No matter if the process can start or not it always return 0, here is an example when trying to start zabbix_server for a second time when its already running..

zabbix@hostname:/apps/zabbix/stable > ./sbin/zabbix_server -c /apps/zabbix/stable/etc/zabbix_server.conf
zabbix@hostname:/apps/zabbix/stable > echo $? 
0
zabbix@hostname:/apps/zabbix/stable > tail logs/zabbix_server.log 
zabbix_server [30026]: Is this process already running? Could not lock PID file [/apps/zabbix/stable/zabbix_server.pid]: [11] Resource temporarily unavailable

The reason im looking at this is that im setting up a HA environment and having an accurate init script that actually tells if the process has started or not and returns the proper return code is crucial, right now all the init scripts i have found always return OK whenever the zabbix starts or not..

Comment by Andris Zeila [ 2014 Oct 31 ]

When starting a Zabbix daemon (agentd, server, proxy) does the following:

  1. parses command line
  2. loads configuration file
  3. forks the daemon process
  4. exits

Now if it can't do any of first three steps it will exit with an error. But after the daemon has been succesfully forked the starting process can't do anyting more than exit with a success code. And the errors related to port opening will occur in the daemon after it has been forked.

Comment by Christian Reizlein [ 2014 Oct 31 ]

Andris, that does make a bit of sense, that's the reason why the daemon processes always return success (they always fork the threads, regardless if they start or not) but i think that's a big mistake/bug... there is no accurate way to check if the processes has trully started or not, rather than manually do a ps -ef or something which is annoying...

Comment by Alexander Vladishev [ 2014 Dec 03 ]

Related issue: ZBXNEXT-611

Comment by Oleksii Zagorskyi [ 2016 Apr 27 ]

ZBX-10717 is very related, or even duplicate, but has some specific details.

Comment by Oleksii Zagorskyi [ 2016 May 02 ]

ZBX-10695 could be another use case, but should be checked.

Generated at Mon Apr 07 00:20:11 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.