As: http://download.csdn.net/detail/hellopengyl/9617697, there are 2 versions, one is written in Perl script, one is written in PHP script, you can choose one, And the other two are monitoring MySQL. Here is the Perl script.
[[email protected] libexec]# chmod +x check_redis.p*[[email protected] Libexec]# ll check_redis.p*-rwxr-xr-x. 1 root root 15812 oct 10 2014 check_redis.php-rwxr-xr-x. 1 root root 141829 Oct 10 2014 check_redis.pl[[email protected] libexec]# ./check_redis.pl --helpcan ' t locate Redis.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/ Local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at ./check_redis.pl line 421.begin failed--compilation aborted at ./ check_redis.pl line 421. [[email protected] libexec]# perl -mcpan -e shellcpan[1]> install redis running build test make had Some problems, won ' t testrunning build install make had some Problems, won ' t installcould not read '/root/.cpan/build/redis-1.976-zhz6xi/meta.yml ' . falling back to other methods to determine prerequisites......cpan[2]> install yaml #可能会安装失败, the reason for the failure is the network connection, multiple execution will be successful. appending installation info to /usr/lib64/perl5/perllocal.pod tinita/ yaml-1.18.tar.gz /usr/bin/make install -- ok cpan: yaml loaded ok (v1.18) cpan[3]> install redisrunning build test make had some problems, won ' t testrunning build install make Had some problems, won ' t installcpan[4]> install build # build.pl failure, reinstall Install build, after successful, then execute INSTALL&NBSP;REDISRUNNING&NBSP;BUILD&NBSP;INSTALL&NBsp; make test had returned bad status, won ' t install without force ..... cpan[5]>q terminal does not support gethistory.lockfile removed. [[email protected] libexec]# yum -y install mod_perl2[[email protected] libexec]# perl -mcpan -e shellcpan[1]> install redis # This process will have a lot of interaction, directly enter the installing /usr/local/share/perl5/redis/list.pminstalling /usr/local/share/man/ man3/redis.3pminstalling /usr/local/share/man/man3/redis::hash.3pminstalling /usr/local/share/man/ Man3/redis::list.3pminstalling /usr/local/share/man/man3/redis::sentinel.3pm dams/redis-1.991.tar.gz ./build install -- okcpan[2]> q terminal does not support gethistory.lockfile removed. [[email protected] libexec]# ./check_redis.pl --helpgeneral and server Connection options:-h, --hostname=address hostname or ip address to check -p, --port=INTEGER port number (default: 6379) -D, --database=NAME optional database name (usually a Number), needed for --query but otherwise not needed -x, --password=string #redis有密码需要指定密码, redis.conf in requirepass behind is the password password for Redis authentication. Safer alternative is to put them in a file and use -c -c, --credentials=filename #可以将密码写在文件里, Read from Credentials file to read for Redis via-c Authentication -t, --timeout=number allows to set timeout for execution of this plugin. this overrides nagios default. -w, --warn=str[,str[,str[] [...]] -c, --crit=str[,str[,str[] [...]] .... variables and thresholds set as list: -a, --variables =string[,string[,string ...] #指定需要检测的项目, such as used_memory_human,connected_clients, are enclosed in single quotation marks and separated by semicolons. -w, --warn=str[,str[,str[] [...]] > - warn if data is above this value (default for numeric values) < - warn if data is below this value (Must be followed by number) = - warn if data is equal to this value (default for non-numeric values) ! - warn if data is not equal to this value ~ - do not check this data (must not be followed by number or ': ') ^ - for numeric values this disables check that warning < critical threshold values can also be specified as range in two forms: num1:num2 - warn if data is outside range i.e. if data<num1 or data>num2 @num1: num2 - warn if data is in range i.e. data>=num1 && data <=num2 -c, --crit=str[,str[,str[] [...]] performance data processing options: -f, -- perfparse [[email protected] libexec]#
In Nagios through command detection
Check_redis_cpu
[[email protected] libexec]# /usr/local/nagios/libexec/ Check_redis.pl -h 10.10.55.31 -p 6379 -a used_cpu_sys,used_cpu_user,used_cpu_sys _children,used_cpu_user_children -w ~,~,~,~ -c ~,~,~,~ -fok: redis 2.8.17 on 10.10.55.31:6379 has 2 databases (db2,db0) with 125792 keys, up 616 days 20 hours - used_cpu_sys is 62256.73, used_cpu_ User is 40052.36, used_cpu_sys_children is 81572.91, used_cpu_user_children is 405302.25 | used_cpu_sys_children=81572.91 used_cpu_sys=62256.73 used_cpu_ user_children=405302.25 used_cpu_user=40052.36[[email protected] libexec]#
~ No monitoring alarm thresholds defined
Check_redis_memory
[Email protected] libexec]#/usr/local/nagios/libexec/check_redis.pl-h 10.10.55.31-p 6379-a used_memory_human,used_ Memory_peak_human-w ~,~-C ~,~-fok:redis 2.8.17 on 10.10.55.31:6379 have 2 databases (DB2,DB0) with 125907 keys, up 616 Days Hours-used_memory_human is 763.85M, Used_memory_peak_human is 907.74M | used_memory_human=763.85m Used_memory_peak_human=907.74m[[email protected] libexec]#
Check_redis_clients
[[email protected] libexec]# /usr/local/nagios/libexec/ Check_redis.pl -h 10.10.55.31 -p 6379 -a connected_clients,blocked_clients, Client_longest_output_list,client_biggest_input_buf -w 200,50,~,~ -c 600,150,~,~ -fok : redis 2.8.17 on 10.10.55.31:6379 has 2 databases (db2,db0) with 125839 keys, up 616 days 20 hours - connected_clients is 47, blocked_clients is 0, client_longest_output_list is 0, client_ biggest_input_buf is 1769472 | blocked_clients=0;50;150 connected_clients=47;200;600 client_biggest_input_buf=1769472 client_longest_output_list=0[[email protected] libexec]#
by nagiosql to Check_redis command definition, add service, note define CHECK_REDIS command when command type is instrumentation command, not various commands
This article is from "I am not a rookie" blog, please be sure to keep this source http://pvbutler.blog.51cto.com/7662323/1845178
Nagios Monitoring Redis