码迷,mamicode.com
首页 > 移动开发 > 详细

nagios监控nginx状态

时间:2014-10-14 20:55:59      阅读:279      评论:0      收藏:0      [点我收藏+]

标签:nagios   check_nginx   

1、服务器与被监控主机安装组件

   yum install bc

   编译安装nrpe(参考教程:http://2860664.blog.51cto.com/2850664/1559056

以下为被监控主机设置

2、下载监控脚本 check_nginx.sh,并上传到被监控主机的 /usr/local/nagios/libexec目录

   下载地址:http://exchange.nagios.org/components/com_mtree/attachment.php?link_id=622&cf_id=24

   给予脚本可执行权限

   chmod +x /usr/local/nagios/libexec/check_nginx.sh

3、vi /usr/local/nagios/etc/nrpe.cfg  添加

   command[check_nginx]=/usr/local/nagios/libexec/check_nginx.sh -H www.xxx.com -P 80 -p /usr/local/nginx/logs/ -n nginx.pid -s nginx_status -w 15000 -c 20000

   其中红色为你要监控的网站;

   绿色为nginx.pid的保存路径,可以在nginx.conf中添加:pid        /usr/local/nginx/logs/nginx.pid;进行设置,切记

4、测试脚本运行

   cd /usr/local/nagios/libexec

   ./check_nginx.sh -H www.xxx.com -P 80 -p /usr/local/nginx/logs/ -n nginx.pid -s nginx_status -w 15000 -c 20000

OK - nginx is running. 1 requests per second, 1 connections per second (1.00 requests per connection) | ‘reqpsec‘=1 ‘conpsec‘=1 ‘conpreq‘=1.00 ]

以下为监控主机设置

5、vi /usr/local/nagios/etc/nagios.cfg  添加

   cfg_file=/usr/local/nagios/etc/objects/nginx.cfg

6、touch /usr/local/nagios/etc/objects/nginx.cfg

   vi /usr/local/nagios/etc/objects/nginx.cfg  (注意修改被监控端的IP)内容如下  


****************************************我是分割线************************************

define host{
           use             linux-server
          host_name     nginx
          alias         nginx
          address       被监控端IP
        }
define service{
        use                      generic-service
        host_name             nginx
        service_description     check-swap
        check_command        check_nrpe!check_swap
               }
define service{
        use                      generic-service
        host_name             nginx
        service_description     check-load
       check_command         check_nrpe!check_load
               }
define service{
        use                      generic-service
        host_name             nginx
       service_description     check-disk
       check_command        check_nrpe!check_sda1
               }
define service{
        use                      generic-service
        host_name             nginx
       service_description     check-users
       check_command        check_nrpe!check_users
               }
define service{
        use                    generic-service
        host_name           nginx
        service_description  otal_procs
        check_command     check_nrpe!check_total_procs
}
define service{
        use                             generic-service         ; Name of service template to use
        host_name                       nginx
        service_description             PING
        check_command                   check_ping!100.0,20%!500.0,60%
        }
define service{
    use                     generic-service
    host_name               nginx
    service_description     nginx_status
    check_command           check_nrpe!check_nginx!ip!80!/usr/local/nginx/sbin/nginx!nginx.pid!nginx_status!/tmp!15000!20000
        notifications_enabled           0
        }

****************************************我也是分割线************************************

暂时写到这里,明天在做整理

本文出自 “linux相关分享” 博客,请务必保留此出处http://2860664.blog.51cto.com/2850664/1564000

nagios监控nginx状态

标签:nagios   check_nginx   

原文地址:http://2860664.blog.51cto.com/2850664/1564000

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!