+ Fix #380
This commit is contained in:
parent
9452678090
commit
2b9d0b7a47
|
@ -214,11 +214,13 @@ sub unix_execute {
|
|||
sub mymodule_load {
|
||||
my (%options) = @_;
|
||||
my $file;
|
||||
($file = $options{module} . ".pm") =~ s{::}{/}g;
|
||||
|
||||
($file = ($options{module} =~ /\.pm$/ ? $options{module} : $options{module} . ".pm")) =~ s{::}{/}g;
|
||||
|
||||
eval {
|
||||
local $SIG{__DIE__} = 'IGNORE';
|
||||
require $file;
|
||||
$file =~ s{/}{::}g;
|
||||
$file =~ s/\.pm$//;
|
||||
};
|
||||
if ($@) {
|
||||
return 1 if (defined($options{no_quit}) && $options{no_quit} == 1);
|
||||
|
@ -226,7 +228,7 @@ sub mymodule_load {
|
|||
$options{output}->add_option_msg(short_msg => $options{error_msg});
|
||||
$options{output}->option_exit();
|
||||
}
|
||||
return 0;
|
||||
return wantarray ? (0, $file) : 0;
|
||||
}
|
||||
|
||||
sub backtick {
|
||||
|
|
|
@ -273,8 +273,9 @@ sub run {
|
|||
|
||||
$self->check_relaunch();
|
||||
|
||||
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{plugin},
|
||||
error_msg => "Cannot load module --plugin.");
|
||||
(undef, $self->{plugin}) =
|
||||
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{plugin},
|
||||
error_msg => "Cannot load module --plugin.");
|
||||
my $plugin = $self->{plugin}->new(options => $self->{options}, output => $self->{output});
|
||||
$plugin->init(help => $self->{help},
|
||||
version => $self->{version});
|
||||
|
|
|
@ -115,8 +115,8 @@ sub init {
|
|||
error_msg => "Cannot load module --mode.");
|
||||
$self->{mode} = $self->{modes}{$self->{mode_name}}->new(options => $self->{options}, output => $self->{output}, mode => $self->{mode_name});
|
||||
} elsif (defined($self->{dynmode_name}) && $self->{dynmode_name} ne '') {
|
||||
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{dynmode_name},
|
||||
error_msg => "Cannot load module --dyn-mode.");
|
||||
(undef, $self->{dynmode_name}) = centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{dynmode_name},
|
||||
error_msg => "Cannot load module --dyn-mode.");
|
||||
$self->{mode} = $self->{dynmode_name}->new(options => $self->{options}, output => $self->{output}, mode => $self->{dynmode_name});
|
||||
} else {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify '--mode' or '--dyn-mode' option.");
|
||||
|
|
|
@ -86,8 +86,8 @@ sub init {
|
|||
error_msg => "Cannot load module --mode.");
|
||||
$self->{mode} = $self->{modes}{$self->{mode_name}}->new(options => $self->{options}, output => $self->{output}, mode => $self->{mode_name});
|
||||
} elsif (defined($self->{dynmode_name}) && $self->{dynmode_name} ne '') {
|
||||
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{dynmode_name},
|
||||
error_msg => "Cannot load module --dyn-mode.");
|
||||
(undef, $self->{dynmode_name}) = centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{dynmode_name},
|
||||
error_msg => "Cannot load module --dyn-mode.");
|
||||
$self->{mode} = $self->{dynmode_name}->new(options => $self->{options}, output => $self->{output}, mode => $self->{dynmode_name});
|
||||
} else {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify '--mode' or '--dyn-mode' option.");
|
||||
|
|
|
@ -91,8 +91,8 @@ sub init {
|
|||
error_msg => "Cannot load module --mode.");
|
||||
$self->{mode} = $self->{modes}{$self->{mode_name}}->new(options => $self->{options}, output => $self->{output}, mode => $self->{mode_name});
|
||||
} elsif (defined($self->{dynmode_name}) && $self->{dynmode_name} ne '') {
|
||||
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{dynmode_name},
|
||||
error_msg => "Cannot load module --dyn-mode.");
|
||||
(undef, $self->{dynmode_name}) = centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{dynmode_name},
|
||||
error_msg => "Cannot load module --dyn-mode.");
|
||||
$self->{mode} = $self->{dynmode_name}->new(options => $self->{options}, output => $self->{output}, mode => $self->{dynmode_name});
|
||||
} else {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify '--mode' or '--dyn-mode' option.");
|
||||
|
|
|
@ -107,8 +107,8 @@ sub init {
|
|||
error_msg => "Cannot load module --mode.");
|
||||
$self->{mode} = $self->{modes}{$self->{mode_name}}->new(options => $self->{options}, output => $self->{output}, mode => $self->{mode_name});
|
||||
} elsif (defined($self->{dynmode_name}) && $self->{dynmode_name} ne '') {
|
||||
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{dynmode_name},
|
||||
error_msg => "Cannot load module --dyn-mode.");
|
||||
(undef, $self->{dynmode_name}) = centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{dynmode_name},
|
||||
error_msg => "Cannot load module --dyn-mode.");
|
||||
$self->{mode} = $self->{dynmode_name}->new(options => $self->{options}, output => $self->{output}, mode => $self->{dynmode_name});
|
||||
} else {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify '--mode' or '--dyn-mode' option.");
|
||||
|
|
|
@ -91,8 +91,8 @@ sub init {
|
|||
error_msg => "Cannot load module --mode.");
|
||||
$self->{mode} = $self->{modes}{$self->{mode_name}}->new(options => $self->{options}, output => $self->{output}, mode => $self->{mode_name});
|
||||
} elsif (defined($self->{dynmode_name}) && $self->{dynmode_name} ne '') {
|
||||
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{dynmode_name},
|
||||
error_msg => "Cannot load module --dyn-mode.");
|
||||
(undef, $self->{dynmode_name}) = centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{dynmode_name},
|
||||
error_msg => "Cannot load module --dyn-mode.");
|
||||
$self->{mode} = $self->{dynmode_name}->new(options => $self->{options}, output => $self->{output}, mode => $self->{dynmode_name});
|
||||
} else {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify '--mode' or '--dyn-mode' option.");
|
||||
|
|
Loading…
Reference in New Issue