Hi guys.
I have a script that checks an API status using curl. When manually executing the script on the Zabbix Server box, it works.
The script:
Output:
However, when creating an external check and using the same script, the Latest Data reports me the "api_check_ping" function is blank; as follow.
Output from the Latest Data page:
ERROR: api_check_ping is down Zabbix_server log:
What am I doing wrong? Why does the script work when manually running but the Latest data page reports otherwise? Thanks in advance.
I have a script that checks an API status using curl. When manually executing the script on the Zabbix Server box, it works.
Code:
/usr/lib/zabbix/externalscripts/api_services_status.sh "api_check_ping"
Code:
#!/bin/sh
set -x
api_check_ping=$(curl --cert cert_prod.pem -s https://api.example.com/Ping/1.0 | tr '<|/' '\n' | grep ^service | grep -e $1 | awk '{print $3}')
if [ $1 = 'api_check_ping' ];
then
if [ "${api_check_ping}" != 'status="up"' ]; then
echo "ERROR: $1 is down"
else
echo "SUCCESS: $1 is UP"
fi
fi
Code:
SUCCESS: api_check_ping is UP
Output from the Latest Data page:
Code:
++ curl --cert cert_prod.pem -s https://api.example.com/Ping/1.0
++ tr '<|/' '\n' ++ awk '{print $3}'
++ grep -e api_check_ping
++ grep '^service'
+ api_check_ping=
+ '[' api_check_ping = api_check_ping ']'
+ '[' '' '!=' 'status="up"' ']'
+ echo 'ERROR: api_check_ping is down'
Code:
20631:20180615:155441.823 In get_value() key:'api_services_status.sh["api_check_ping"]' 20631:20180615:155441.824 In get_value_external() key:'api_services_status.sh["api_check_ping"]' 20631:20180615:155441.824 In zbx_popen() command:'/usr/lib/zabbix/externalscripts/api_services_status.sh "api_check_ping"'
What am I doing wrong? Why does the script work when manually running but the Latest data page reports otherwise? Thanks in advance.
Comment