[ZBX-12594] Not possible to ignore exit codes of scripts which may result in unsupported state Created: 2017 Aug 24 Updated: 2024 Apr 10 Resolved: 2017 Oct 11 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | Server (S) |
Affects Version/s: | 3.4.0 |
Fix Version/s: | 3.4.3rc1, 4.0.0alpha1, 4.0 (plan) |
Type: | Problem report | Priority: | Major |
Reporter: | sles | Assignee: | Vladislavs Sokurenko |
Resolution: | Fixed | Votes: | 5 |
Labels: | exitcodes, scripts, unsupported, userparameters | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified | ||
Environment: |
Centos 7 |
Issue Links: |
|
||||||||||||||||
Team: | Team A | ||||||||||||||||
Sprint: | Sprint 17, Sprint 18 | ||||||||||||||||
Story Points: | 1 |
Description |
Since 3.4 exit code for scripts is checked, it means that some scripts will now become unsupported, for example grep:
So it is expected that some commands should not become unsupported on some error codes. UserParameter examples are also broken. Current workaround to make default example work is to change following user parameter: mailq UserParameter=unix_mail.queue,mailq | grep -v "Mail queue is empty" | grep -c '^[0-9A-Z]' To: UserParameter=unix_mail.queue,mailq | grep -v "Mail queue is empty" | grep -c '^[0-9A-Z]' || true MySQL UserParameter=mysql.ping,mysqladmin -uroot ping | grep -c alive To: UserParameter=mysql.ping,mysqladmin -uroot ping | grep alive | wc -l |
Comments |
Comment by Vladislavs Sokurenko [ 2017 Aug 24 ] |
thank you for the report, could you please provide steps to reproduce ? |
Comment by sles [ 2017 Aug 24 ] |
Yes, it is UserParameter, UserParameter=tcp.p8530,cmd.exe /C netstat -n -p TCP | find /c ":8530" Command itself returns 0: if no connections. But [m|ZBX_NOTSUPPORTED] [0 So problem is on agent, not server side, sorry for wrong component, please change it. What is strange here is that non-zero values are OK. btw, just echo is OK: UserParameter=zero,cmd.exe /C "echo 0" C:\zabbix>zabbix_agentd.exe -c C:\zabbix\zabbix_agentd.conf -t zero Thank you! vso thanks, please also do zabbix_agentd --version |
Comment by sles [ 2017 Aug 24 ] |
C:\zabbix>zabbix_agentd.exe --version |
Comment by Vladislavs Sokurenko [ 2017 Aug 24 ] |
Please try printing exit code after you execute command manually echo Exit Code is %errorlevel% |
Comment by sles [ 2017 Aug 24 ] |
Another port, because there are connections on 8530: C:\zabbix>netstat -n | find /c ":8531" & echo %errorlevel% Due to command/script exit code check introduction in Zabbix 3.4, alertscripts can be executed multiple times if their exit code is different from 0. Previously configured items with user parameters executed by Zabbix server, external check items, and system.run items which exit code is not 0 may become “Not supported” due to additional checks for exit code, behavior of the items with “nowait” flag is not changed though. |
Comment by sles [ 2017 Aug 24 ] |
btw, it works on another server usnig older agent: C:\zabbix>zabbix_agentd.exe --version result of command is the same C:\zabbix>netstat -ano | find "190:81" | find /c "ESTAB" & echo %errorlevel% |
Comment by sles [ 2017 Aug 24 ] |
Well, and how return previous behavior? |
Comment by Vladislavs Sokurenko [ 2017 Aug 24 ] |
No indication of a bug. Closing as Won't Fix. |
Comment by sles [ 2017 Aug 24 ] |
script is not failed! |
Comment by sles [ 2017 Aug 24 ] |
It IS bug! |
Comment by sles [ 2017 Aug 24 ] |
btw, why are you editing my comments instead of reply? |
Comment by Glebs Ivanovskis (Inactive) [ 2017 Aug 24 ] |
Is there a newline in script's output? |
Comment by sles [ 2017 Aug 24 ] |
One can't rely on errorlevel as script success or fail, this is wrong. |
Comment by Vladislavs Sokurenko [ 2017 Aug 24 ] |
please try if exit 0 helps and get back to us, thanks ! |
Comment by sles [ 2017 Aug 24 ] |
yes, exit 0 "solves" issue, but this is workaround, not solution- |
Comment by sles [ 2017 Aug 24 ] |
I'd like to add - if you add new features good idea is provide compatibility. Really, I don't see any reasons to retry script, one who needs this can write script which do such retries internally, in this script. Thank you! |
Comment by Vjaceslavs Bogdanovs [ 2017 Aug 25 ] |
Well, I understand your point, but it was decided to make things simpler and not to introduce additional item and configuration params.
So this is a feature and not a bug as it is working the way it was planned. If you really think that better solution would be introducing additional params to item and/or config, then you can create a feature request for that. |
Comment by sles [ 2017 Aug 25 ] |
Bug is not always wrong implementation, sometimes bug is wrong idea/way to implement |
Comment by Andrea Biscuola (Inactive) [ 2017 Sep 18 ] |
REOPENED This bug cause items to be "not supported" for exit statuses that are different than 0 BUT are NOT error conditions. For example: EXIT STATUS 0 One or more lines were selected. This is clearly part of the POSIX standard and zabbix does not respect this (possible) behavior. Also, grep is actually not the only standard utility having this possibility
|
Comment by Dmitry Verkhoturov [ 2017 Sep 18 ] |
3.4.1 source code have UserParameters examples which are broken that way - grep -c will return exit code 1 in case of line not found: ➜ zabbix$ egrep "UserParameter.grep.\s-\S*c" . -r |
Comment by Frederic Perrouin [ 2017 Sep 18 ] |
As a workaround for unix_mail.queue userparameter, I put this: UserParameter=unix_mail.queue,mailq | grep -v "Mail queue is empty" | grep -c '^[0-9A-Z]' || true. |
Comment by richlv [ 2017 Sep 18 ] |
i'm with abs on this one - it breaks a lot of existing implementations and adds an unnecessary burden on the user. |
Comment by sles [ 2017 Sep 18 ] |
> it breaks a lot of existing implementations and adds an unnecessary burden on the user. to not break existing previous ( pre 3.4) behaviour has to be default. thank you! |
Comment by Andrea Biscuola (Inactive) [ 2017 Sep 19 ] |
vso "Not well behaved scripts" is incorrect. As the POSIX and SUS specs does not give a final rule but a set of conventions regarding the exit status, also documenting the exit status of all the standard utilities. Please correct it in something like: "Not possible to ignore exit status different than 0 which result in unsupported state even if the script is correct." |
Comment by Vitaly Zhuravlev [ 2017 Sep 25 ] |
Another example where smartctl utility returns non zero exit code when harddrive is failed:
|
Comment by Vladislavs Sokurenko [ 2017 Sep 26 ] |
Suggested solution is to introduce EnableExitCodeChecks parameter in configuration file of zabbix server, proxy and agent. On Server/Proxy it will control external checks, while on agent it will take care of user parameter exit code checks. New flag wexit should be added to system.run mode, it will enable exit code checks while wait mode will not check for exit code. |
Comment by Vladislavs Sokurenko [ 2017 Oct 04 ] |
What if we revert exit code checks for external checks, system.run and user parameters ? |
Comment by Alexander Vladishev [ 2017 Oct 04 ] |
Yes, please revert these changes. External checks, system.run and user parameters should not support check of exit code. |
Comment by Vjaceslavs Bogdanovs [ 2017 Oct 09 ] |
Server side tested |
Comment by Vladislavs Sokurenko [ 2017 Oct 09 ] |
Fixed in:
|
Comment by Vladislavs Sokurenko [ 2017 Oct 09 ] |
Fixed system.run, user parameter and external check not to become unsupported when exit code is different than zero |
Comment by sles [ 2017 Oct 19 ] |
3.4.3 is out, but only 3.4.0 precompiled agent for windows is available from downloads.... Thank you! |
Comment by Daniel Daniel [ 2018 Aug 08 ] |
Hi, pls, why aren't there newer versions of agents for non-Windows platforms available to download in https://www.zabbix.com/download_agents ? |