Zabbix如何监控自定义的各项指标?

2026-05-28 01:311阅读0评论SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计1263个文字,预计阅读时间需要6分钟。

Zabbix如何监控自定义的各项指标?

文章目录

一、手动命令行监控方法

1.需要监控的TCP十一种状态

2.命令行监控

1. 手动批量创建自定义监控项 1. 将十一种状态写入一个文件


文章目录

  • ​​一、手动命令行监控方法​​
  • ​​1、需要监控的tcp十一种状态​​
  • ​​2、命令行监控​​
  • ​​二、手动批量创建自定义监控项​​
  • ​​1、将十一种状态写入一个文件​​
  • ​​2、使用循环创建子配置文件,自定义监控项key​​
  • ​​3、重启测试​​
  • ​​4、web页面添加自定义监控项​​
  • ​​1)创建应用集​​
  • ​​2)创建监控项​​
  • ​​三、抓包循环创建自定义监控项​​
  • ​​1、获取添加监控项请求数据​​
  • ​​1) 添加监控项请求url:​​
  • ​​2)添加监控项请求原始数据​​
  • ​​2、获取登录请求数据​​
  • ​​1)登录的url​​
  • ​​2)登录请求原始数据​​
  • ​​3、获取cookie和sid​​
  • ​​1)安装apache,启动​​
  • ​​2)获取html页面,保留cookie​​
  • ​​3)通过apache查看页面​​
  • ​​4)查看cookie​​
  • ​​5)获取新的sid​​
  • ​​6)替换添加监控项请求数据的sid、key值为$n​​
  • ​​7)将剩下的key值写到一个文件当中​​
  • ​​8)书写for循环​​
  • ​​9)刷新页面查看监控项​​

一、手动命令行监控方法

1、需要监控的tcp十一种状态

ESTABLISHED
SYN_SENT
SYN_RECV
FIN_WAIT1
FIN_WAIT2
TIME_WAIT
CLOSE
CLOSE_WAIT
LAST_ACK
LISTEN
CLOSING

2、命令行监控

[root@web01 ~]# netstat -ant|grep -c ESTABLISHED
1

[root@web01 ~]# netstat -ant|grep -c SYN_SENT
0
....

二、手动批量创建自定义监控项

1、将十一种状态写入一个文件

[root@zabbix ~]# vim tcps.txt

2、使用循环创建子配置文件,自定义监控项key

[root@zabbix ~]# for n in `cat tcps.txt`; do echo "UserParameter=$n,netstat -ant |grep -c $n">>/etc/zabbix/zabbix_agentd.d/user_def.conf ;done
[root@zabbix ~]# cat /etc/zabbix/zabbix_agentd.d/user_def.conf
1 UserParameter=ESTABLISHED,netstat -ant |grep -c ESTABLISHED
2 UserParameter=SYN_SENT,netstat -ant |grep -c SYN_SENT
3 UserParameter=SYN_RECV,netstat -ant |grep -c SYN_RECV
4 UserParameter=FIN_WAIT1,netstat -ant |grep -c FIN_WAIT1
5 UserParameter=FIN_WAIT2,netstat -ant |grep -c FIN_WAIT2
6 UserParameter=TIME_WAIT,netstat -ant |grep -c TIME_WAIT
7 UserParameter=CLOSE,netstat -ant |grep -c CLOSE
8 UserParameter=CLOSE_WAIT,netstat -ant |grep -c CLOSE_WAIT
9 UserParameter=LAST_ACK,netstat -ant |grep -c LAST_ACK
10 UserParameter=LISTEN,netstat -ant |grep -c LISTEN
11 UserParameter=CLOSING,netstat -ant |grep -c CLOSING


格式:UserParameter=名,值

3、重启测试

[root@zabbix ~]# systemctl restart zabbix-agent.service
[root@zabbix ~]# zabbix_get -s 127.0.0.1 -k TIME_WAIT
42

4、web页面添加自定义监控项

1)创建应用集

2)创建监控项

Zabbix如何监控自定义的各项指标?

剩下十个同上

三、抓包循环创建自定义监控项

1、获取添加监控项请求数据

