您的位置:首页 > 数据库 > Memcache

nagios安装配置(六):监控nginx和memcache

2011-11-18 16:17 302 查看
一. nagios监控nginx

1. 下载

wget http://www.monitoringexchange.org/attachment/download/Check-Plugins/Software/check_nginx-sh/check_nginx.sh -P /usr/local/nagios/libexec/

2. 修改拥有者和权限

chown nagios:nagios /usr/local/nagios/libexec/check_nginx.sh && chmod a+x /usr/local/nagios/libexec/check_nginx.sh

3. nrpe配置文件添加命令

vi /usr/local/nagios/etc/nrpe.cfg
command[check_nginx]=/usr/local/nagios/libexec/check_nginx.sh -H hostip -P port -p /usr/local/nginx -n nginx.pid

4. 重载nrpe

service nrpe restart

5. 编辑nagios服务器文件

vi /usr/local/nagios/etc/linuxjcq/services.cfg
define service{
use                             local-service
host_name                       linuxjcq01
service_description             05. The Nginx Status
check_command                   check_nrpe!check_nginx
}

6. 重载nagios

service nagios restart

二. nagios监控memcached

1. 下载软件,如果以下链接不能下载,可以到http://search.cpan.org/搜索Nagios-Plugins-Memcached

wget http://cpan.wenzk.com/authors/id/Z/ZI/ZIGOROU/Nagios-Plugins-Memcached-0.02.tar.gz -P /usr/local/src

2. 安装

tar zxvf Nagios-Plugins-Memcached-0.02.tar.gz
cd Nagios-Plugins-Memcached-0.02
perl Makefile.PL

这边会列出模块的依赖安装情况,你可以根据提示选择y,进行自动安装,也可以通过自己手动安装,我使用后者

*** Module::AutoInstall version 1.03
*** Checking for Perl dependencies…
[Core Features]
– Carp::Clan …missing.
– Cache::Memcached …missing.
– FindBin …loaded. (1.47)
– Nagios::Plugin …missing.
– Time::HiRes …loaded. (1.9717)
==> Auto-install the 3 mandatory module(s) from CPAN? [y]

手动安装需要的模块

yum install perl-Carp-Clan perl-Cache-Memcached perl-Nagios-Plugin

之后,编译安装:

perl Makefile.PL
make
make install

3. nrpe配置文件添加命令

vi /usr/local/nagios/etc/nrpe.cfg
command[check_memcached_response]=/usr/bin/check_memcached -H ip:port -w 3 -c 5
command[check_memcached_size]=/usr/bin/check_memcached -H ip:port –size-warning 80 –size-critical 90
command[check_memcached_hit]=/usr/bin/check_memcached -H ip:port –hit-warning 40 –size-critical 20

将其中的ip和port修改为你的mecached的监听IP,port修改为端口号

重启nrpe

service nrpe restart

4. nagios服务配置文件修改

vi /usr/local/nagios/etc/linuxjcq/services.cfg
define service{
use                         local-service
host_name                   linuxjcq01
service_description         07. Memcached Reponse
check_command               check_nrpe!check_memcached_response
}

define service{
use                         local-service
host_name                   linuxjcq01
service_description         08. Memcached Size
check_command               check_nrpe!check_memcached_size
}

define service{
use                         local-service
host_name                   linuxjcq01
service_description         09. Memcached Hit
check_command               check_nrpe!check_memcached_hit
}

将其中的hostname修改成你配置文件中定义的主机名,重启nagios

service nagios restart


本文出自 “linuxjcq” 博客,请务必保留此出处http://linuxjcq.blog.51cto.com/3042600/718180
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: