diff --git a/apps/redis/cli/custom/rediscli.pm b/apps/redis/cli/custom/rediscli.pm index 5b95f8e02..d3226c96c 100644 --- a/apps/redis/cli/custom/rediscli.pm +++ b/apps/redis/cli/custom/rediscli.pm @@ -44,6 +44,7 @@ sub new { { "hostname:s" => { name => 'hostname' }, "port:s" => { name => 'port' }, + "password:s" => { name => 'password' }, }); } $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->{port} = $self->{option_results}->{port}; + $self->{password} = $self->{option_results}->{password}; if (!defined($self->{hostname})) { $self->{output}->add_option_msg(short_msg => "Need to specify hostname argument."); @@ -104,6 +106,9 @@ sub get_info { my ($self, %options) = @_; $self->{redis} = Redis->new(server => $self->{hostname} . ":" . $self->{port}); + if (defined($self->{password})) { + $self->{redis}->auth($self->{password}); + } my $response = $self->{redis}->info; my $items; @@ -111,6 +116,8 @@ sub get_info { $items->{$attributes} = $response->{$attributes}; } + $self->{redis}->quit(); + return $items; } @@ -138,6 +145,10 @@ Redis hostname. Redis port. +=item B<--password> + +Redis password + =back =head1 DESCRIPTION