File tree 1 file changed +7
-2
lines changed
1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change 17
17
@errors = [ ]
18
18
@perfdata = [ ]
19
19
exit_code = OK
20
+ http_error_critical = false
20
21
21
22
options = OpenStruct . new
22
23
options . proxies = [ ]
67
68
OpenSSL ::SSL ::VERIFY_PEER = OpenSSL ::SSL ::VERIFY_NONE
68
69
end
69
70
71
+ opts . on ( '--http-error-critical' , 'Throw critical when connection to HAProxy is refused or returns error code' ) do
72
+ http_error_critical = true
73
+ end
74
+
70
75
opts . on ( '-h' , '--help' , 'Display this screen' ) do
71
76
puts opts
72
77
exit 3
106
111
f = open ( options . url , :http_basic_authentication => [ options . user , options . password ] )
107
112
rescue OpenURI ::HTTPError => e
108
113
puts "ERROR: #{ e . message } "
109
- exit CRITICAL
114
+ http_error_critical ? exit CRITICAL : exit UNKNOWN
110
115
rescue Errno ::ECONNREFUSED => e
111
116
puts "ERROR: #{ e . message } "
112
- exit CRITICAL
117
+ http_error_critical ? exit CRITICAL : exit UNKNOWN
113
118
rescue Exception => e
114
119
if e . message =~ /redirection forbidden/
115
120
options . url = e . message . gsub ( /.*-> (.*)/ , '\1' ) # extract redirect URL
You can’t perform that action at this time.
0 commit comments