1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-24 09:57:09 +00:00

Now supports password protected Redis servers

This commit is contained in:
Vadim Istratov 2010-11-17 09:55:11 +01:00 committed by Steve Schnepp
parent eb3dad4363
commit a7be1b2079

View file

@ -26,7 +26,7 @@
##
## 1. Download the plugin to your plugins directory (e.g. /usr/share/munin/plugins)
## 2. Create 3 symlinks at the directory that us used by munin for plugins detection (e.g. /etc/munin/plugins): redis_connected_clients, redis_per_sec and and redis_used_memory
## 3. Edit plugin-conf.d/munin-node if it is needed (env.host and env.port variables are accepted)
## 3. Edit plugin-conf.d/munin-node if it is needed (env.host and env.port variables are accepted; set env.password for password protected Redis server)
## 4. Restart munin-node service
use strict;
@ -35,6 +35,7 @@ use Switch;
my $HOST = exists $ENV{'host'} ? $ENV{'host'} : "127.0.0.1";
my $PORT = exists $ENV{'port'} ? $ENV{'port'} : 6379;
my $PASSWORD = exists $ENV{'password'} ? $ENV{'password'} : undef;
my $server = "$HOST:$PORT";
my $sock = IO::Socket::INET->new(
@ -42,6 +43,11 @@ my $sock = IO::Socket::INET->new(
Proto => 'tcp'
);
if ( defined( $PASSWORD ) ) {
print $sock "AUTH ", $PASSWORD, "\r\n";
my $result = <$sock> || die "can't read socket: $!";
}
print $sock "INFO\r\n";
my $result = <$sock> || die "can't read socket: $!";