Nagios监控memcached

Nagios的check_memcached

这个插件可以装在memcached服务器上,也可以装在Nagios服务器上,我是直接装在Nagios服务器上这样方便一些.


下载地址:

http://search.cpan.org/CPAN/authors/id/Z/ZI/ZIGOROU/Nagios-Plugins-Memcached-0.02.tar.gz 

这个脚本是用perl编的,所以你要先确保自己的机器里面是否有perl环境.

安装方法:

#cd /usr/local/src/tarbag
#wget http://search.cpan.org/CPAN/authors/id/Z/ZI/ZIGOROU/Nagios-Plugins-Memcached-0.02.tar.gz 
#tar xzvf Nagios-Plugins-Memcached-0.02.tar.gz -C ../software
#cd ../software/Nagios-Plugins-Memcached-0.02
#perl Makefile.PL

执行后会出现一些提示让你选择,一路回车

#make

这时会下载一些运行时需要的东西

#make install

默认会把check_memcached文件放到/usr/bin/check_memcached

做个软链接抟到Nagios libexec目录下.

ln -s /usr/bin/check_memcached  /usr/local/nagios/libexec/
修改nagios commands.cfg配置文件.加上这些内容:

#Memcached
### check response time(msec) for memcached  
define command {  
        command_name check_memcached_response  
        command_line /usr/local/nagios/libexec/check_memcached -H $HOSTADDRESS$:12000 -w $ARG1$ -c $ARG2$  
        }  
 
### check cache size ratio(bytes/limit_maxbytes[%]) for memcached  
define command {  
        command_name check_memcached_size  
        command_line /usr/local/nagios/libexec/check_memcached -H $HOSTADDRESS$:12000 --size-warning $ARG1$ --size-critical $ARG2$  
        }  
 
### check cache hit ratio(get_hits/cmd_get[%]) for memcached  
define command {  
        command_name check_memcached_hit  
        command_line /usr/local/nagios/libexec/check_memcached -H $HOSTADDRESS$:12000 --hit-warning $ARG1$ --hit-critical $ARG2$  
        }  

12000端口是我的memcached端口.

然后在memcached主机的cfg配置文件里加上:

#Memcached
define service{
        use                                local-service ;                         Name of service template to use
        host_name                          10.0.0.204
        service_description                Memcached_response
        check_command                      check_memcached_response!300!500
        }
define service{  
        use                             local-service ;           Name of service template to use  
        host_name                       10.0.0.204  
        service_description             Memcached_size  
        check_command                   check_memcached_size!90!95  
        }  
define service{  
        use                             local-service ;                 Name of service template to use  
        host_name                       10.0.0.204  
        service_description             Memcached_hit  
        check_command                   check_memcached_hit!10!5  
        }

最后重启下Nagios. 搞定!


你可能感兴趣的:(Nagios监控memcached)