| 1 |
Index: pkg-nagios-plugins-contrib/check_cups/check_cups |
| 2 |
=================================================================== |
| 3 |
--- pkg-nagios-plugins-contrib.orig/check_cups/check_cups |
| 4 |
+++ pkg-nagios-plugins-contrib/check_cups/check_cups |
| 5 |
@@ -39,13 +39,33 @@ use warnings; |
| 6 |
# http://search.cpan.org/~rgarcia/perl-5.6.2/pod/perllexwarn.pod |
| 7 |
no warnings qw( redefine prototype ); |
| 8 |
|
| 9 |
+sub load_module { |
| 10 |
+ my @names = @_; |
| 11 |
+ my $module; |
| 12 |
+ for my $name (@names) { |
| 13 |
+ my $file = $name; |
| 14 |
+ # requires need either a bare word or a file name |
| 15 |
+ $file =~ s{::}{/}gsxm; |
| 16 |
+ $file .= '.pm'; |
| 17 |
+ eval { |
| 18 |
+ require $file; |
| 19 |
+ $name->import(); |
| 20 |
+ $module = $name; |
| 21 |
+ }; |
| 22 |
+ last if $module; |
| 23 |
+ } |
| 24 |
+ return $module; |
| 25 |
+} |
| 26 |
+ |
| 27 |
+my $plugin_module; |
| 28 |
+ |
| 29 |
BEGIN { |
| 30 |
|
| 31 |
# use Opsview libs |
| 32 |
use lib '/usr/local/nagios/perl/lib'; |
| 33 |
use lib '/usr/local/nagios/lib'; |
| 34 |
|
| 35 |
- use Nagios::Plugin; |
| 36 |
+ $plugin_module = load_module( 'Monitoring::Plugin', 'Nagios::Plugin' ); |
| 37 |
|
| 38 |
use Data::Dumper; |
| 39 |
|
| 40 |
@@ -95,7 +115,7 @@ General Public Licence (see http://www.f |
| 41 |
This plugin was written at The Harvard-MIT Data Center |
| 42 |
(http://www.hmdc.harvard.edu) by Steve Huff (<shuff\@hmdc.harvard.edu>). |
| 43 |
LICENSE |
| 44 |
-my( $plugin ) = Nagios::Plugin->new( |
| 45 |
+my( $plugin ) = $plugin_module->new( |
| 46 |
shortname => 'check_cups', |
| 47 |
usage => $usagemsg, |
| 48 |
version => '0.2', |