diff --git a/README.md b/README.md index 3956fe0..b913d14 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ Usage: ./check_http_json.rb -u -e -w -c --pass PASSWORD HTTP basic authentication password. --headers HEADERS Comma-separated list of HTTP headers to include (ex. HOST:somehost,AUTH:letmein). --status_level STRING Comma-separated list of HTTP status codes and their associated Nagios alert levels (ex. 301:1,404:2). + --status_level_default VALUE The default return code for unexpected HTTP status codes. Defaults to 1. -f, --file PATH Target file. Incompatible with -u. -e, --element ELEMENT... Desired element (ex. foo=>bar=>ish is foo.bar.ish). Repeatable argument. -E, --element_regex REGEX Desired element expressed as regular expression. diff --git a/check_http_json.rb b/check_http_json.rb index 856621b..c929f1e 100755 --- a/check_http_json.rb +++ b/check_http_json.rb @@ -214,8 +214,7 @@ def uri_target(options) # We must get a 200 response; if not, the user might want to know. if not response.code.to_i == 200 then - # WARN by default. - level = 1 + level = options[:status_level_default] if options[:status_level] then options[:status_level].each do |s| k,v = s.split(':') @@ -301,6 +300,11 @@ def parse_args(options) options[:status_level] = x.split(',') end + options[:status_level_default] = 1 + opts.on('--status_level_default VALUE', 'The default return code for unexpected HTTP status codes. Defaults to 1.') do |x| + options[:status_level_default] = x.to_i + end + options[:file] = nil opts.on('-f', '--file PATH', 'Target file. Incompatible with -u.') do |x| options[:file] = x