Zabbix a custom template to monitor the number of TCP connections

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.