Debian Codegraph @

debian/patches/check_libvirt/monitoring-plugin

raw
1 Index: pkg-nagios-plugins-contrib/check_libvirt/check_libvirt
2 ===================================================================
3 --- pkg-nagios-plugins-contrib.orig/check_libvirt/check_libvirt
4 +++ pkg-nagios-plugins-contrib/check_libvirt/check_libvirt
5 @@ -27,11 +27,33 @@
6 use strict;
7 use warnings;
8 use vars qw($PROGNAME $VERSION $output $result);
9 -use Nagios::Plugin;
10 use File::Basename;
11 use Sys::Virt;
12 use XML::Simple;
13
14 +sub load_module {
15 + my @names = @_;
16 + my $module;
17 + for my $name (@names) {
18 + my $file = $name;
19 + # requires need either a bare word or a file name
20 + $file =~ s{::}{/}gsxm;
21 + $file .= '.pm';
22 + eval {
23 + require $file;
24 + $name->import();
25 + $module = $name;
26 + };
27 + last if $module;
28 + }
29 + return $module;
30 +}
31 +
32 +my $plugin_module;
33 +BEGIN {
34 + $plugin_module = load_module( 'Monitoring::Plugin', 'Nagios::Plugin' );
35 +}
36 +
37 $PROGNAME = basename($0);
38 $VERSION = '0.1.0';
39 my $spooldir="/opt/monitor/var/check_libvirt";
40 @@ -41,7 +63,7 @@ if (!-d $spooldir)
41 mkdir($spooldir);
42 }
43
44 -my $np = Nagios::Plugin->new(
45 +my $np = $plugin_module->new(
46 usage => "Usage: %s -H <hosturl> [ -N <vmname> ]\n"
47 . " [-u <user> -p <pass>]\n"
48 . " -l <command> [ -s <subcommand> ]\n"