zabbix监控磁盘IO(二)
本帖最后由 34212131 于 2017-1-12 09:03 编辑1.nginx配置增加状态
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
vim nginx_status.conf
server {
listen*:81 default_server;
server_name _;
location /nginx_status {
stub_status on;
access_log off;
}
location /upstream_status {
check_status;
access_log off;
}
location /req_status_server {
req_status_show server;
access_log off;
}
#location /req_status_url {
# req_status_show url;
# access_log off;
#}
}
2.测试访问
1
2
3
4
5
# curl http://localhost:81/nginx_status
Active connections: 573
server accepts handled requests request_time
146168002 146168002 195194137 12912677608
Reading: 0 Writing: 13 Waiting: 560
3.创建监控脚本
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
vim nginx_stat.sh
#!/bin/bash
HOST="127.0.0.1"
PORT="81"
function ping {
/sbin/pidof nginx | wc -l
}
function active {
/usr/bin/curl "http://${HOST}:${PORT}/nginx_status/" 2>/dev/null| grep 'Active' | awk '{print $NF}'
}
function reading {
/usr/bin/curl "http://${HOST}:${PORT}/nginx_status/" 2>/dev/null| grep 'Reading' | awk '{print $2}'
}
function writing {
/usr/bin/curl "http://${HOST}:${PORT}/nginx_status/" 2>/dev/null| grep 'Writing' | awk '{print $4}'
}
function waiting {
/usr/bin/curl "http://${HOST}:${PORT}/nginx_status/" 2>/dev/null| grep 'Waiting' | awk '{print $6}'
}
function accepts {
/usr/bin/curl "http://${HOST}:${PORT}/nginx_status/" 2>/dev/null| awk NR==3 | awk '{print $1}'
}
function handled {
/usr/bin/curl "http://${HOST}:${PORT}/nginx_status/" 2>/dev/null| awk NR==3 | awk '{print $2}'
}
function requests {
/usr/bin/curl "http://${HOST}:${PORT}/nginx_status/" 2>/dev/null| awk NR==3 | awk '{print $3}'
}
$1
4.增加配置文件参数
1
2
vim /usr/local/zabbix-agent/etc/zabbix_agentd.conf
UserParameter=nginx.status[*],/bin/bash /usr/local/zabbix-agent/scripts/nginx_stat.sh $1
5.重启进程
1
/etc/init.d/zabbix_agentd restart
6.增加模板
7.增加item
8.增加监控图像
9.查看监控
标题跟内容完全不搭啊
页:
[1]