1) 添加监控项请求url:

10.0.0.71/zabbix/items.php

2)添加监控项请求原始数据

sid=fe3fd5f8f595d727&form_refresh=1&form=create&hostid=10084&selectedInterfaceId=0&name=ESTABLISHED%E7%8A%B6%E6%80%81%E7%9A%84%E6%95%B0%E9%87%8F&type=0&key=ESTABLISHED&url=&query_fields%5Bname%5D%5B1%5D=&query_fields%5Bvalue%5D%5B1%5D=&timeout=3s&post_type=0&posts=&headers%5Bname%5D%5B1%5D=&headers%5Bvalue%5D%5B1%5D=&status_codes=200&follow_redirects=1&retrieve_mode=0&10.0.0.71/zabbix/index.php

2)登录请求原始数据

name=Admin&password=123456&autologin=1&enter=Sign+in
改成正确密码
name=Admin&password=zabbix&autologin=1&enter=Sign+in

3、获取cookie和sid

1)安装apache,启动

yum install -y 10.0.0.71/zabbix/index.php >test.html

3)通过apache查看页面

#1.先把test.html文件移动到apache的站点目录
[root@web03 ~]# mv test.html /var/www/html/
#2.重启curl.haxx.se/docs/10.0.0.71/zabbix/items.php >123.html

[root@zabbix /var/www/html]# grep -i sid test.html

6)替换添加监控项请求数据的sid、key值为$n

sid=50abf6594d1b16df&form_refresh=1&form=create&hostid=10084&selectedInterfaceId=0&name=${n}%E7%8A%B6%E6%80%81%E7%9A%84%E6%95%B0%E9%87%8F&type=0&key=${n}&url=&query_fields%5Bname%5D%5B1%5D=&query_fields%5Bvalue%5D%5B1%5D=&timeout=3s&post_type=0&posts=&headers%5Bname%5D%5B1%5D=&headers%5Bvalue%5D%5B1%5D=&status_codes=200&follow_redirects=1&retrieve_mode=0&10.0.0.71/zabbix/items.php ;done

9)刷新页面查看监控项


本文共计1263个文字,预计阅读时间需要6分钟。

Zabbix如何监控自定义的各项指标?

文章目录

一、手动命令行监控方法

1.需要监控的TCP十一种状态

2.命令行监控

1. 手动批量创建自定义监控项 1. 将十一种状态写入一个文件


文章目录

  • ​​一、手动命令行监控方法​​
  • ​​1、需要监控的tcp十一种状态​​
  • ​​2、命令行监控​​
  • ​​二、手动批量创建自定义监控项​​
  • ​​1、将十一种状态写入一个文件​​
  • ​​2、使用循环创建子配置文件,自定义监控项key​​
  • ​​3、重启测试​​
  • ​​4、web页面添加自定义监控项​​
  • ​​1)创建应用集​​
  • ​​2)创建监控项​​
  • ​​三、抓包循环创建自定义监控项​​
  • ​​1、获取添加监控项请求数据​​
  • ​​1) 添加监控项请求url:​​
  • ​​2)添加监控项请求原始数据​​
  • ​​2、获取登录请求数据​​
  • ​​1)登录的url​​
  • ​​2)登录请求原始数据​​
  • ​​3、获取cookie和sid​​
  • ​​1)安装apache,启动​​
  • ​​2)获取html页面,保留cookie​​
  • ​​3)通过apache查看页面​​
  • ​​4)查看cookie​​
  • ​​5)获取新的sid​​
  • ​​6)替换添加监控项请求数据的sid、key值为$n​​
  • ​​7)将剩下的key值写到一个文件当中​​
  • ​​8)书写for循环​​
  • ​​9)刷新页面查看监控项​​

一、手动命令行监控方法

1、需要监控的tcp十一种状态

ESTABLISHED
SYN_SENT
SYN_RECV
FIN_WAIT1
FIN_WAIT2
TIME_WAIT
CLOSE
CLOSE_WAIT
LAST_ACK
LISTEN
CLOSING

2、命令行监控

[root@web01 ~]# netstat -ant|grep -c ESTABLISHED
1

