Hello,
I am working on setting up a UserParameter to monitor our Cantaloupe IIIF server (v.4.1) by simply grabbing a localhost webpage via curl and looking for a string in the result. As the server (Zabbix 5.0.31 (Zabbix repo)) sits in a different firewall zone than the client (Zabbix agent 5.0.21 (EPEL repo)) we don't want to open up a firewall rule to allow direct monitoring of the Cantaloupe IIIF server via web requests from the Zabbix server. Instead we are looking to a real simple local script and UserParameter to achieve this. The simple script "check_url" is as follows and it takes two parameters, the URL to question (generally http://localhost:8182/health for the Cantaloupe health) and the string to look for - in our case the word "color". The output of the curl command results in JSON output as shown below:
Cantaloupe /health output:
check_url script:
When run from the command line the exit and echo work as expected. The first value returned is from the script, the 2nd value returned is the return code from the script.
When run from the zabbix_get command from the Zabbix server the cmd_result does not reflect either the exit value or the echo value of the script as captured in the zabbix_agentd.log file. The sending back code is always "1".
Executed zabbix_get:
Result:
Executed zabbix_get:
Result:
What specifically is the value of the "cmd_result"? Is it the exit code of the command run or is the value output from the command? I'm suspecting the later due to being able to run a command that returns text seems to work correctly. However as indicated above the first example should IMO return "0" instead of "1".
Is this maybe (far reach here IMO) due to the difference between versions on the server (5.0.31) vs. client (5.0.21) - or did I happen to stumble across a bug?
Thanks,
-Brian.
I am working on setting up a UserParameter to monitor our Cantaloupe IIIF server (v.4.1) by simply grabbing a localhost webpage via curl and looking for a string in the result. As the server (Zabbix 5.0.31 (Zabbix repo)) sits in a different firewall zone than the client (Zabbix agent 5.0.21 (EPEL repo)) we don't want to open up a firewall rule to allow direct monitoring of the Cantaloupe IIIF server via web requests from the Zabbix server. Instead we are looking to a real simple local script and UserParameter to achieve this. The simple script "check_url" is as follows and it takes two parameters, the URL to question (generally http://localhost:8182/health for the Cantaloupe health) and the string to look for - in our case the word "color". The output of the curl command results in JSON output as shown below:
Cantaloupe /health output:
Code:
{"color":"RED","message":"FilesystemCache: /srv/cache/source","possibleColors":["GREEN","YELLOW","RED"]}
Code:
#!/bin/bash
RESULT=`curl -s $1 | grep $2`
if [ -z "$RESULT" ]
then
echo 1
exit 1
else
echo 0
exit 0
fi
When run from the command line the exit and echo work as expected. The first value returned is from the script, the 2nd value returned is the return code from the script.
Code:
# ./check_url http://localhost:8182/health color; echo $? 0 0 # ./check_url http://localhost:8182/health blue; echo $? 1 1
Executed zabbix_get:
Code:
$ zabbix_get -s pa-iiif-01.library.pitt.edu -k "cantaloupe.check_url[http://localhost:8182/health,color]" 1
Code:
EXECUTE_STR() command:'/usr/local/bin/check_url http://localhost:8182/health color' len:1 cmd_result:'1' Sending back [1]
Code:
$ zabbix_get -s pa-iiif-01.library.pitt.edu -k "cantaloupe.check_url[http://localhost:8182/health,blue]" 1
Result:
Code:
EXECUTE_STR() command:'/usr/local/bin/check_url http://localhost:8182/health blue' len:1 cmd_result:'1' Sending back [1]
Is this maybe (far reach here IMO) due to the difference between versions on the server (5.0.31) vs. client (5.0.21) - or did I happen to stumble across a bug?
Thanks,
-Brian.
Comment