Take advantage of the noon break to write a blog.
Recently I have a headache is the company's network monitoring, do not know what solution to use, a large network failure occurred, Mister first time asked how no monitoring, this pot really bad dump. There are plans to spend money, but they are not the first choice for OPS. How to find a practical solution from the Open source field?
-
Write a script, the national node in each computer room pumping two machine run scripts, management difficulty;
-
Smokeping, a set, it is necessary, but the alarm is not good aggregation and grading, there is no way to make a general forecast;
-
Write a template with Zabbix to replace the smokeping, optimistic Zabbix alarm aggregation grading function;
Zabbix-trapper: This is a way of data transfer, unlike Zabbix-agent, which defines an item that needs to use Zabbix-sender to send data to Zabbix-server
(Original: http://wuhf2015.blog.51cto.com/8213008/1766184)
Zabbix-sender the required parameters:
-Z-Specifies the IP of the Zabbix server
-P-Specifies the port of the Zabbix server, which defaults to 10051
-S-Specify target host, hostname must be hostname in configuration instead of visible name, remember
-K-Specify key, we define the trapper key, here is the trap we defined earlier
-O-Specify the data to be passed
Using fping to detect the packet loss rate of each node
Parameters of the fping:
-B Ping Packet size
Number of-C pings
-P ping interval, unit ms
Scripts placed in the server-side externalscripts:
#!/bin/bash
#
ZBXSERVER=127.0.0.1
FPING=/usr/sbin/fping
ZBXSENDER=/usr/local/zabbix/bin/zabbix_sender
# Where to send ping
IP=$1
# How many ping to send
COUNT=$2
# What interval between ping [ms]
INTERVAL=$3
# How many bytes in one ping
BYTES=$4
# ‘Hostname‘ of the host which will collect data
HOSTNAME=$5
if [ $# -lt 5 ]
then
echo
echo " Not enough parameters"
echo " Usage: zbxsmokeping <HOST_IP> <NUMBERS_OF_PINGS> <INTERVAL> <BYTES> <TO_WHICH_HOST_SEND_DATA_IN_ZABBIX>"
echo " Zabbix External Check Item ex.: zbxsmokeping[{HOST.IP},6,1000,68,{HOST.HOST}]"
exit 2
fi
# debug
#echo $FPING -b $BYTES -c $COUNT -q -p $INTERVAL $IP 2>&1
OUTPUT=`$FPING -b $BYTES -c $COUNT -q -p $INTERVAL $IP 2>&1 | awk ‘{print $5,$8}‘ | tr -d "%|," | tr -s " " "/" | awk -F"/" ‘{print $3,$4,$5,$6}‘`
tab=($OUTPUT)
#echo ${tab[3]}
# debug
# echo $ZBXSENDER -z $ZBXSERVER -p 10051 -s $HOSTNAME -k PrimaryLoss -o ${tab[0]}
# echo $ZBXSENDER -z $ZBXSERVER -p 10051 -s $HOSTNAME -k PrimaryLatencyMin -o ${tab[1]}
# echo $ZBXSENDER -z $ZBXSERVER -p 10051 -s $HOSTNAME -k PrimaryLatencyMax -o ${tab[3]}
# echo $ZBXSENDER -z $ZBXSERVER -p 10051 -s $HOSTNAME -k PrimaryLatencyAvg -o ${tab[2]}
$ZBXSENDER -z $ZBXSERVER -p 10051 -s $HOSTNAME -k SmokLoos -o ${tab[0]} -v | grep "failed: 1" &> /dev/null
$ZBXSENDER -z $ZBXSERVER -p 10051 -s $HOSTNAME -k SmokLatencyMin -o ${tab[1]} -v | grep "failed: 1" &>/dev/null
$ZBXSENDER -z $ZBXSERVER -p 10051 -s $HOSTNAME -k SmokLatencyMax -o ${tab[3]} -v |grep "failed: 1" &>/dev/null
$ZBXSENDER -z $ZBXSERVER -p 10051 -s $HOSTNAME -k SmokLatencyAvg -o ${tab[2]} -v | grep "failed: 1" &>/dev/null
The script gives execute permissions and the owner, the template mounts on the node that needs probing, and does not need to define a key-value pair on each node.
Items in the template:
Trigger values in the template:
Diagram in the template:
Above our Zabbix form of smokeping has been established, the following will be used to Zabbix correlation trigger and the means to set up the backbone of the monitoring of the network.
1. Each computer room is divided into a group, on the basis of a group to set a packet loss rate average of it
2. Set the alert point for this group
3. To correlate the alert points of several groups together, to achieve the triggering requirements of the time to execute the total judgment, judged as the main network failure.
This article is from the "Tongluowan" blog, make sure to keep this source http://wuhf2015.blog.51cto.com/8213008/1766184
Zabbix detect network quality instead of smokeping