[root@web01 ~]# netstat -ant|grep -c SYN_SENT
0
....

二、手动批量创建自定义监控项

1、将十一种状态写入一个文件

[root@zabbix ~]# vim tcps.txt

2、使用循环创建子配置文件,自定义监控项key

[root@zabbix ~]# for n in `cat tcps.txt`; do echo "UserParameter=$n,netstat -ant |grep -c $n">>/etc/zabbix/zabbix_agentd.d/user_def.conf ;done
[root@zabbix ~]# cat /etc/zabbix/zabbix_agentd.d/user_def.conf
1 UserParameter=ESTABLISHED,netstat -ant |grep -c ESTABLISHED
2 UserParameter=SYN_SENT,netstat -ant |grep -c SYN_SENT
3 UserParameter=SYN_RECV,netstat -ant |grep -c SYN_RECV
4 UserParameter=FIN_WAIT1,netstat -ant |grep -c FIN_WAIT1
5 UserParameter=FIN_WAIT2,netstat -ant |grep -c FIN_WAIT2
6 UserParameter=TIME_WAIT,netstat -ant |grep -c TIME_WAIT
7 UserParameter=CLOSE,netstat -ant |grep -c CLOSE
8 UserParameter=CLOSE_WAIT,netstat -ant |grep -c CLOSE_WAIT
9 UserParameter=LAST_ACK,netstat -ant |grep -c LAST_ACK
10 UserParameter=LISTEN,netstat -ant |grep -c LISTEN
11 UserParameter=CLOSING,netstat -ant |grep -c CLOSING


格式:UserParameter=名,值

3、重启测试

[root@zabbix ~]# systemctl restart zabbix-agent.service
[root@zabbix ~]# zabbix_get -s 127.0.0.1 -k TIME_WAIT
42

4、web页面添加自定义监控项

1)创建应用集

2)创建监控项

Zabbix如何监控自定义的各项指标?

剩下十个同上

三、抓包循环创建自定义监控项

1、获取添加监控项请求数据

1) 添加监控项请求url:

10.0.0.71/zabbix/items.php

2)添加监控项请求原始数据

sid=fe3fd5f8f595d727&form_refresh=1&form=create&hostid=10084&selectedInterfaceId=0&name=ESTABLISHED%E7%8A%B6%E6%80%81%E7%9A%84%E6%95%B0%E9%87%8F&type=0&key=ESTABLISHED&url=&query_fields%5Bname%5D%5B1%5D=&query_fields%5Bvalue%5D%5B1%5D=&timeout=3s&post_type=0&posts=&headers%5Bname%5D%5B1%5D=&headers%5Bvalue%5D%5B1%5D=&status_codes=200&follow_redirects=1&retrieve_mode=0&10.0.0.71/zabbix/index.php

2)登录请求原始数据

name=Admin&password=123456&autologin=1&enter=Sign+in
改成正确密码
name=Admin&password=zabbix&autologin=1&enter=Sign+in

3、获取cookie和sid

1)安装apache,启动

yum install -y 10.0.0.71/zabbix/index.php >test.html

3)通过apache查看页面

#1.先把test.html文件移动到apache的站点目录
[root@web03 ~]# mv test.html /var/www/html/
#2.重启curl.haxx.se/docs/10.0.0.71/zabbix/items.php >123.html

[root@zabbix /var/www/html]# grep -i sid test.html

6)替换添加监控项请求数据的sid、key值为$n

sid=50abf6594d1b16df&form_refresh=1&form=create&hostid=10084&selectedInterfaceId=0&name=${n}%E7%8A%B6%E6%80%81%E7%9A%84%E6%95%B0%E9%87%8F&type=0&key=${n}&url=&query_fields%5Bname%5D%5B1%5D=&query_fields%5Bvalue%5D%5B1%5D=&timeout=3s&post_type=0&posts=&headers%5Bname%5D%5B1%5D=&headers%5Bvalue%5D%5B1%5D=&status_codes=200&follow_redirects=1&retrieve_mode=0&10.0.0.71/zabbix/items.php ;done

9)刷新页面查看监控项