update findbin from script.pm
This commit is contained in:
parent
fb5edb6ea0
commit
5d13fb53eb
|
@ -24,7 +24,6 @@ use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use centreon::plugins::output;
|
use centreon::plugins::output;
|
||||||
use centreon::plugins::misc;
|
use centreon::plugins::misc;
|
||||||
use FindBin;
|
|
||||||
use Pod::Usage;
|
use Pod::Usage;
|
||||||
use Pod::Find qw(pod_where);
|
use Pod::Find qw(pod_where);
|
||||||
|
|
||||||
|
@ -191,11 +190,14 @@ sub check_directory {
|
||||||
{
|
{
|
||||||
local *STDOUT;
|
local *STDOUT;
|
||||||
open STDOUT, '>', \$stdout;
|
open STDOUT, '>', \$stdout;
|
||||||
pod2usage(-exitval => 'NOEXIT', -input => $directory . "/" . $filename,
|
pod2usage(
|
||||||
|
-exitval => 'NOEXIT',
|
||||||
|
-input => $directory . "/" . $filename,
|
||||||
-verbose => 99,
|
-verbose => 99,
|
||||||
-sections => "PLUGIN DESCRIPTION");
|
-sections => 'PLUGIN DESCRIPTION'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$self->{plugins_result}->{$directory . "/" . $filename} = $stdout;
|
$self->{plugins_result}->{$directory . '/' . $filename} = $stdout;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir $dh;
|
closedir $dh;
|
||||||
|
@ -273,6 +275,10 @@ sub display_list_plugin {
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
centreon::plugins::misc::mymodule_load(
|
||||||
|
output => $self->{output}, module => 'FindBin',
|
||||||
|
error_msg => "Cannot load module 'FindBin'."
|
||||||
|
);
|
||||||
# Search file 'plugin.pm'
|
# Search file 'plugin.pm'
|
||||||
$self->check_directory($FindBin::Bin);
|
$self->check_directory($FindBin::Bin);
|
||||||
foreach my $key (sort keys %{$self->{plugins_result}}) {
|
foreach my $key (sort keys %{$self->{plugins_result}}) {
|
||||||
|
@ -289,8 +295,14 @@ sub display_list_plugin {
|
||||||
|
|
||||||
sub check_relaunch {
|
sub check_relaunch {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
|
centreon::plugins::misc::mymodule_load(
|
||||||
|
output => $self->{output}, module => 'FindBin',
|
||||||
|
error_msg => "Cannot load module 'FindBin'."
|
||||||
|
);
|
||||||
|
|
||||||
my $need_restart = 0;
|
my $need_restart = 0;
|
||||||
my $cmd = $FindBin::Bin . "/" . $FindBin::Script;
|
my $cmd = $FindBin::Bin . '/' . $FindBin::Script;
|
||||||
my @args = ();
|
my @args = ();
|
||||||
|
|
||||||
if (defined($self->{environment})) {
|
if (defined($self->{environment})) {
|
||||||
|
@ -311,11 +323,11 @@ sub check_relaunch {
|
||||||
}
|
}
|
||||||
if ($uid != $>) {
|
if ($uid != $>) {
|
||||||
if ($> == 0) {
|
if ($> == 0) {
|
||||||
unshift @args, "-s", "/bin/bash", "-l", $self->{runas}, "-c", join(" ", $cmd, "--plugin=" . $self->{plugin}, @ARGV);
|
unshift @args, '-s', '/bin/bash', '-l', $self->{runas}, '-c', join(' ', $cmd, '--plugin=' . $self->{plugin}, @ARGV);
|
||||||
$cmd = "su";
|
$cmd = 'su';
|
||||||
} else {
|
} else {
|
||||||
unshift @args, "-S", "-u", $self->{runas}, $cmd, "--plugin=" . $self->{plugin}, @ARGV;
|
unshift @args, '-S', '-u', $self->{runas}, $cmd, '--plugin=' . $self->{plugin}, @ARGV;
|
||||||
$cmd = "sudo";
|
$cmd = 'sudo';
|
||||||
}
|
}
|
||||||
$need_restart = 1;
|
$need_restart = 1;
|
||||||
}
|
}
|
||||||
|
@ -335,8 +347,10 @@ sub check_relaunch {
|
||||||
|
|
||||||
if ($exit_code <= -1000) {
|
if ($exit_code <= -1000) {
|
||||||
if ($exit_code == -1000) {
|
if ($exit_code == -1000) {
|
||||||
$self->{output}->output_add(severity => 'UNKNOWN',
|
$self->{output}->output_add(
|
||||||
short_msg => $stdout);
|
severity => 'UNKNOWN',
|
||||||
|
short_msg => $stdout
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$self->{output}->display();
|
$self->{output}->display();
|
||||||
$self->{output}->exit();
|
$self->{output}->exit();
|
||||||
|
|
Loading…
Reference in New Issue