zabbix 端口监控 --- net.tcp.port

zabbix 端口监控很多方案,比如 net.tcp.listennet.tcp.port ,自定义等.
参考:
https://www.zabbix.com/documentation/3.4/manual/config/items/itemtypes/zabbix_agent

本文验证net.tcp.port是在 server端 还是在agent端 监测的。


net.tcp.listen[port]

Checks if this TCP port is in LISTEN state.

port - TCP port number

返回值:
0 - it is not in LISTEN state
1 - it is in LISTEN state

Example:

⇒ net.tcp.listen[80]

On Linux supported since Zabbix agent version 1.8.4

Since Zabbix 3.0.0, on Linux kernels 2.6.14 and above, information about listening TCP sockets is obtained from the kernel's NETLINK interface, if possible. Otherwise, the information is retrieved from /proc/net/tcp and /proc/net/tcp6 files.


net.tcp.port[,port]

Checks if it is possible to make TCP connection to specified port.

ip - IP address (default is 127.0.0.1)
port - port number

0 - cannot connect
1 - can connect

Example:
⇒ net.tcp.port[,80] → can be used to test availability of web server running on port 80.

For simple TCP performance testing use net.tcp.service.perf[tcp,,]

Note that these checks may result in additional messages in system daemon logfiles (SMTP and SSH sessions being logged usually).

Old naming: check_port[*]


实验

服务器 IP地址 连通状态
zabbix-server 10.98.201.16 与10.98.201.15不通
zabbix-agent 10.98.21.131 与10.98.201.15通
test-server 10.98.201.15 配置安全组,仅允许10.98.21.0/24网段访问
[sysadmin@VM_201_16_centos ~]$ ping 10.98.201.15
PING 10.98.201.15 (10.98.201.15) 56(84) bytes of data.
^C
--- 10.98.201.15 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 1999ms

[sysadmin@VM_201_16_centos ~]$ 

实验方案
第一组测试,验证net.tcp.port监测是在agent上完成的
第二组测试,验证net.tcp.port不设置IP参数,默认为127.0.0.1

在zabbix-server上执行测试命令

[sysadmin@VM_201_16_centos ~]$ zabbix_get -s 10.98.21.131 -p 10050 -k "net.tcp.port[10.98.201.15,22]"
1
[sysadmin@VM_201_16_centos ~]$ zabbix_get -s 10.98.21.131 -p 10050 -k "net.tcp.port[10.98.201.15,21]"
0

[sysadmin@VM_201_16_centos ~]$ zabbix_get -s 10.98.21.131 -p 10050 -k "net.tcp.port[10.98.21.131,11211]"
1
[sysadmin@VM_201_16_centos ~]$ zabbix_get -s 10.98.21.131 -p 10050 -k "net.tcp.port[,11211]"
1

你可能感兴趣的:(zabbix 端口监控 --- net.tcp.port)