Skip to content

supporting standby server #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
michaelxwang opened this issue Jul 22, 2020 · 3 comments · Fixed by #19
Closed

supporting standby server #14

michaelxwang opened this issue Jul 22, 2020 · 3 comments · Fixed by #19

Comments

@michaelxwang
Copy link

I have a backup consisting of the a primary and standby (which are not supported by us):

backend foo
...
    server primary <ip1>:<port> check
    server standby <ip1>:<port> check

as long as one of them is up, we are fine. I added a option to support this:

# diff -u check_haproxy.rb check_haproxy_new.rb 
--- check_haproxy.rb	2020-07-20 11:48:18.606961989 -0400
+++ check_haproxy_new.rb	2020-07-22 10:25:42.739437825 -0400
@@ -56,6 +56,10 @@
     options.insecure_ssl = true
   end
 
+  opts.on( '-o', '--overall', 'Reporting status based on the overall frontend/backup status' ) do
+    options.overall = true
+  end
+
   opts.on( '--http-error-critical', 'Throw critical when connection to HAProxy is refused or returns error code' ) do
     options.http_error_critical = true
   end
@@ -177,9 +181,11 @@
                     row['smax'])
   @proxies << message
 
-  if row['status'].include?('DOWN')
-    @errors << message
-    exit_code CRITICAL
+  if not options.overall or row['svname'] =~ /^(FRONTEND|BACKEND)$/
+    if row['status'].include?('DOWN')
+      @errors << message
+      exit_code CRITICAL
+    end
   end
 
   if options.critical && session_percent_usage >= options.critical.to_i

Please review. Thanks.

@benprew
Copy link
Owner

benprew commented Jul 27, 2020

Hi @michaelxwang, thanks for submitting this patch. I had one question, previously the code used to report critical messages if a proxy was down, now it only reports critical messages if "overall" is specified, or the svname is frontend or backend.

I think a better solution would be to have an option to limit to specific svnames, then you could pass in backend,frontend as the list of acceptable svnames.

Would that work for you?

@benprew
Copy link
Owner

benprew commented Jul 27, 2020

Maybe the svname would require a proxy as well, so instead of just specifying --svnames frontend,backend you could do something like --svnames foo|frontend,foo|backend if you wanted to filter to specific svnames in specific proxies.

benprew added a commit that referenced this issue Mar 21, 2021
Previously, check_haproxy would consider it a crit if any server was DOWN, change it so
it only considers a full BACKEND or FRONTEND failure a crit ( Fixes #17. )

Have better active/backup role testing, to ignore backup servers that are
down. ( Fixes #14 )
@benprew
Copy link
Owner

benprew commented Mar 21, 2021

@michaelxwang I think I have a fix for this in PR #19, can you test with that updated version of check_haproxy.rb when you get a chance to see if it fixes the issue? If not, can you provide a haproxy .csv file that I can test against?

Thanks

benprew added a commit that referenced this issue Apr 29, 2021
Previously, check_haproxy would consider it a crit if any server was DOWN, change it so
it only considers a full BACKEND or FRONTEND failure a crit ( Fixes #17. )

Have better active/backup role testing, to ignore backup servers that are
down. ( Fixes #14 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants