This commit is contained in:
Babak Farrokhi 2017-09-04 15:27:00 +04:30
commit d498b23012
11 changed files with 169 additions and 63 deletions

View File

@ -1,4 +1,4 @@
Copyright (c) 2015, Babak Farrokhi Copyright (c) 2017, Babak Farrokhi, Moritz Hoffmann
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without

View File

@ -11,7 +11,11 @@ A set of FreeBSD specific plugins for Munin
- You need to install `lang/gawk` in order to run `intr_` plugin. - You need to install `lang/gawk` in order to run `intr_` plugin.
- You need to install `sysutils/ipmitool` in order to run `ipmi_` plugin. - You need to install `sysutils/ipmitool` in order to run `ipmi_` plugin.
- These are wildcard plugins, and should be installed using `munin-node-configure` program - These are wildcard plugins, and should be installed using `munin-node-configure` program
- Some plugins such as `ipmi_` and `multiping_` need to have root access to run. - Some plugins such as `pf_`, `ipmi_` and `multiping_` need to have root access to run. To tell Munin to run a plugin as root, adapt the following snippet and add it to `/usr/local/etc/munin/plugin-conf.d/plugins.conf`:
```
[pf_*]
user root
```
## Setup ## Setup
1. Make sure `sysutils/munin-node` is installed 1. Make sure `sysutils/munin-node` is installed

2
intr_
View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2015 Babak Farrokhi. All rights reserved. # Copyright (c) 2016 Babak Farrokhi. All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions # modification, are permitted provided that the following conditions

2
ip_
View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2015 Babak Farrokhi. All rights reserved. # Copyright (c) 2016 Babak Farrokhi. All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions # modification, are permitted provided that the following conditions

65
ipinput Executable file
View File

