1
0

Compare commits

5 Commits

3 changed files with 55 additions and 2 deletions

View File

@@ -0,0 +1,45 @@
--- ./check_haproxy.pl 2025/03/26 16:15:37 1.1
+++ ./check_haproxy.pl 2025/03/26 16:15:54
@@ -123,6 +123,11 @@
help => _gt('Comma-separated list of backends to ignore'),
required => 0,
);
+$np->add_arg (
+ spec => 'ignore-down-backup-servers|B',
+ help => _gt('Ignore servers marked as backup in down state.'),
+ required => 0,
+);
$np->getopts;
@@ -141,6 +146,7 @@
if ( defined ( $ignore_backends ) ) {
@ignore_backends_list = split(',',$ignore_backends);
}
+my $ignore_down_backup = $np->opts->get('ignore-down-backup-servers');
# Thresholds :
# time
@@ -296,14 +302,16 @@
if ( $stats{$pxname}{$svname}{'status'} eq 'UP' ) {
logD( sprintf(_gt("%s '%s' is up on '%s' proxy."),$activeDescr,$svname,$pxname) );
} elsif ( $stats{$pxname}{$svname}{'status'} eq 'DOWN' ) {
- if ( defined($crit_backends) ) {
- if ( grep(/^$pxname$/,@crit_backends_list) ) {
- $np->add_message(CRITICAL, sprintf(_gt("%s '%s' is DOWN on '%s' proxy !"),$activeDescr,$svname,$pxname) );
+ if ( $active || !$ignore_down_backup ) {
+ if ( defined($crit_backends) ) {
+ if ( grep(/^$pxname$/,@crit_backends_list) ) {
+ $np->add_message(CRITICAL, sprintf(_gt("%s '%s' is DOWN on '%s' proxy !"),$activeDescr,$svname,$pxname) );
+ }else{
+ $np->add_message(WARNING, sprintf(_gt("%s '%s' is DOWN on '%s' proxy !"),$activeDescr,$svname,$pxname) );
+ }
}else{
- $np->add_message(WARNING, sprintf(_gt("%s '%s' is DOWN on '%s' proxy !"),$activeDescr,$svname,$pxname) );
+ $np->add_message(CRITICAL, sprintf(_gt("%s '%s' is DOWN on '%s' proxy !"),$activeDescr,$svname,$pxname) );
}
- }else{
- $np->add_message(CRITICAL, sprintf(_gt("%s '%s' is DOWN on '%s' proxy !"),$activeDescr,$svname,$pxname) );
}
}
if ( $stats{$pxname}{$svname}{'act'} eq '1' ) {

View File

@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Mar 26 17:19:10 CET 2025 - ro@suse.de
- add check_haproxy-ignore_down_backends.patch
allow ignoring down servers marked as backup
(meant for active/passive clusters)
-------------------------------------------------------------------
Wed Feb 7 12:10:28 CET 2024 - ro@suse.de

View File

@@ -1,7 +1,7 @@
#
# spec file for package monitoring-plugins-haproxy
#
# Copyright (c) 2024 SUSE LLC
# Copyright (c) 2025 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -25,6 +25,7 @@ Group: System/Monitoring
URL: https://github.com/Napsty/check_haproxy
Source0: check_haproxy-%{version}.tar.gz
Source1: gpl-2.0.txt
Patch0: check_haproxy-ignore_down_backends.patch
BuildRequires: nagios-rpm-macros
# For directory ownership:
BuildRequires: icinga2-bin
@@ -47,7 +48,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-build
The plugin checks HAProxy statistic url (csv) and gets UP and DOWN services.
%prep
%setup -q -n check_haproxy-%{version}
%autosetup -n check_haproxy-%{version}
install -m644 %{SOURCE1} LICENSE
%build