| 1 |
Index: pkg-nagios-plugins-contrib/check_httpd_status/check_httpd_status |
| 2 |
=================================================================== |
| 3 |
--- pkg-nagios-plugins-contrib.orig/check_httpd_status/check_httpd_status |
| 4 |
+++ pkg-nagios-plugins-contrib/check_httpd_status/check_httpd_status |
| 5 |
@@ -34,8 +34,28 @@ use File::Basename; # get basename() |
| 6 |
use POSIX qw(setlocale); |
| 7 |
use Locale::gettext; |
| 8 |
|
| 9 |
-use Nagios::Plugin ; |
| 10 |
- |
| 11 |
+sub load_module { |
| 12 |
+ my @names = @_; |
| 13 |
+ my $module; |
| 14 |
+ for my $name (@names) { |
| 15 |
+ my $file = $name; |
| 16 |
+ # requires need either a bare word or a file name |
| 17 |
+ $file =~ s{::}{/}gsxm; |
| 18 |
+ $file .= '.pm'; |
| 19 |
+ eval { |
| 20 |
+ require $file; |
| 21 |
+ $name->import(); |
| 22 |
+ $module = $name; |
| 23 |
+ }; |
| 24 |
+ last if $module; |
| 25 |
+ } |
| 26 |
+ return $module; |
| 27 |
+} |
| 28 |
+ |
| 29 |
+my $plugin_module; |
| 30 |
+BEGIN { |
| 31 |
+ $plugin_module = load_module( 'Monitoring::Plugin', 'Nagios::Plugin' ); |
| 32 |
+} |
| 33 |
use LWP::UserAgent; |
| 34 |
use HTTP::Status; # get status_message() |
| 35 |
use Time::HiRes qw(gettimeofday tv_interval); |
| 36 |
@@ -92,7 +112,7 @@ my %TranslationTable = ( |
| 37 |
); |
| 38 |
|
| 39 |
|
| 40 |
-my $np = Nagios::Plugin->new( |
| 41 |
+my $np = $plugin_module->new( |
| 42 |
version => $VERSION, |
| 43 |
blurb => _gt('Apache / Lighthttpd server status monitor for Nagios'), |
| 44 |
usage => "Usage: %s [ -H <host> [-p <port>] [-t <timeout>] [-w <warn_level> -c <crit_level>] [-V] [-u <url>] [-U user -P pass -r realm]", |
| 45 |
@@ -443,4 +463,4 @@ Note : |
| 46 |
Warn if less than 100 workers are available |
| 47 |
Crit if less than 10 workers are available |
| 48 |
EOT |
| 49 |
-} |
| 50 |
\ No newline at end of file |
| 51 |
+} |