@ -0,0 +1,65 @@
#!/bin/sh
#
# Copyright (c) 2015 Babak Farrokhi. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
#
# March-2017 @farrokhi
# This plugin extracts "ip input" buffer overruns using sysctl and feeds
# to munin (or any other compatible agent) for graphing
#
# Buffer overrung on IP Input happens when CPU is not fast enough
# to pick ip packet from queue. This can be observed by seeing a
# CPU hogging "task queue" process in top.
#
# Magic markers:
#%# family=auto
#%# capabilities=autoconf
SCRIPT_NAME=$(basename $0)
if [ $# -lt 1 ]; then
DROPS=`sysctl -n net.inet.ip.intr_queue_drops`
echo ip_idrops.value ${DROPS}
elif [ "$1" == "autoconf" ]; then
echo yes
exit 0
elif [ "$1" == "config" ]; then
echo "graph_title IP Input Drops"
echo "graph_args --lower-limit 0 --base 1000"
echo "graph_vlabel packets / second"
echo "graph_category system"
echo ip_idrops.label "Input Drops"
echo ip_idrops.type DERIVE
echo ip_idrops.min 0
fi

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2015 Babak Farrokhi. All rights reserved. # Copyright (c) 2016 Babak Farrokhi. All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions # modification, are permitted provided that the following conditions
@ -32,42 +32,53 @@
# Configuration sample: # Configuration sample:
# [multiping_*] # [multiping_*]
# user root # user root
# env.interface igb0 # env.interface igb0:1 igb1:2
# env.hosts "4.2.2.4, ripe.net, 192.168.0.5, 8.8.4.4" # env.hosts "4.2.2.4, ripe.net, 192.168.0.5, 8.8.4.4"
# #
#
# with env.interface variable, every interface should be suffixed with
# its fib number. In a normal environment, fib should always be 0. If
# you are using multiple routing tables you should use correct fib
# number (e.g. igb1 on fib 4 will be igb1:4).
#
#
# Magic markers: # Magic markers:
#%# family=auto #%# family=auto
#%# capabilities=autoconf suggest #%# capabilities=autoconf suggest
SCRIPT_NAME=$(basename $0) SCRIPT_NAME=$(basename $0)
SRC=`echo $SCRIPT_NAME | sed -n s/multiping_//p` SRC=`echo $SCRIPT_NAME | sed -n s/multiping_//p | cut -f1 -d_`
PING=`which ping` || exit 1 FIB=`echo $SCRIPT_NAME | sed -n s/multiping_//p | cut -f2 -d_`
FPING=`which fping` || ( echo "fping required but not found"; exit 1)
FSRC=`echo ${SRC} | sed 's/\./_/g'` FSRC=`echo ${SRC} | sed 's/\./_/g'`
IPS=`ifconfig ${interface} | awk '/inet /{print $2}' | grep -Ev '^(10|192)\.'` SETFIB="/usr/sbin/setfib ${FIB}"
if [ $# -lt 1 ]; then if [ $# -lt 1 ]; then
if [ x${SRC} == x ]; then if [ -z "${SRC}" ]; then
echo "should run from symlink" echo "should run from symlink"
exit 1 exit 1
fi fi
if [ -z "${hosts}" ]; then
echo "Unknown destination address"
exit 1
fi
TMPFILE=`mktemp -t multiping` TMPFILE=`mktemp -t multiping`
for DST in `echo ${hosts} | tr , " "`; do DST=`echo ${hosts} | tr , " "`
fname=`echo ${DST} | sed 's/\./_/g'` fname=`echo ${DST} | sed 's/\./_/g'`
ping -q -W1 -i0.1 -c10 -S ${SRC} ${DST} | sed 's/\// /g' | awk '
/^round-trip/ { ${SETFIB} ${FPING} -A -q -s -i10 -c50 -p 25 -S ${SRC} -t1000 ${DST} 2>&1 | grep ':' | tr '%/,' ' ' | awk '
print "rtt_'${fname}'.value " $7; /xmt/ {
} name = $1;
/ packet loss/ { gsub(/\./, "_", name);
loss=$7; printf "rtt_%s.value %0.0f\n", name, $15;
gsub(/\%/, "", loss); printf "loss_%s.value %0.0f\n", name, $9;
print "loss_'${fname}'.value " loss;
} }
' >> ${TMPFILE} ' >> ${TMPFILE}
done
echo "multigraph rtt_${FSRC}" echo "multigraph rtt_${FSRC}"
grep ^rtt ${TMPFILE} grep ^rtt ${TMPFILE}
@ -76,20 +87,28 @@ if [ $# -lt 1 ]; then
rm ${TMPFILE} rm ${TMPFILE}
elif [ "$1" == "suggest" ]; then elif [ "$1" == "suggest" ]; then
# interface name format is igb0:2 - number after colon is fib number
for int in ${interface}; do
FIB=`echo ${int} | cut -f2 -d:`
NAME=`echo ${int} | cut -f1 -d:`
IPS=`ifconfig ${NAME} | grep -v tunnel | awk '/inet /{print $2}' | grep -Ev '^(10|192|127)\.'`
for DST in ${IPS}; do for DST in ${IPS}; do
echo ${DST} echo ${DST}_${FIB}
done done
done
elif [ "$1" == "autoconf" ]; then elif [ "$1" == "autoconf" ]; then
if [ x${hosts} == x ]; then if [ -z "${hosts}" ]; then
echo "no (env.hosts is not defined)" echo "no (env.hosts is not defined)"
exit 0 exit 1
fi fi
if [ x${interface} == x ]; then if [ -z "${interface}" ]; then
echo "no (env.interface is not defined)" echo "no (env.interface is not defined)"
exit 0 exit 1
fi fi
### check env vars and return no if not set properly ### check env vars and return no if not set properly
@ -98,7 +117,7 @@ elif [ "$1" == "autoconf" ]; then
elif [ "$1" == "config" ]; then elif [ "$1" == "config" ]; then
if [ x${SRC} == x ]; then if [ -z "${SRC}" ]; then
exit 1 exit 1
fi fi
@ -107,7 +126,7 @@ elif [ "$1" == "config" ]; then
echo "graph_args --lower-limit 0 --base 1000" echo "graph_args --lower-limit 0 --base 1000"
echo "graph_vlabel milliseconds" echo "graph_vlabel milliseconds"
echo "graph_category connectivity" echo "graph_category connectivity"
echo "graph_info This graph shows ICMP RTT for {$SRC} on interface ${interface} toward multiple destination hosts" echo "graph_info This graph shows ICMP RTT for {$SRC} on FIB ${FIB} toward multiple destination hosts"
COLOR=7 COLOR=7
for DST in `echo ${hosts} | tr , " "`; do for DST in `echo ${hosts} | tr , " "`; do
@ -126,7 +145,7 @@ elif [ "$1" == "config" ]; then
echo "graph_scale no" echo "graph_scale no"
echo "graph_vlabel percent" echo "graph_vlabel percent"
echo "graph_category connectivity" echo "graph_category connectivity"
echo "graph_info This graph shows ICMP Packet Loss for source address ${SRC} on interface ${interface} toward multiple destination hosts" echo "graph_info This graph shows ICMP Packet Loss for source address ${SRC} on FIB ${FIB} toward multiple destination hosts"
COLOR=7 COLOR=7
for DST in `echo ${hosts} | tr , " "`; do for DST in `echo ${hosts} | tr , " "`; do

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2015 Babak Farrokhi. All rights reserved. # Copyright (c) 2016 Babak Farrokhi. All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions # modification, are permitted provided that the following conditions
@ -88,7 +88,8 @@ BEGIN {
/'${STAT_TYPE}'/ { /'${STAT_TYPE}'/ {
split($1,name,":"); split($1,name,":");
print name[1]".label "$1; gsub(/ /,"", $1);
print name[1]".label " $1;
print name[1]".type DERIVE"; print name[1]".type DERIVE";
print name[1]".min 0"; print name[1]".min 0";
print name[1]".draw LINE2"; print name[1]".draw LINE2";

65
netisr_
View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2015 Babak Farrokhi. All rights reserved. # Copyright (c) 2017 Babak Farrokhi. All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions # modification, are permitted provided that the following conditions
@ -46,19 +46,36 @@ if [ $# -lt 1 ]; then
echo "Should run from symlink" echo "Should run from symlink"
exit 1 exit 1
fi fi
awk ' awk '
BEGIN {
OFS="";
qed=0;
handled=0;
dropped=0;
hdised=0;
dised=0;
st="";
}
/ ('${STAT_TYPE}') / { / ('${STAT_TYPE}') / {
print "t"$2 "_"$3"_queued.value "$9; st=$3;
print "t"$2 "_"$3"_handled.value "$10; qed=qed+$9;
print "t"$2 "_"$3"_dropped.value "$8; handled=handled+$10;
print "t"$2 "_"$3"_hdispatched.value "$7; dropped=dropped+$8;
print "t"$2 "_"$3"_dispatched.value "$6; hdised=hdised+$7;
} ' ${STATFILE} dised=dised+$6;
}
END {
print st, "_queued.value ", qed;
print st, "_handled.value ", handled;
print st, "_dropped.value ", dropped;
print st, "_hdispatched.value ", hdised;
print st, "_dispatched.value ", dised;
}
' ${STATFILE}
elif [ "$1" == "suggest" ]; then elif [ "$1" == "suggest" ]; then
awk '/---/{print $1}' ${STATFILE} awk '/--$/{print $1}' ${STATFILE}
elif [ "$1" == "autoconf" ]; then elif [ "$1" == "autoconf" ]; then
${NETSTAT} -Q >/dev/null 2>&1 && echo yes || echo no ${NETSTAT} -Q >/dev/null 2>&1 && echo yes || echo no
@ -77,21 +94,21 @@ elif [ "$1" == "config" ]; then
awk ' awk '
/ ('${STAT_TYPE}') / { / ('${STAT_TYPE}') / {
print "t"$2 "_"$3"_queued.label Thread "$2 " Queued"; print $3"_queued.label Queued";
print "t"$2 "_"$3"_handled.label Thread "$2 " Handled"; print $3"_handled.label Handled";
print "t"$2 "_"$3"_dropped.label Thread "$2 " Dropped"; print $3"_dropped.label Dropped";
print "t"$2 "_"$3"_hdispatched.label Thread "$2 " Hybrid-Dispatched"; print $3"_hdispatched.label Hybrid-Dispatched";
print "t"$2 "_"$3"_dispatched.label Thread "$2" Dispatched"; print $3"_dispatched.label Dispatched";
print "t"$2 "_"$3"_queued.type DERIVE"; print $3"_queued.type DERIVE";
print "t"$2 "_"$3"_handled.type DERIVE"; print $3"_handled.type DERIVE";
print "t"$2 "_"$3"_dropped.type DERIVE"; print $3"_dropped.type DERIVE";
print "t"$2 "_"$3"_hdispatched.type DERIVE"; print $3"_hdispatched.type DERIVE";
print "t"$2 "_"$3"_dispatched.type DERIVE"; print $3"_dispatched.type DERIVE";
print "t"$2 "_"$3"_queued.min 0"; print $3"_queued.min 0";
print "t"$2 "_"$3"_handled.min 0"; print $3"_handled.min 0";
print "t"$2 "_"$3"_dropped.min 0"; print $3"_dropped.min 0";
print "t"$2 "_"$3"_hdispatched.min 0"; print $3"_hdispatched.min 0";
print "t"$2 "_"$3"_dispatched.min 0"; print $3"_dispatched.min 0";
}' ${STATFILE} }' ${STATFILE}
fi fi

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2015 Babak Farrokhi. All rights reserved. # Copyright (c) 2016 Babak Farrokhi. All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions # modification, are permitted provided that the following conditions

2
pf_
View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2015 Babak Farrokhi. All rights reserved. # Copyright (c) 2016 Babak Farrokhi. All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions # modification, are permitted provided that the following conditions

2
udp_
View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2015 Babak Farrokhi. All rights reserved. # Copyright (c) 2016 Babak Farrokhi. All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions # modification, are permitted provided that the following conditions