Nagios not accepting regex in command

nagiosregex

I have this command defined:

define command{
command_name check_http_sane
command_line $USER1$/check_http -H $HOSTNAME$ -r "HTTP/1.1 (200|301|302|303|304|307|401|418|426)"
}

When I run it manually on command line, it works fine, but nagios (2.6) reports a "pattern not found" error. Do I need to escape something?


Edit: As stated below, I solved it by replacing check_http with my own script which works (good enough for our use case, anyway). Script: http://pastebin.com/hNmz6Wa1

Best Answer

The source code for check_http.c says the -r option checks the headers and the page contents. The problem you are seeing is probably the Nagios command macro interpreter trying to replace something in your regex string.

You should try escaping all of your (,| and ) characters. If that doesn't work, try just the parentheses and just the pipes. You might also try using single quotes instead of double quotes.