I am pretty bad with string manipulations, so here is another one, I was able to get this far:
underlying is using jq to parse the json. So I am passing URL, jq filter and the thresholds it needs to match for each field
./parse_json_generic.sh 'http://blah.com:9020/healthcheck' \'.\"Mongo' 'Health\".\"healthy\"\',\'.\"Two-Way-Communication-Service\".\"healthy\"\',\'.\"RabbitMQ\".\"healthy\"\',\'.\"threadDeadlockHealthCheck\".\"healthy\"\' 'false false false false'
These is the filter '."Mongo Health"."healthy"','."Two-Way-Communication-Service"."healthy"','."RabbitMQ"."healthy"','."threadDeadlockHealthCheck"."healthy"'
'."Mongo_Health"."healthy"'=true is CRITICAL '."Two-Way-Communication-Service"."healthy"'=true is CRITICAL '."RabbitMQ"."healthy"'=true is CRITICAL '."threadDeadlockHealthCheck"."healthy"'=true is CRITICAL
But when I am trying to put this into Nagios is where I am running into issues. Here is what I have.
define command{
command_name check_parse_json_threshold
command_line $USER1$/parse_json_generic.sh $ARG1$ $ARG2$ $ARG3$
}
define service{
use app-services
service_description Two-Way Communication
host_name BLAH
check_command check_parse_json_threshold!"http://$HOSTADDRESS$:9020/healthcheck"!\'.\"Mongo' 'Health\".\"healthy\"\',\'.\"Two-Way-Communication-Service\".\"healthy\"\',\'.\"RabbitMQ\".\"healthy\"\',\'.\"threadDeadlockHealthCheck\".\"healthy\"\'!"false false false false"
notifications_enabled 0
}
I need help with the second argument as so that \'.\"Mongo' 'Health\".\"healthy\"\',\'.\"Two-Way-Communication-Service\".\"healthy\"\',\'.\"RabbitMQ\".\"healthy\"\',\'.\"threadDeadlockHealthCheck\".\"healthy\"\' is handled as one string
Double quotes around it don't help
Thanks in advance
Handling complex arguments No2
-
jdalrymple
- Skynet Drone
- Posts: 2620
- Joined: Wed Feb 11, 2015 1:56 pm
Re: Handling complex arguments No2
This is what I get when I do what we discussed before:
becomes
escaping:
Code: Select all
\'.\"Mongo' 'Health\".\"healthy\"\',\'.\"Two-Way-Communication-Service\".\"healthy\"\',\'.\"RabbitMQ\".\"healthy\"\',\'Code: Select all
\\\'.\\\"Mongo\' \'Health\\\".\\\"healthy\\\"\\\',\\\'.\\\"Two-Way-Communication-Service\\\".\\\"healthy\\\"\\\',\\\'.\\\"RabbitMQ\\\".\\\"healthy\\\"\\\',\\\'Code: Select all
\ ' "Re: Handling complex arguments No2
jdalrymple wrote:This is what I get when I do what we discussed before:
becomesCode: Select all
\'.\"Mongo' 'Health\".\"healthy\"\',\'.\"Two-Way-Communication-Service\".\"healthy\"\',\'.\"RabbitMQ\".\"healthy\"\',\'escaping:Code: Select all
\\\'.\\\"Mongo\' \'Health\\\".\\\"healthy\\\"\\\',\\\'.\\\"Two-Way-Communication-Service\\\".\\\"healthy\\\"\\\',\\\'.\\\"RabbitMQ\\\".\\\"healthy\\\"\\\',\\\'
Code: Select all
\ ' "
It didn't work that space for the Mongo Health is throwing things off
So when I remove that one and just use this \\\'.\\\"Two-Way-Communication-Service\\\".\\\"healthy\\\"\\\',\\\'.\\\"RabbitMQ\\\".\\\"healthy\\\"\\\',\\\'.\\\"threadDeadlockHealthCheck\\\".\\\"healthy\\\"\\\' I get things parsed correctly.
I have asked the devs to modify the code to give single worded field names, so I won't run into this issue.
But it would be nice to figure out how to handle multiple words
-
jdalrymple
- Skynet Drone
- Posts: 2620
- Joined: Wed Feb 11, 2015 1:56 pm
Re: Handling complex arguments No2
%20?
That would be my only potential thought. Otherwise generally speaking Nagios ARGs handle whitespace without issue.
That would be my only potential thought. Otherwise generally speaking Nagios ARGs handle whitespace without issue.