Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

validate all proxies have been checked #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions check_haproxy_stats.pl
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ sub usage {
my $exitcode = 0;
my $msg;
my $checked = 0;
my %checked_proxies;
my $perfdata = "";

# Remove excluded proxies from the list if both -p and -P options are
Expand All @@ -267,6 +268,8 @@ sub usage {
if (@proxies) { next unless grep {$data[$pxname] eq $_} @proxies; };
if (@no_proxies) { next if grep {$data[$pxname] eq $_} @no_proxies; };

$checked_proxies{$data[$pxname]} = "found";

# Is session limit enforced?
if ($data[$slim]) {
$perfdata .= sprintf "%s-%s=%u;%u;%u;0;%u;", $data[$pxname], $data[$svname], $data[$scur], $swarn * $data[$slim] / 100, $scrit * $data[$slim] / 100, $data[$slim];
Expand Down Expand Up @@ -311,6 +314,11 @@ sub usage {
++$checked;
}

if (@proxies && 0+@proxies > 0+keys %checked_proxies) {
$exitcode = 2;
$msg = "Not all proxies checked for @proxies.";
}

unless ($msg) {
$msg = @proxies ? sprintf("checked proxies: %s", join ', ', sort @proxies) : "checked $checked proxies.";
}
Expand Down