I have the following bash script that uses jq to parse a json file, based on the URL and values to parse for
Here is an example on the command line:
./parse_json.sh "http://blah.com:9000/admin/metrics" \'.gauges."\""heap.init""\".value\',\'.gauges."\""heap.used""\".value\',\'.gauges."\""heap.committed"\"".value\'
268435456 90739040 268435456
Stats | '.gauges."heap.init".value'=268435456;;;0;,'.gauges."heap.used".value'=90739040;;;0;,'.gauges."heap.committed".value'=90739040;;;0;
What I am doing here is breaking for single and double quotes so that parameter looks like this '.gauges."heap.init".value', '.gauges."heap.used".value",'gauges."heap.committed".value
This is my nagios configuration:
Code: Select all
define command{
command_name check_parse_json
command_line $USER1$/parse_json.sh $ARG1$ $ARG2$
}
define service{
use misc-services
host_name nagios
service_description Email Ingestion Heap Stats
check_command check_parse_json!"http://blah.com:9000/admin/metrics"!\'.gauges."\""heap.init""\".value\',\'.gauges."\""heap.used""\".value\',\'.gauges."\""heap.committed"\"".value\'
contact_groups network
normal_check_interval 5
notifications_enabled 0
}Since I don't know how to pass this to Nagios, double quotes around the field name disappear.
Thanks in advance