[ZBX-5464] zabbix can't get 0 from external script Created: 2012 Aug 17  Updated: 2017 May 30  Resolved: 2013 Feb 14

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Server (S)
Affects Version/s: 2.0.2
Fix Version/s: None

Type: Incident report Priority: Trivial
Reporter: sles Assignee: Unassigned
Resolution: Cannot Reproduce Votes: 0
Labels: externalchecks
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Centos 6.3/x86-64


Attachments: File 26052.tmp    

 Description   

If external script returns 0 then I see in zabbix server log:

19516:20120817:093623.552 item [Lud-cr2801-1:pingloss.sh[-c 20, -q, -B1, -r1, -b1500,

{HOST.CONN}]] became not supported: Received value [0]
is not suitable for value type [Numeric (float)]


If script returns 0.0 all is OK:

19516:20120817:095325.202 item [Lud-cr2801-1:pingloss.sh[-c 20, -q, -B1, -r1, -b1500, {HOST.CONN}

]] became supported

I think this is wrong.



 Comments   
Comment by sles [ 2012 Aug 17 ]

Oops!
0.0 is not always suitable too
19523:20120817:101257.060 item [Lud-cr2801-1:pingloss.sh[-c 20, -q, -B1, -r1, -b1500,

{HOST.CONN}

]] became not supported: Received value [0.0
] is not suitable for value type [Numeric (float)]

real situation is worse
although usually I see last value 0 in web frontend.

Comment by Alexander Vladishev [ 2012 Aug 21 ]

Zabbix doesn't log CR and LF characters in the message "Received value [....". Possibly your script returns an empty line(s) before a value.

Please reopen the issue if it not so.

Comment by sles [ 2012 Aug 21 ]

not so

[root@zabbix externalscripts]# ./pingloss.sh -c 20 -q -B1 -r1 -b1500 192.168.22.220
0.0
[root@zabbix externalscripts]#

Comment by sles [ 2012 Aug 21 ]

not so

Comment by Alexei Vladishev [ 2012 Aug 29 ]

Please attach pingloss.sh here if possible. Thanks.

Comment by sles [ 2012 Sep 10 ]

Here it is:

#!/bin/sh
#fping -c 1 -q -B1 -r1 -b1500 192.168.22.229 2>&1 | awk '

{ print $5 }' | awk -F "/" '{ print $3 }' | awk -F "%" '{p rint $1}'
fping $* 2>&1 | awk '{ print $5 }

' | awk -F "/" '

{ print $3 }

' | awk -F "%" '{if ($1 == 0)

{ print "0.0"}

else

{print $1}

}'

Thank you!

Comment by Andris Zeila [ 2013 Feb 05 ]

For me the following script works fine:

#!/bin/sh
fping -c 1 -q -B1 -r1 -b1500 $@ 2>&1 | awk '{ print $5 }' | awk -F "/" '{ print $3 }' | awk -F "%" '{print $1}'

It returns 0 which is read by server without problems. I checked the code - the decimal mark is not required for floating values.
Theoretically the reported problem could be a result of the script output containing unprintable characters, but I don't see how that could happen.

Comment by sles [ 2013 Feb 06 ]

checked logs-
still have the same problem with 2.0.5rc1:

705:20130206:061256.677 item [Lud-cr2801-1:pingloss.sh[-c 20, -q, -B1, -r1, -b1500,

{HOST.CONN}

]] became not supported: Received value [0.0
] is not suitable for value type [Numeric (float)]

Comment by Andris Zeila [ 2013 Feb 06 ]

One question - is there really line feed character in the logs, or it was just inserted during copying this line?

And another thing - could you pleas instead of copying pingloss.sh script output redirect to file and attach it here?

Comment by sles [ 2013 Feb 08 ]

Really it looks like:

Received value [0.0] is not suitable

so no line feed or carriage return here

Comment by sles [ 2013 Feb 08 ]

well, you are right, there is additional symbol at the end.
this is strange, I'll check what happens at Monday

Comment by Andris Zeila [ 2013 Feb 08 ]

Yes, strange. LF/CR characters at the end should have been stripped by server.

Comment by sles [ 2013 Feb 12 ]

I changed script to just
echo 0.0

and there is no such problem ( at least I can't reproduce it), I guess script returns non-digit values in some situations and zabbix info about 0.0 in log is wrong, i.e. real bug is what zabbix writes to log

Comment by Andris Zeila [ 2013 Feb 12 ]

There is a potential problem if fping produces multiple lines of output (although I can't imagine how that could happen with this example, but maybe occasionally there could be some error or whatever message). In that case if the first line contains less than 5 fields, then the script would give output;
<empty line>
0.0

Parser would fail because of the first empty line, but logger would strip the empty lines from message. This would lead to failed items with visually correct values in log files.

So the suggestion would be to ensure that your script produces only single line of output (with head or tail for example).

Comment by richlv [ 2013 Feb 12 ]

should parser strip leading whitespace, too ?

Comment by sles [ 2013 Feb 14 ]

Hello!

I added tail -n 1 to script, now I can't reproduce problem.
Thank you!

Comment by Andris Zeila [ 2013 Feb 14 ]

Great. Then I'm closing this one.

Generated at Wed Apr 24 06:52:25 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.