Adding check_apache_balancer_members
This commit is contained in:
parent
6af92e5dd3
commit
581fc6ce92
4
check_apache_balancer_members/Makefile
Normal file
4
check_apache_balancer_members/Makefile
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
#/usr/bin/make -f
|
||||||
|
|
||||||
|
include ../common.mk
|
||||||
|
|
55
check_apache_balancer_members/check_apache_balancer_members
Normal file
55
check_apache_balancer_members/check_apache_balancer_members
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use LWP::Simple;
|
||||||
|
use Data::Dump qw(dump); #libdata-dump-perl
|
||||||
|
use Nagios::Plugin; #libnagios-plugin-perl
|
||||||
|
use Web::Scraper; #libweb-scraper-perl
|
||||||
|
|
||||||
|
my $np = Nagios::Plugin->new(
|
||||||
|
usage => '',
|
||||||
|
plugin => $0,
|
||||||
|
shortname => "Balancer Members",
|
||||||
|
blurb => 'Apache 2 Load Balancer Manager Members',
|
||||||
|
timeout => 10
|
||||||
|
);
|
||||||
|
|
||||||
|
$np->add_arg(
|
||||||
|
spec => 'hostname|h=s',
|
||||||
|
help => 'hostname of the apache server',
|
||||||
|
required => 1
|
||||||
|
);
|
||||||
|
|
||||||
|
$np->add_arg(
|
||||||
|
spec => 'path|p=s',
|
||||||
|
help => 'path to the balancer url',
|
||||||
|
required => 1
|
||||||
|
);
|
||||||
|
|
||||||
|
$np->getopts;
|
||||||
|
|
||||||
|
my $response = get("http://".$np->opts->hostname."/".$np->opts->path);
|
||||||
|
my $s = scraper {
|
||||||
|
process 'table:nth-of-type(2) tr:not(:first-child)', 'members[]' => scraper {
|
||||||
|
process 'td:nth-of-type(1)', 'worker' => 'TEXT';
|
||||||
|
process 'td:nth-of-type(6)', 'status' => 'TEXT';
|
||||||
|
process 'td:nth-of-type(7)', 'elected' => 'TEXT';
|
||||||
|
process 'td:nth-of-type(8)', 'to' => 'TEXT';
|
||||||
|
process 'td:nth-of-type(9)', 'from' => 'TEXT';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
my $results = $s->scrape($response);
|
||||||
|
|
||||||
|
my @problemMembers = ();
|
||||||
|
my $at_least_one_is_ok = 0;
|
||||||
|
|
||||||
|
foreach my $member (@{$results->{'members'}})
|
||||||
|
{
|
||||||
|
push @problemMembers, $member->{'worker'} if $member->{'status'} =~ /Err/i;
|
||||||
|
$at_least_one_is_ok = 1 if $member->{'status'} =~ /Ok\s?$/;
|
||||||
|
}
|
||||||
|
|
||||||
|
$np->nagios_exit('CRITICAL', "No members are Ok; there is a problem") unless $at_least_one_is_ok;
|
||||||
|
$np->nagios_exit('CRITICAL', "Members have errors: " . join (", ", @problemMembers)) if (@problemMembers > 0);
|
||||||
|
$np->nagios_exit('OK', "All members functioning correctly");
|
6
check_apache_balancer_members/control
Normal file
6
check_apache_balancer_members/control
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
Homepage: https://raw.github.com/mintsoft/check_apache_balancer_members/master/check_apache_balancer_members.pl
|
||||||
|
Watch: https://github.com/mintsoft/check_apache_balancer_members <a class="commit-tease-sha"[^>]*>\s+([0-9a-f]+)\s+</a>
|
||||||
|
Recommends: libdata-dump-perl, libweb-scraper-perl, libmonitoring-plugin-perl | libnagios-plugin-perl
|
||||||
|
Version: a9827f1
|
||||||
|
Uploaders: Jan Wagner <waja@cyconet.org>
|
||||||
|
Description: plugin to monitor Apache2 balancer_manager
|
15
check_apache_balancer_members/copyright
Normal file
15
check_apache_balancer_members/copyright
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
Copyright Copyright 2015 Robert Emery/Codeweavers Ltd
|
||||||
|
|
||||||
|
License: Apache-2.0
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
47
debian/patches/check_apache_balancer_members/MonitoringPlugin
vendored
Normal file
47
debian/patches/check_apache_balancer_members/MonitoringPlugin
vendored
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
From a9a62a4c646acac9a2db826c529efcc599786a93 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jan Wagner <waja@cyconet.org>
|
||||||
|
Date: Mon, 29 May 2017 12:37:12 +0200
|
||||||
|
Subject: [PATCH] Adding support for Monitoring::Plugin
|
||||||
|
|
||||||
|
---
|
||||||
|
check_apache_balancer_members.pl | 25 +++++++++++++++++++++++--
|
||||||
|
1 file changed, 23 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/check_apache_balancer_members/check_apache_balancer_members b/check_apache_balancer_members/check_apache_balancer_members
|
||||||
|
index e83ff68..3c811fd 100644
|
||||||
|
--- a/check_apache_balancer_members/check_apache_balancer_members
|
||||||
|
+++ b/check_apache_balancer_members/check_apache_balancer_members
|
||||||
|
@@ -3,10 +3,31 @@
|
||||||
|
use warnings;
|
||||||
|
use LWP::Simple;
|
||||||
|
use Data::Dump qw(dump); #libdata-dump-perl
|
||||||
|
-use Nagios::Plugin; #libnagios-plugin-perl
|
||||||
|
use Web::Scraper; #libweb-scraper-perl
|
||||||
|
|
||||||
|
-my $np = Nagios::Plugin->new(
|
||||||
|
+sub load_module {
|
||||||
|
+ my @names = @_;
|
||||||
|
+ my $module;
|
||||||
|
+ for my $name (@names) {
|
||||||
|
+ my $file = $name;
|
||||||
|
+ # requires need either a bare word or a file name
|
||||||
|
+ $file =~ s{::}{/}gsxm;
|
||||||
|
+ $file .= '.pm';
|
||||||
|
+ eval {
|
||||||
|
+ require $file;
|
||||||
|
+ $name->import();
|
||||||
|
+ $module = $name;
|
||||||
|
+ };
|
||||||
|
+ last if $module;
|
||||||
|
+ }
|
||||||
|
+ return $module;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+my $plugin_module;
|
||||||
|
+
|
||||||
|
+$plugin_module = load_module( 'Monitoring::Plugin', 'Nagios::Plugin' ); #libmonitoring-plugin-perl or libnagios-plugin-perl
|
||||||
|
+
|
||||||
|
+my $np = $plugin_module->new(
|
||||||
|
usage => '',
|
||||||
|
plugin => $0,
|
||||||
|
shortname => "Balancer Members",
|
10
debian/patches/check_apache_balancer_members/epn
vendored
Normal file
10
debian/patches/check_apache_balancer_members/epn
vendored
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
diff --git a/check_apache_balancer_members/check_apache_balancer_members b/check_apache_balancer_members/check_apache_balancer_members
|
||||||
|
index e83ff68..1cb63da 100644
|
||||||
|
--- a/check_apache_balancer_members/check_apache_balancer_members
|
||||||
|
+++ b/check_apache_balancer_members/check_apache_balancer_members
|
||||||
|
@@ -1,4 +1,5 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
+# nagios: -epn
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use LWP::Simple;
|
2
debian/patches/series
vendored
2
debian/patches/series
vendored
|
@ -1,3 +1,5 @@
|
||||||
|
check_apache_balancer_members/MonitoringPlugin
|
||||||
|
check_apache_balancer_members/epn
|
||||||
check_ipsec/10_pathes
|
check_ipsec/10_pathes
|
||||||
check_ipsec/15_fix_syntax
|
check_ipsec/15_fix_syntax
|
||||||
check_ipsec/20_remove_gateway
|
check_ipsec/20_remove_gateway
|
||||||
|
|
Loading…
Reference in a new issue