Skip to content


nagios监控memcached

Nagios的check_memcached
下载地址:

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

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


#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
#cd 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/

测试
/usr/local/nagios/libexec/check_memcached -H192.168.0.40:12111
MEMCACHED OK – OK
如果提示没有Nagios::Plugin

可以通过CPAN来安装perl-nagios-plugin

perl -MCPAN -e shell
install File::Slurp
install YAML
install HTML::Parser
install URI
install Compress::Zlib
install Module::Runtime
install Module::Implementation
install Attribute::Handlers
install Params::Validate
install Nagios::Plugin

重新配置cpan的命令为”o conf init”

测试通过后修改nagios commands.cfg配置文件.加上这些内容:

define command {
command_name check_memcached_response
command_line $USER1$/check_memcached -H $ARG1$:$ARG2$ -w $ARG3$ -c $ARG4$
}
define command {
command_name check_memcached_size
command_line $USER1$/check_memcached -H $ARG1$:$ARG2$ –size-warning $ARG3$ –size-critical $ARG4$
}

define command {
command_name check_memcached_hit
command_line $USER1$/check_memcached -H $ARG1$:$ARG2$ –hit-warning $ARG3$ –hit-critical $ARG4$
}

然后在需监控主机的cfg配置文件里加上:

define service{
use local-service,srv-pnp ; Name of service template to use
host_name memcachedserver
service_description Memcached_response
check_command check_memcached_response!192.168.0.40!12111!300!500
}
define service{
use local-service,srv-pnp ; Name of service template to use
host_name memcachedserver
service_description Memcached_size
check_command check_memcached_size!192.168.0.40!12111!90!95
}
define service{
use local-service,srv-pnp ; Name of service template to use
host_name memcachedserver
service_description Memcached_hit
check_command check_memcached_hit!192.168.0.40!12111!10!5
}

/etc/init.d/nagios reload
重新reload后就可以看到,目前此插件不支持pnp作图

参考:http://simblog.vicp.net/?p=250
http://blog.csdn.net/deccmtd/article/details/6799647

Posted in Nagios.


No Responses (yet)

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.