nagios通过 Nagios-Plugins-Memcached插件监控memcached服务器
插件需要Perl语言支持,建议到cpan直接下载。
Nagios-Plugins-Memcached-0.02
http://search.cpan.org/CPAN/authors/id/Z/ZI/ZIGOROU/Nagios-Plugins-Memcached-0.02.tar.gz
1. 下载并安装插件
wget http://search.cpan.org/CPAN/authors/id/Z/ZI/ZIGOROU/Nagios-Plugins-Memcached-0.02.tar.gz
mv Nagios-Plugins-Memcached-0.02.tar.gz /usr/local/src
cd /usr/local/src
tar xzvf Nagios-Plugins-Memcached-0.02.tar.gz
cd Nagios-Plugins-Memcached-0.0.2
perl Makefile.pl
make install
2. 安装插件到nagios
cp -av `whereis check_memcached` /opt/nagios/libexec/
3. 检查插件是否可以正常工作
找一台可以连通的memcached服务器,这里用192.168.88.60来测试
# /opt/nagios/libexec/check_memcached -H 192.168.88.60
MEMCACHED OK - OK
4. 配置nagios监控系统
4.1 定义命令
修改objects/commands.cfg,增加如下内容:
# 'check_memcached' command definition
define command{
command_name check_memcached_response

command_line $USER1$/check_memcached -H $HOSTADDRESS$:$ARG1$ -w $ARG2$ -c $ARG3$
}

define command{
command_name check_memcached_size

command_line $USER1$/check_memcached -H $HOSTADDRESS$:$ARG1$ --size-warning $ARG2$ --size-critical $ARG3$
}

define command{
command_name check_memcached_hit

command_line $USER1$/check_memcached -H $HOSTADDRESS$:$ARG1$ --hit-warning $ARG2$ --hit-critical $ARG3$
}
4.2 定义主机和服务
添加文件objects/memcached_01.cfg文件
define host{
use linux-box-remote
host_name memcached_01
alias Memcached Server 01
address 192.168.88.60
}
define service{
use generic-service
host_name memcached_01
service_description Memcached01
check_command check_memcached_response!11211!30!40
}
define service{
use generic-service
host_name memcached_01
service_description Memcached02
check_command check_memcached_response!11212!30!40
}
define service{
use generic-service
host_name memcached_01
service_description Memcached01_size
check_command check_memcached_size!11211!30!40
}
define service{
use generic-service
host_name memcached_01
service_description Memcached02_size
check_command check_memcached_size!11212!30!40
}
define service{
use generic-service
host_name memcached_01
service_description Memcached01_hit
check_command check_memcached_hit!11211!40!30
}
define service{
use generic-service
host_name memcached_01
service_description Memcached02_hit
check_command check_memcached_hit!11212!40!30
}
4.3 在nagios.cfg中引用objects/memcached_01.cfg配置
vim /etc/nagios/nagios.cfg
增加下面的行:
cfg_file=/etc/nagios/objects/memcached_01.cfg
4.4 选项操作
推荐操作:
定义一个专门的服务器对象监控目录,如objects/servers
定义一个专门的服务对象监控目录,如objects/services
vim /etc/nagios/nagios.cfg
增加下面的行:
cfg_file=/etc/nagios/objects/objects/servers
cfg_file=/etc/nagios/objects/objects/services
根据实际需要添加必要的配置文件到这两个目录。
4.5 重新读取nagios配置并测试我们前边的操作
/etc/init.d/nagios reload
memcached监控页面
150401695.png