1. Use a script to obtain information about the number of TCP connections parameters
vim/usr/local/zabbix/etc/tcp_connections.sh #!/bin/bash #netstat-an | awk '/^tcp/{++s[$NF]} END {for (a in S) print A, S[a]} ' | Grep-w "established" |cut-d ""-f2 #netstat-an | awk '/^tcp/{++s[$NF]} END {for (a in S) print A, S[a]} ' | Grep-w "time_wait" |cut-d ""-f2 #netstat-an | awk '/^tcp/{++s[$NF]} END {for (a in S) print A, S[a]} ' |
Grep-w "LISTEN" |cut-d ""-f2 args=1 if [$#-ne "$ARGS"];then echo "please input one arguement:" Fi case $ in Established) result= ' Netstat-an | awk '/^tcp/{++s[$NF]} END {for (a in S) print A, S[a]} ' |
Grep-w "established" |cut-d "-f2 ' echo $result;; time_wait) result= ' Netstat-an | awk '/^tcp/{++s[$NF]} END {for (a in S) print A, S[a]} ' |
Grep-w "time_wait" |cut-d "-f2 ' echo $result;; LISTEN) result= ' Netstat-an | awk '/^tcp/{++s[$NF]} END {for (a in S) print A, S[a]} ' | Grep-w "LISTEN" |cut-d "-f2 ' echo $result;; *) echo "usage:$0 (time_wait| established|
LISTEN) ";;
Esac
2, modify the zabbix_agentd.conf, allow the custom key value
vim/usr/local/zabbix/etc/zabbix_agentd.conf
# Add the following
Unsafeuserparameters=1 # allow custom key values
Userparameter=tcp.status[*],/usr/local/zabbix/etc/tcp_connections.sh $
3. Log in to Zabbix Server and use Zabbix to test if you can get the custom key value correctly
[ROOT@ZABBIX-17 ~]# zabbix_get-s 192.168.1.48-p 10050-k "Tcp.status[listen]"
8 # successfully obtained key value
4, Login Zabbix Web side, configure the corresponding monitoring items can be