fix indent

This commit is contained in:
garnier-quentin 2020-02-27 10:39:30 +01:00
parent 53da9f000d
commit c7d7e99fe5
1 changed files with 14 additions and 12 deletions

View File

@ -47,17 +47,17 @@ sub new {
}); });
$options{options}->add_help(package => __PACKAGE__, sections => 'RETENTION OPTIONS', once => 1); $options{options}->add_help(package => __PACKAGE__, sections => 'RETENTION OPTIONS', once => 1);
} }
$self->{error} = 0; $self->{error} = 0;
$self->{output} = $options{output}; $self->{output} = $options{output};
$self->{datas} = {}; $self->{datas} = {};
$self->{storable} = 0; $self->{storable} = 0;
$self->{memcached_ok} = 0; $self->{memcached_ok} = 0;
$self->{memcached} = undef; $self->{memcached} = undef;
$self->{statefile_dir} = undef; $self->{statefile_dir} = undef;
$self->{statefile_suffix} = undef; $self->{statefile_suffix} = undef;
return $self; return $self;
} }
@ -65,12 +65,15 @@ sub check_options {
my ($self, %options) = @_; my ($self, %options) = @_;
if (defined($options{option_results}) && defined($options{option_results}->{memcached})) { if (defined($options{option_results}) && defined($options{option_results}->{memcached})) {
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'Memcached::libmemcached', centreon::plugins::misc::mymodule_load(
error_msg => "Cannot load module 'Memcached::libmemcached'."); output => $self->{output},
module => 'Memcached::libmemcached',
error_msg => "Cannot load module 'Memcached::libmemcached'."
);
$self->{memcached} = Memcached::libmemcached->new(); $self->{memcached} = Memcached::libmemcached->new();
Memcached::libmemcached::memcached_server_add($self->{memcached}, $options{option_results}->{memcached}); Memcached::libmemcached::memcached_server_add($self->{memcached}, $options{option_results}->{memcached});
} }
# Check redis # Check redis
if (defined($options{option_results}->{redis_server})) { if (defined($options{option_results}->{redis_server})) {
$self->{redis_attributes} = ''; $self->{redis_attributes} = '';
@ -79,7 +82,7 @@ sub check_options {
$self->{redis_attributes} .= "$_ => " . $options{option_results}->{redis_attribute}->{$_} . ', '; $self->{redis_attributes} .= "$_ => " . $options{option_results}->{redis_attribute}->{$_} . ', ';
} }
} }
centreon::plugins::misc::mymodule_load( centreon::plugins::misc::mymodule_load(
output => $self->{output}, output => $self->{output},
module => 'Redis', module => 'Redis',
@ -98,7 +101,7 @@ sub check_options {
} }
}; };
} }
$self->{statefile_dir} = $options{option_results}->{statefile_dir}; $self->{statefile_dir} = $options{option_results}->{statefile_dir};
if ($self->{statefile_dir} ne $default_dir && defined($options{option_results}->{statefile_concat_cwd})) { if ($self->{statefile_dir} ne $default_dir && defined($options{option_results}->{statefile_concat_cwd})) {
centreon::plugins::misc::mymodule_load( centreon::plugins::misc::mymodule_load(
@ -133,13 +136,12 @@ sub read {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{statefile_suffix} = defined($options{statefile_suffix}) ? $options{statefile_suffix} : $self->{statefile_suffix}; $self->{statefile_suffix} = defined($options{statefile_suffix}) ? $options{statefile_suffix} : $self->{statefile_suffix};
$self->{statefile_dir} = defined($options{statefile_dir}) ? $options{statefile_dir} : $self->{statefile_dir}; $self->{statefile_dir} = defined($options{statefile_dir}) ? $options{statefile_dir} : $self->{statefile_dir};
$self->{statefile} = defined($options{statefile}) ? $options{statefile} . $self->{statefile_suffix} : $self->{statefile} = defined($options{statefile}) ? $options{statefile} . $self->{statefile_suffix} : $self->{statefile};
$self->{statefile};
$self->{no_quit} = defined($options{no_quit}) && $options{no_quit} == 1 ? 1 : 0; $self->{no_quit} = defined($options{no_quit}) && $options{no_quit} == 1 ? 1 : 0;
if (defined($self->{memcached})) { if (defined($self->{memcached})) {
# if "SUCCESS" or "NOT FOUND" is ok. Other with use the file # if "SUCCESS" or "NOT FOUND" is ok. Other with use the file
my $val = Memcached::libmemcached::memcached_get($self->{memcached}, $self->{statefile_dir} . "/" . $self->{statefile}); my $val = Memcached::libmemcached::memcached_get($self->{memcached}, $self->{statefile_dir} . '/' . $self->{statefile});
if (defined($self->{memcached}->errstr) && $self->{memcached}->errstr =~ /^SUCCESS|NOT FOUND$/i) { if (defined($self->{memcached}->errstr) && $self->{memcached}->errstr =~ /^SUCCESS|NOT FOUND$/i) {
$self->{memcached_ok} = 1; $self->{memcached_ok} = 1;
if (defined($val)) { if (defined($val)) {
@ -160,7 +162,7 @@ sub read {
$datas = {}; $datas = {};
return 1; return 1;
} }
return 0; return 0;
} }