Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
northwood128
Posts: 9 Joined: Mon Jun 15, 2015 12:43 pm
Post
by northwood128 » Thu Jul 02, 2015 5:20 pm
Hi everyone!
I'm trying to monitor a service. This service response should always be an empty JSON list like this: []
When I run it like this, it works:
Code: Select all
~/development/nagios-plugins/check_http -H HOSTADDRESS -w 3 -c 5 -t 4 -u '/url/to/service -r '\[\]' --ssl
HTTP OK: HTTP/1.1 200 OK - 258 bytes in 0.046 second response time |time=0.045796s;3.000000;5.000000;0.000000 size=258B;;;0
But one I've defined the service I get "Could Not Compile Regular Expression: Unmatched [ or [^check_http: Could not parse arguments"
This is the service definition:
Code: Select all
define service {
use generic-service
host_name HOSTADDRESS
service_description DESCRIPTION
check_command check_https_uri_regex!3!5!/api/assort/failed!'\[\]'!
action_url SOME_LINK
notes A_NOTE.
}
And this is the command definition:
Code: Select all
define command{
command_name check_https_uri_regex
command_line $USER1$/check_http -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -t 4 -u $ARG3$ -r $ARG4$ --ssl
}
I've already tried a ton of ways to define the service but it doesn't take any of the different ways to express the regex. I've appreciate some help.
Thank in advance!
Last edited by
northwood128 on Thu Jul 16, 2015 3:09 pm, edited 1 time in total.
lmiltchev
Former Nagios Staff
Posts: 13587 Joined: Mon May 23, 2011 12:15 pm
Post
by lmiltchev » Mon Jul 06, 2015 1:22 pm
It's an escaping issue. Have you tried using this:
Code: Select all
check_command check_https_uri_regex!3!5!/api/assort/failed!'[]'!
or this:
Code: Select all
check_command check_https_uri_regex!3!5!/api/assort/failed!"\[\]"!
Be sure to check out our
Knowledgebase for helpful articles and solutions!
jolson
Attack Rabbit
Posts: 2560 Joined: Thu Feb 12, 2015 12:40 pm
Post
by jolson » Mon Jul 06, 2015 1:24 pm
In addition to what lmiltchev said, I got the following to work on my test machine:
Code: Select all
/usr/local/nagios/libexec/check_http -H $HOSTADDRESS$ -w 3 -c 5 -t 4 -u '/url/to/service' -r "\\\[\\\]"
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
northwood128
Posts: 9 Joined: Mon Jun 15, 2015 12:43 pm
Post
by northwood128 » Mon Jul 06, 2015 1:55 pm
Thanks guys!!
Actually, I've tried what lmiltchev suggested but it didn't work. I'll try the way joison proposed and I'll let you know. Thanks again for your help!
jolson
Attack Rabbit
Posts: 2560 Joined: Thu Feb 12, 2015 12:40 pm
Post
by jolson » Mon Jul 06, 2015 2:01 pm
No problem - looking forward to hearing back!
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
northwood128
Posts: 9 Joined: Mon Jun 15, 2015 12:43 pm
Post
by northwood128 » Tue Jul 07, 2015 11:48 am
That doesn't work either joison
Code: Select all
HTTP CRITICAL: HTTP/1.1 200 OK - pattern not found - 258 bytes in 0.029 second response time
The response of the service is []
Code: Select all
$ curl -k https://hostname/url/to/service
[]
abrist
Red Shirt
Posts: 8334 Joined: Thu Nov 15, 2012 1:20 pm
Post
by abrist » Tue Jul 07, 2015 11:54 am
Can you run the checks above with the very very verbose switch (-vvv)? e.g.:
Code: Select all
/usr/local/nagios/libexec/check_http -H $HOSTADDRESS$ -vvv -w 3 -c 5 -t 4 -u '/url/to/service' -r "\\\[\\\]"
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the
Dark Side .
ssax
Dreams In Code
Posts: 7682 Joined: Wed Feb 11, 2015 12:54 pm
Post
by ssax » Tue Jul 07, 2015 12:05 pm
In addition to abrist's post, try this:
Code: Select all
define service {
use generic-service
host_name HOSTADDRESS
service_description DESCRIPTION
check_command check_https_uri_regex!3!5!/api/assort/failed!\\[\\]!
action_url SOME_LINK
notes A_NOTE.
}
Code: Select all
define command{
command_name check_https_uri_regex
command_line $USER1$/check_http -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -t 4 -u $ARG3$ -r '$ARG4$' --ssl
}
northwood128
Posts: 9 Joined: Mon Jun 15, 2015 12:43 pm
Post
by northwood128 » Tue Jul 07, 2015 1:29 pm
Hi abrist, ssax!! Thanks for the suggestion.
I've tried that,
Code: Select all
define command{
command_name check_https_uri_regex
command_line $USER1$/check_http -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -t 4 -u $ARG3$ -r '$ARG4$' --ssl
}
define service {
use generic-service
host_name $HOSTNAME$
servicegroups SomeServiceaGroup
service_description Some Description
check_command check_https_uri_regex!3!5!/api/assort/failed!\\[\\]!
}
Same compilation error.
"Could Not Compile Regular Expression: Unmatched [ or [^check_http: Could not parse arguments "
northwood128
Posts: 9 Joined: Mon Jun 15, 2015 12:43 pm
Post
by northwood128 » Tue Jul 07, 2015 2:10 pm
verbose output
Code: Select all
$ /usr/local/nagios/production/libexec/check_http -H HOSTNAME -w 3 -c 5 -t 4 -S -u '/api/assort/failed' -r "\[\]" -v
GET /api/assort/failed HTTP/1.1
User-Agent: check_http/v1.4.15 (nagios-plugins 1.4.15)
Connection: close
Host: HOSTNAME
https://HOSTNAME:443/api/assort/failed is 256 characters
STATUS: HTTP/1.1 200 OK
**** HEADER ****
Server: Apache-Coyote/1.1
X-Ecoli-Encoded-Object-Class: java.util.ArrayList
X-Ecoli-Timing: DQ=0|O=8|ER=0|P=8|
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Date: Tue, 07 Jul 2015 19:08:49 GMT
**** CONTENT ****
2
[]
0
HTTP OK: HTTP/1.1 200 OK - 256 bytes in 0.039 second response time |time=0.038579s;3.000000;5.000000;0.000000 size=256B;;;0