zabbix application monitoring practice

zabbix tcp monitor
connection status Tcp for our web servers is critical, especially concurrency ESTAB; or syn_recv value, if this value is relatively large, then we can say that is not under attack, or the value is time_wait relatively high, we have to consider whether we need to tune the kernel, then time_wait value is too high, take up too much port, if the port less then lead to disastrous consequences: so today we come to learn how to use Zabbix monitoring tcp state

1.编写shell脚本
cd /server/scripts/
vim tcp_status.sh
#!/bin/sh
[ $# -ne 1 ] && echo "Usage:CLOSE-WAIT|CLOSED|CLOSING|ESTAB|FIN-WAIT-1|FIN-WAIT-2|LAST-ACK|LISTEN|SYN-RECV SYN-SENT|TIME-WAIT" && exit 1
tcp_status_fun(){
TCP_STAT=$1
ss -ant | awk 'NR>1 {++s[$1]} END {for(k in s) print k,s[k]}' > /tmp/ss.txt
TCP_STAT_VALUE=$(grep "$TCP_STAT" /tmp/ss.txt | cut -d ' ' -f2)
if [ -z "$TCP_STAT_VALUE" ];then
TCP_STAT_VALUE=0
fi
echo $TCP_STAT_VALUE
}
tcp_status_fun $1;

Add execute permissions
chmod + x tcp_status.sh

2. tcp_status.conf monitored item profile as
UserParameter = tcp_status [*], / bin / bash /server/scripts/tcp_status.sh "$ 1"

3. Restart zabbix-agent modify the configuration file must restart
systemctl restart zabbix-agent

Agent can test whether 4.Server to get value by Zabbix_get (Do not execute scripts directly)
[root @ zabbix-Server ~] # zabbix_get -s 10.0.0.7 -k tcp_status [ESTAB]
2

5.5. Adding all monitoring items (remember the template associated with the host)

Guess you like

Origin www.cnblogs.com/bidad/p/11613640.html