Zabbix Auto-Discovery uses in-port and graphically shows the number of connections for each port

Source: Internet
Author: User

Zabbix automatically discovers the ports in use in the current server and graphically shows the number of ports connected to each port

1. Modify the configuration file

Vi/data/server/zabbix_agent/conf/zabbix_agentd.conf

Userparameter=tcp.port.discovery,/data/server/zabbix/bin/discover_tcp_port_count Tcp_port_discovery

Userparameter=tcp.port.count[*],/data/server/zabbix/bin/discover_tcp_port_count Tcp_port_count $


2. Automatic Discovery Scripts

VI Discover_tcp_port_count

#!/bin/bash

SOURCE/ETC/BASHRC >/dev/null 2>&1

Source/etc/profile >/dev/null 2>&1

Tcp_port_discovery () {

tcp_port= (' netstat-tnlp|egrep-i ' $ "|awk {' Print $4 '}|awk-f ': ' {if ($NF ~/^[0-9]*$/) print $NF} ' |sort |uniq 2>/dev/n Ull ')

printf ' {\ n '

printf ' \ t ' data: [\ n '

For ((i=0;i<${#tcp_port [@]};++i))

{

num=$ (echo$ (${#tcp_port [@]}-1))

If ["$i"! = ${num}]; Then

printf "\t\t{\ n"

printf "\t\t\t\" {#PORTNUM}\ ": \" ${tcp_port[$i]}\ "},\n"

Else

printf "\t\t{\ n"

printf "\t\t\t\" {#PORTNUM}\ ": \" ${tcp_port[$num]}\ "}]}\n"

Fi

}

}

Tcp_port_count () {

#/usr/bin/curl-o/dev/null-s-W%{http_code} http://$1

NETSTAT-ATNL |grep $ |wc-l

}

Case "$" in

Tcp_port_discovery)

Tcp_port_discovery

;;

Tcp_port_count)

Tcp_port_count$2

;;

*)

echo "usage:$0 {Tcp_port_discovery|tcp_port_count [port]}"

;;

Esac

3. Restart Agentd

4. Verification

./zabbix_get-s192.168.0.7-p 10050-k "Tcp.port.discovery"

./zabbix_get-s192.168.0.7 -P 10050-k "tcp.port.count[8080]"


5.server Web page configuration (configuration template or single host)

1) Create an app set

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/54/91/wKioL1SGo--AiCSRAAImCk_QaxU408.jpg "title=" 1.png " alt= "Wkiol1sgo--aicsraaimck_qaxu408.jpg"/>

2) Create a discovery rule

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/54/92/wKiom1SGo2nCHfcUAAMJdespwwQ370.jpg "title=" 2.png " alt= "Wkiom1sgo2nchfcuaamjdespwwq370.jpg"/>


3) Create a project monitoring prototype

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/54/92/wKiom1SGo3bwTWQ4AAMBlzMzNIU707.jpg "title=" 3.png " alt= "Wkiom1sgo3bwtwq4aamblzmzniu707.jpg"/>


4) Add graphic prototypes

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/54/91/wKioL1SGpBTxxdvbAAMNkTmtGrE495.jpg "title=" 4.png " alt= "Wkiol1sgpbtxxdvbaamnktmtgre495.jpg"/>

This article is from the "XFICC" blog, make sure to keep this source http://xficc.blog.51cto.com/1189288/1587948

Zabbix Auto-Discovery uses in-port and graphically shows the number of connections for each port

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.