I. Overview of the Environment
Nagios Server: 192.168.203.10
Nagios Client (Redis): 192.168.203.20
Redis version: Redis 2.8 Release
Second, download and install the Redis monitor plugin
Https://github.com/willixix/WL-NagiosPlugins
Place Perl files under the specified libexec path of Nagios and assign Execute permissions
/usr/local/nagios/libexec/check_redis.pl
Need to install Perl redis.pm module, otherwise error
(No output on stdout) Stderr:can ' t locate redis.pm in @INC (@INC contains:/usr/local/lib64/perl5/usr/local/sha Re/perl5/usr/lib64/perl5/vendor_perl/usr/share/perl5/vendor_perl/usr/lib64/perl5/usr/share/perl5.) at/usr/local/nagios/libexec/check_redis.pl Line 421.
#yum install-y Perl-yaml
#perl-mcpan-e Shell
Cpan[1]> Install Redis
All the way to the return, you may need to install too many dependent packages, always install just fine.
Result:pass
Dams/redis-1.975.tar.gz
/usr/bin/make Test--OK
Running make Install
Prepending/root/.cpan/build/redis-1.975-tazmoi/blib/arch/root/.cpan/build/redis-1.975-tazmoi/blib/lib to Perl5lib for ' Install '
installing/usr/local/share/perl5/redis.pm
installing/usr/local/share/perl5/redis/list.pm
installing/usr/local/share/perl5/redis/sentinel.pm
installing/usr/local/share/perl5/redis/hash.pm
installing/usr/local/share/man/man3/redis::hash.3pm
installing/usr/local/share/man/man3/redis::sentinel.3pm
installing/usr/local/share/man/man3/redis::list.3pm
installing/usr/local/share/man/man3/redis.3pm
Appending installation Info To/usr/lib64/perl5/perllocal.pod
Dams/redis-1.975.tar.gz
/usr/bin/make Install--OK
Cpan[2]> quit
#Cp-p/usr/local/share/perl5/redis.pm/usr/lib64/perl5/
Third, define the monitoring command
Add the following to Commands.cfg:
#vi/usr/local/nagios/etc/objects/commands.cfg
# Check Redis
Define Command {
Command_name Check_redis
Command_line $USER 1$/check_redis.pl-h $HOSTADDRESS $-P $ARG 1$-a $ARG 2$-W $ARG 3$-C $ARG 4$-F
}
Defining host monitoring items
#vi/usr/local/nagios/etc/objects/192.168.203.20.cfg
Define Service {
Use Local-service
Service_description Redis Client
Check_command check_redis!6379! ' Connected_clients,blocked_clients,client_longest_output_list,client_biggest_input_buf '!100,5,~,~!500,10,~,~
HOST_NAME 192.168.203.20
}
After the installation is complete, the following are the details: