mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-28 08:04:36 +02:00
+ Avoid loop !
This commit is contained in:
parent
db7b35b06a
commit
ed53a65b12
@ -215,10 +215,12 @@ sub mymodule_load {
|
|||||||
require $file;
|
require $file;
|
||||||
};
|
};
|
||||||
if ($@) {
|
if ($@) {
|
||||||
|
return 1 if (defined($options{no_quit}) && $options{no_quit} == 1);
|
||||||
$options{output}->add_option_msg(long_msg => $@);
|
$options{output}->add_option_msg(long_msg => $@);
|
||||||
$options{output}->add_option_msg(short_msg => $options{error_msg});
|
$options{output}->add_option_msg(short_msg => $options{error_msg});
|
||||||
$options{output}->option_exit();
|
$options{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub backtick {
|
sub backtick {
|
||||||
|
@ -592,8 +592,11 @@ sub is_litteral_status {
|
|||||||
sub create_json_document {
|
sub create_json_document {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
centreon::plugins::misc::mymodule_load(output => $self, module => 'JSON',
|
if (centreon::plugins::misc::mymodule_load(no_quit => 1, module => 'JSON',
|
||||||
error_msg => "Cannot load module 'JSON'.");
|
error_msg => "Cannot load module 'JSON'.")) {
|
||||||
|
print "Cannot load module 'JSON'\n";
|
||||||
|
$self->exit(exit_litteral => 'unknown');
|
||||||
|
}
|
||||||
$self->{is_output_json} = 1;
|
$self->{is_output_json} = 1;
|
||||||
$self->{json_output} = JSON->new->utf8();
|
$self->{json_output} = JSON->new->utf8();
|
||||||
}
|
}
|
||||||
@ -601,8 +604,11 @@ sub create_json_document {
|
|||||||
sub create_xml_document {
|
sub create_xml_document {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
centreon::plugins::misc::mymodule_load(output => $self, module => 'XML::LibXML',
|
if (centreon::plugins::misc::mymodule_load(no_quit => 1, module => 'XML::LibXML',
|
||||||
error_msg => "Cannot load module 'XML::LibXML'.");
|
error_msg => "Cannot load module 'XML::LibXML'.")) {
|
||||||
|
print "Cannot load module 'XML::LibXML'\n";
|
||||||
|
$self->exit(exit_litteral => 'unknown');
|
||||||
|
}
|
||||||
$self->{is_output_xml} = 1;
|
$self->{is_output_xml} = 1;
|
||||||
$self->{xml_output} = XML::LibXML::Document->new('1.0', 'utf-8');
|
$self->{xml_output} = XML::LibXML::Document->new('1.0', 'utf-8');
|
||||||
}
|
}
|
||||||
@ -700,8 +706,11 @@ sub to_utf8 {
|
|||||||
|
|
||||||
|
|
||||||
# Some Perl version dont have the following module (like Perl 5.6.x)
|
# Some Perl version dont have the following module (like Perl 5.6.x)
|
||||||
centreon::plugins::misc::mymodule_load(output => $self, module => 'Encode',
|
if (centreon::plugins::misc::mymodule_load(no_quit => 1, module => 'Encode',
|
||||||
error_msg => "Cannot load module 'Encode'.");
|
error_msg => "Cannot load module 'Encode'.")) {
|
||||||
|
print "Cannot load module 'Encode'\n";
|
||||||
|
$self->exit(exit_litteral => 'unknown');
|
||||||
|
}
|
||||||
|
|
||||||
$self->{encode_utf8_import} = 1;
|
$self->{encode_utf8_import} = 1;
|
||||||
eval '$self->{perlqq} = Encode::PERLQQ';
|
eval '$self->{perlqq} = Encode::PERLQQ';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user