使用nagios监控memcached
监控memcached需要一些perl的modules
- Nagios::Plugin
- Nagios::Plugins::Memcached
- Cache::memcached
- Carp::Clan
- Class::Accessor::Fast
- Config::Tiny
- Math::Calc::Units
- Module::Build
- Params::Validate
Perl的modules的安装步骤都一样,
- #perl Makefile.PL
- #make
- #make install
配置nagios
安装完Nagios::Plugins::Memcached后,监控程序会安装在/usr/bin/check_memcached,可以链接到nagios目录下,也可以直接使用
- #ln –s /usr/bin/check_memcached /usr/local/nagios/libexec/check_memcached
接下来配置nagios的command.cfg文件
- #vi /usr/local/nagios/etc/objects/command.cfg
加入如下内容:
- ### check response time(msec) for memcached
- define command {
- command_name check_memcached_response
- command_line /usr/bin/check_memcached -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$
- }
- ### check cache size ratio(bytes/limit_maxbytes[%]) for memcached
- define command {
- command_name check_memcached_size
- command_line /usr/bin/check_memcached -H $HOSTADDRESS$ --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/bin/check_memcached -H $HOSTADDRESS$ --hit-warning $ARG1$ --size-critical $ARG2$
- }
然后编辑memcached服务端主机配置文件memcached.cfg
- #vi /usr/local/nagios/etc/objects/memcached.cfg
加入如下内容,其中阀值可以自己设置:
define service{
use local-service ; Name of service template to use
host_name localhost
service_description memcached_response
check_command check_memcached_response!300!500
}
- define service{
- use local-service ; Name of service template to use
- host_name localhost
- service_description memcached_size
- check_command check_memcached_size!90!95
- }
- define service{
- use local-service ; Name of service template to use
- host_name localhost
- service_description memcached_hit
- check_command check_memcached_hit!10!5
重启nagios就可以了。如何使用Nagios监控memcached就讲述到这里。
【编辑推荐】