- add modified ipmi_ plugin to improve FreeBSD support as well as detecting correct FAN speed output type
- Add multiping_ plugin.
This commit is contained in:
118
multiping_
Executable file
118
multiping_
Executable file
@ -0,0 +1,118 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# 12-Aug-2015 @farrokhi
|
||||
# This script graphs ICMP RTT to remove given hosts using ping utility.
|
||||
# It uses all IP addresses as source address on given interface.
|
||||
#
|
||||
# Configuration sample:
|
||||
# [multiping_*]
|
||||
# user root
|
||||
# env.interface igb0
|
||||
# env.hosts "4.2.2.4, ripe.net, 192.168.0.5, 8.8.4.4"
|
||||
#
|
||||
# Magic markers:
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf suggest
|
||||
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
SRC=`echo $SCRIPT_NAME | sed -n s/multiping_//p`
|
||||
PING=`which ping` || exit 1
|
||||
FSRC=`echo ${SRC} | sed 's/\./_/g'`
|
||||
IPS=`ifconfig ${interface} | awk '/inet /{print $2}' | grep -Ev '^(10|192)\.'`
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
|
||||
if [ x${SRC} == x ]; then
|
||||
echo "should run from symlink"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TMPFILE=`mktemp -t multiping`
|
||||
|
||||
for DST in `echo ${hosts} | tr , " "`; do
|
||||
fname=`echo ${DST} | sed 's/\./_/g'`
|
||||
ping -q -W1 -i0.1 -c10 -S ${SRC} ${DST} | sed 's/\// /g' | awk '
|
||||
/^round-trip/ {
|
||||
print "rtt_'${fname}'.value " $7;
|
||||
}
|
||||
/ packet loss/ {
|
||||
loss=$7;
|
||||
gsub(/\%/, "", loss);
|
||||
print "loss_'${fname}'.value " loss;
|
||||
}
|
||||
' >> ${TMPFILE}
|
||||
done
|
||||
|
||||
echo "multigraph rtt_${FSRC}"
|
||||
grep ^rtt ${TMPFILE}
|
||||
echo "multigraph loss_${FSRC}"
|
||||
grep ^loss ${TMPFILE}
|
||||
rm ${TMPFILE}
|
||||
|
||||
elif [ "$1" == "suggest" ]; then
|
||||
for DST in ${IPS}; do
|
||||
echo ${DST}
|
||||
done
|
||||
|
||||
elif [ "$1" == "autoconf" ]; then
|
||||
|
||||
if [ x${hosts} == x ]; then
|
||||
echo "no (env.hosts is not defined)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x${interface} == x ]; then
|
||||
echo "no (env.interface is not defined)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
### check env vars and return no if not set properly
|
||||
echo yes
|
||||
exit 0
|
||||
|
||||
elif [ "$1" == "config" ]; then
|
||||
|
||||
if [ x${SRC} == x ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "multigraph rtt_${FSRC}"
|
||||
echo "graph_title RTT Statistics for ${SRC}"
|
||||
echo "graph_args --lower-limit 0 --base 1000"
|
||||
echo "graph_vlabel milliseconds"
|
||||
echo "graph_category connectivity"
|
||||
echo "graph_info This graph shows ICMP RTT for {$SRC} on interface ${interface} toward multiple destination hosts"
|
||||
|
||||
COLOR=7
|
||||
for DST in `echo ${hosts} | tr , " "`; do
|
||||
fname=`echo ${DST} | sed 's/\./_/g'`
|
||||
echo rtt_${fname}.type GAUGE
|
||||
echo rtt_${fname}.draw LINE1
|
||||
echo rtt_${fname}.min 0
|
||||
echo rtt_${fname}.colour COLOUR${COLOR}
|
||||
echo rtt_${fname}.label ${DST}
|
||||
COLOR=`expr ${COLOR} + 1`
|
||||
done
|
||||
|
||||
echo "multigraph loss_${FSRC}"
|
||||
echo "graph_title Packet Loss Statistics for ${SRC}"
|
||||
echo "graph_args -r --upper-limit 100 --lower-limit 0 --base 1000"
|
||||
echo "graph_vlabel percent"
|
||||
echo "graph_category connectivity"
|
||||
echo "graph_info This graph shows ICMP Packet Loss for source address ${SRC} on interface ${interface} toward multiple destination hosts"
|
||||
|
||||
COLOR=7
|
||||
for DST in `echo ${hosts} | tr , " "`; do
|
||||
fname=`echo ${DST} | sed 's/\./_/g'`
|
||||
echo loss_${fname}.type GAUGE
|
||||
echo loss_${fname}.draw LINE2
|
||||
echo loss_${fname}.min 0
|
||||
echo loss_${fname}.max 100
|
||||
echo loss_${fname}.colour COLOUR${COLOR}
|
||||
echo loss_${fname}.label ${DST}
|
||||
COLOR=`expr ${COLOR} + 1`
|
||||
done
|
||||
|
||||
fi
|
||||
|
Reference in New Issue
Block a user