Handling complex arguments No2
Posted: Tue Apr 21, 2015 2:03 pm
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
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