mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-25 22:55:15 +02:00
Add password option on rediscli custom mode
This commit is contained in:
parent
4a06e02be6
commit
21218cb0bd
@ -44,6 +44,7 @@ sub new {
|
|||||||
{
|
{
|
||||||
"hostname:s" => { name => 'hostname' },
|
"hostname:s" => { name => 'hostname' },
|
||||||
"port:s" => { name => 'port' },
|
"port:s" => { name => 'port' },
|
||||||
|
"password:s" => { name => 'password' },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$options{options}->add_help(package => __PACKAGE__, sections => 'REDIS CLI OPTIONS', once => 1);
|
$options{options}->add_help(package => __PACKAGE__, sections => 'REDIS CLI OPTIONS', once => 1);
|
||||||
@ -81,6 +82,7 @@ sub check_options {
|
|||||||
|
|
||||||
$self->{hostname} = $self->{option_results}->{hostname};
|
$self->{hostname} = $self->{option_results}->{hostname};
|
||||||
$self->{port} = $self->{option_results}->{port};
|
$self->{port} = $self->{option_results}->{port};
|
||||||
|
$self->{password} = $self->{option_results}->{password};
|
||||||
|
|
||||||
if (!defined($self->{hostname})) {
|
if (!defined($self->{hostname})) {
|
||||||
$self->{output}->add_option_msg(short_msg => "Need to specify hostname argument.");
|
$self->{output}->add_option_msg(short_msg => "Need to specify hostname argument.");
|
||||||
@ -104,6 +106,9 @@ sub get_info {
|
|||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{redis} = Redis->new(server => $self->{hostname} . ":" . $self->{port});
|
$self->{redis} = Redis->new(server => $self->{hostname} . ":" . $self->{port});
|
||||||
|
if (defined($self->{password})) {
|
||||||
|
$self->{redis}->auth($self->{password});
|
||||||
|
}
|
||||||
|
|
||||||
my $response = $self->{redis}->info;
|
my $response = $self->{redis}->info;
|
||||||
my $items;
|
my $items;
|
||||||
@ -111,6 +116,8 @@ sub get_info {
|
|||||||
$items->{$attributes} = $response->{$attributes};
|
$items->{$attributes} = $response->{$attributes};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$self->{redis}->quit();
|
||||||
|
|
||||||
return $items;
|
return $items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,6 +145,10 @@ Redis hostname.
|
|||||||
|
|
||||||
Redis port.
|
Redis port.
|
||||||
|
|
||||||
|
=item B<--password>
|
||||||
|
|
||||||
|
Redis password
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
=head1 DESCRIPTION
|
||||||
|
Loading…
x
Reference in New Issue
Block a user