如果你不想写代码那么就使用 ztc来监控 nginx吧
###监控nginx 需要服务器的 server-status 哦 不要忘记了 修改 nginx.conf 怎么修改
location ~ ^/NginxStatus/ {
location ~ ^/NginxStatus/ {
stub_status on;
access_log off;
allow 127.0.0.1;
allow 192.168.0.3; // Put your servers IPaddress instead of 192.168.0.3
deny all;
}
或者
# server {
# listen localhost:8080;
# server_name nginx_status.localhost;
# location /server-status {
# stub_status on;
# access_log off;
# allow 127.0.0.1;
# deny all;
# }
#}
# listen localhost:8080;
# server_name nginx_status.localhost;
# location /server-status {
# stub_status on;
# access_log off;
# allow 127.0.0.1;
# deny all;
# }
#}
1.修改配置文件
有关怎么安装配置请参考 zabbix监控 mysql
http://hi.baidu.com/wylinux/item/60d5ba7f2a7b3f306cc37c35
vi /etc/ztc/nginx.conf
[main]
##
# ZTC nginx template configuration file
#
# Make sure that nginx compiled with status module
# and it is enabled on some localtion or vhost
# e.g.:
# server {
# listen localhost:8080;
# server_name nginx_status.localhost;
# location /server-status {
# stub_status on;
# access_log off;
# allow 127.0.0.1;
# deny all;
# }
#}
proto=http
host=localhost
##
# ZTC nginx template configuration file
#
# Make sure that nginx compiled with status module
# and it is enabled on some localtion or vhost
# e.g.:
# server {
# listen localhost:8080;
# server_name nginx_status.localhost;
# location /server-status {
# stub_status on;
# access_log off;
# allow 127.0.0.1;
# deny all;
# }
#}
proto=http
host=localhost
#主机名
port=80
port=80
#端口号
resource=/nginx_status
###访问的url
timelog=/var/log/nginx/time.log
statuslog=/var/log/nginx/status.log
timelog=/var/log/nginx/time.log
statuslog=/var/log/nginx/status.log
2. 新建文件夹和 文件
1005 mkdir /var/log/nginx/
1006 touch /var/log/nginx/time.log
1007 touch /var/log/nginx/status.log
1005 mkdir /var/log/nginx/
1006 touch /var/log/nginx/time.log
1007 touch /var/log/nginx/status.log
mkdir /var/log/zabbix
chmod 777 /var/log/zabbix
设置文件权限
chmod 777 /var/log/nginx/time.log /var/log/nginx/status.log
3. 下面的命令随便挑一个测试是否可以正常使用
1018 /opt/ztc/bin/nginx.py status
1019 /opt/ztc/bin/nginx.py accepts
1020 /opt/ztc/bin/nginx.py requests
1021 /opt/ztc/bin/nginx.py connections_waiting
1019 /opt/ztc/bin/nginx.py accepts
1020 /opt/ztc/bin/nginx.py requests
1021 /opt/ztc/bin/nginx.py connections_waiting
实例
[root@zenossserver2 ~]# /opt/ztc/bin/nginx.py requests
9917
[root@zenossserver2 ~]#
[root@zenossserver2 ~]# /opt/ztc/bin/nginx.py requests
9917
[root@zenossserver2 ~]#
4.修改配置文件
vi /etc/zabbix/zabbix_agentd.conf
最后一行加上
最后一行加上
Include=/etc/zabbix-agent.d/
5.导入模块 监控 参考
http://hi.baidu.com/wylinux/item/60d5ba7f2a7b3f306cc37c35
6.重启agentd
1024 /etc/init.d/zabbix_agentd_ctl stop
1025 ps aux |grep zabbix
1026 /etc/init.d/zabbix_agentd_ctl start
7.在 zabbix 服务器上 对监控主机加上 nginx 模块
1025 ps aux |grep zabbix
1026 /etc/init.d/zabbix_agentd_ctl start
7.在 zabbix 服务器上 对监控主机加上 nginx 模块
配置 配置图表 over