nagios监控nginx状态
本帖最后由 kjut 于 2014-10-15 08:36 编辑1、服务器与被监控主机安装组件
yum install bc
编译安装nrpe(参考教程:http://www.iyunv.com/thread-26032-1-1.html)
以下为被监控主机设置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=/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)内容如下
****************************************我是分割线************************************
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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_descriptionotal_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
}
****************************************我也是分割线************************************
暂时写到这里,明天在做整理
页:
[1]