- Initial version of munin plugins for FreeBSD
This commit is contained in:
parent
75e78f6d69
commit
50187a1379
93
intr_
Executable file
93
intr_
Executable file
@ -0,0 +1,93 @@
|
||||
#!/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.
|
||||
#
|
||||
#
|
||||
# 12-Aug-2015 @farrokhi
|
||||
# This script extracts CPU and IRQ interrupt rates from "vmstat -i"
|
||||
# on FreeBSD and feeds to munin
|
||||
#
|
||||
# XXX: This script requires lang/gawk to be installed (we use extended regexp in awk).
|
||||
#
|
||||
# Magic markers:
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf suggest
|
||||
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
STAT_TYPE=`echo $SCRIPT_NAME | sed -n s/intr_//p`
|
||||
VMSTAT="/usr/bin/vmstat"
|
||||
AWK=`which gawk` || exit 1
|
||||
|
||||
|
||||
STATFILE=`mktemp -t intr`
|
||||
${VMSTAT} -i | sort -V > ${STATFILE} 2>/dev/null
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
|
||||
|
||||
case ${STAT_TYPE} in
|
||||
cpu)
|
||||
cat ${STATFILE} | ${AWK} '{ FS = "[ ]{2,}" } /^cpu/{split($1,name,":"); print name[1]".value "$2}'
|
||||
;;
|
||||
irq)
|
||||
cat ${STATFILE} | ${AWK} '{ FS = "[ ]{2,}" } /^irq/{split($1,name,":"); print name[1]".value "$2}'
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
elif [ "$1" == "suggest" ]; then
|
||||
echo "cpu"
|
||||
echo "irq"
|
||||
|
||||
elif [ "$1" == "autoconf" ]; then
|
||||
${VMSTAT} -i >/dev/null 2>&1 && echo yes || echo no
|
||||
exit 0
|
||||
|
||||
elif [ "$1" == "config" ]; then
|
||||
|
||||
case ${STAT_TYPE} in
|
||||
cpu)
|
||||
echo "graph_title CPU Timer Statistics"
|
||||
echo "graph_args --lower-limit 0 --base 1000"
|
||||
echo "graph_vlabel interrupts / second"
|
||||
echo "graph_category system"
|
||||
|
||||
cat ${STATFILE} | ${AWK} '{ FS = "[ ]{2,}" } /^cpu/{split($1,name,":"); print name[1]".label "$1"\n"name[1]".type DERIVE\n"name[1]".min 0"}'
|
||||
;;
|
||||
irq)
|
||||
echo "graph_title IRQ Statistics"
|
||||
echo "graph_args --lower-limit 0 --base 1000"
|
||||
echo "graph_vlabel interrupts / second"
|
||||
echo "graph_category system"
|
||||
|
||||
cat ${STATFILE} | ${AWK} '{ FS = "[ ]{2,}" } /^irq/{split($1,name,":"); print name[1]".label "$1"\n"name[1]".type DERIVE\n"name[1]".min 0"}'
|
||||
;;
|
||||
esac
|
||||
|
||||
fi
|
||||
|
||||
rm ${STATFILE}
|
||||
|
77
netisr_
Executable file
77
netisr_
Executable file
@ -0,0 +1,77 @@
|
||||
#!/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.
|
||||
#
|
||||
# 10-Aug-2015 @farrokhi
|
||||
# This script extracts netisr dispatcher statistics from "netstat -Q"
|
||||
# on FreeBSD and feeds to munin
|
||||
#
|
||||
# Magic markers:
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf suggest
|
||||
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
NETSTAT="/usr/bin/netstat"
|
||||
STAT_TYPE=`echo $SCRIPT_NAME | sed -n s/netisr_//p`
|
||||
|
||||
STATFILE=`mktemp -t netisr`
|
||||
${NETSTAT} -Q > ${STATFILE} 2>/dev/null
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
|
||||
if [ x${STAT_TYPE} == x ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat ${STATFILE} | awk ' / ('${STAT_TYPE}') /{print "t"$2 "_"$3"_queued.value "$9 "\nt"$2 "_"$3"_handled.value "$10 "\nt"$2 "_"$3"_dropped.value "$8 "\nt"$2 "_"$3"_hdispatched.value "$7 "\nt"$2 "_"$3"_dispatched.value "$6}'
|
||||
|
||||
elif [ "$1" == "suggest" ]; then
|
||||
|
||||
cat ${STATFILE} | awk '/---/{print $1}'
|
||||
|
||||
elif [ "$1" == "autoconf" ]; then
|
||||
${NETSTAT} -Q >/dev/null 2>&1 && echo yes || echo no
|
||||
exit 0
|
||||
|
||||
elif [ "$1" == "config" ]; then
|
||||
|
||||
if [ x${STAT_TYPE} == x ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "graph_title netisr dispatcher statistics for ${STAT_TYPE}"
|
||||
echo "graph_args -X 0 --lower-limit 0 --base 1000"
|
||||
echo "graph_vlabel packets / second"
|
||||
echo "graph_category isr"
|
||||
|
||||
cat ${STATFILE} | awk ' / ('${STAT_TYPE}') /{print "t"$2 "_"$3"_queued.label Thread "$2 " Queued\nt"$2 "_"$3"_handled.label Thread "$2 " Handled\nt"$2 "_"$3"_dropped.label Thread "$2 " Dropped\nt"$2 "_"$3"_hdispatched.label Thread "$2 " Hybrid-Dispatched\nt"$2 "_"$3"_dispatched.label Thread "$2" Dispatched"}'
|
||||
cat ${STATFILE} | awk ' / ('${STAT_TYPE}') /{print "t"$2 "_"$3"_queued.type DERIVE\nt"$2 "_"$3"_handled.type DERIVE\nt"$2 "_"$3"_dropped.type DERIVE\nt"$2 "_"$3"_hdispatched.type DERIVE\nt"$2 "_"$3"_dispatched.type DERIVE"}'
|
||||
cat ${STATFILE} | awk ' / ('${STAT_TYPE}') /{print "t"$2 "_"$3"_queued.min 0\nt"$2 "_"$3"_handled.min 0\nt"$2 "_"$3"_dropped.min 0\nt"$2 "_"$3"_hdispatched.min 0\nt"$2 "_"$3"_dispatched.min 0"}'
|
||||
|
||||
fi
|
||||
|
||||
rm ${STATFILE}
|
||||
|
96
netmem_
Executable file
96
netmem_
Executable file
@ -0,0 +1,96 @@
|
||||
#!/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.
|
||||
#
|
||||
# 17-Feb-2015 @farrokhi
|
||||
# This script extracts network memory usage counters from "netstat -m"
|
||||
# on FreeBSD and feeds to munin
|
||||
#
|
||||
# Magic markers:
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf suggest
|
||||
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
STAT_TYPE=`echo $SCRIPT_NAME | sed -n s/netmem_//p`
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
|
||||
if [ "${STAT_TYPE}" == "mbufs" ]; then
|
||||
netstat -m | grep "mbufs in use" | sed -E -n 's/([0-9]+)\/([0-9]+)\/([0-9]+) .+/mbufs_current.value \1,mbufs_cache.value \2,mbufs_total.value \3/p' | tr ',' '\n'
|
||||
elif [ "${STAT_TYPE}" == "clusters" ]; then
|
||||
netstat -m | grep "mbuf clusters in use" | sed -E -n 's/([0-9]+)\/([0-9]+)\/([0-9]+)\/([0-9]+) .+/clusters_current.value \1,clusters_cache.value \2,clusters_total.value \3,clusters_max.value \4/p' | tr ',' '\n'
|
||||
elif [ "${STAT_TYPE}" == "sendfile" ]; then
|
||||
netstat -m | grep sendfile | sed -E -n 's/(^[0-9]+).+/sendfile.value \1/p'
|
||||
fi
|
||||
|
||||
elif [ "$1" == "suggest" ]; then
|
||||
echo "mbufs"
|
||||
echo "clusters"
|
||||
echo "sendfile"
|
||||
|
||||
elif [ "$1" == "autoconf" ]; then
|
||||
[ -x "/usr/bin/netstat" ] && echo yes || echo no
|
||||
exit 0
|
||||
|
||||
elif [ "$1" == "config" ]; then
|
||||
|
||||
if [ "${STAT_TYPE}" == "mbufs" ]; then
|
||||
echo "graph_title mbufs usage"
|
||||
echo "graph_args --lower-limit 0 --base 1000"
|
||||
echo "graph_vlabel mbufs"
|
||||
echo "graph_category network"
|
||||
echo "mbufs_current.label current"
|
||||
echo "mbufs_current.draw AREA"
|
||||
echo "mbufs_cache.label cache"
|
||||
echo "mbufs_cache.draw STACK"
|
||||
echo "mbufs_total.label total"
|
||||
echo "mbufs_total.draw LINE2"
|
||||
elif [ "${STAT_TYPE}" == "clusters" ]; then
|
||||
echo "graph_title mbuf clusters usage"
|
||||
echo "graph_args --lower-limit 0 --base 1000"
|
||||
echo "graph_vlabel clusters"
|
||||
echo "graph_category network"
|
||||
echo "clusters_current.label current"
|
||||
echo "clusters_current.draw AREA"
|
||||
echo "clusters_cache.label cache"
|
||||
echo "clusters_cache.draw STACK"
|
||||
echo "clusters_total.label total"
|
||||
echo "clusters_total.draw LINE2"
|
||||
#echo "clusters_max.label max"
|
||||
#echo "clusters_max.draw LINE1"
|
||||
elif [ "${STAT_TYPE}" == "sendfile" ]; then
|
||||
echo "graph_title sendfile() calls"
|
||||
echo "graph_args --lower-limit 0 --base 1000"
|
||||
echo "graph_vlabel calls"
|
||||
echo "graph_period minute"
|
||||
echo "graph_category network"
|
||||
echo "sendfile.label calls"
|
||||
echo "sendfile.draw LINE1"
|
||||
echo "sendfile.type DERIVE"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
153
pf_
Executable file
153
pf_
Executable file
@ -0,0 +1,153 @@
|
||||
#!/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.
|
||||
#
|
||||
#
|
||||
# 04-Aug-2015 @farrokhi
|
||||
# This script extracts pf firewall statistics from from "pfctl -vsi"
|
||||
# on FreeBSD and feeds to munin
|
||||
#
|
||||
# Magic markers:
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf suggest
|
||||
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
STAT_TYPE=`echo $SCRIPT_NAME | sed -n s/pf_//p`
|
||||
PFCTL="/sbin/pfctl"
|
||||
|
||||
|
||||
STATFILE=`mktemp -t pf`
|
||||
${PFCTL} -vsi > ${STATFILE} 2>/dev/null
|
||||
|
||||
print_config()
|
||||
{
|
||||
local fname=$1; shift;
|
||||
local fdesc=$1; shift;
|
||||
|
||||
echo "${fname}.label ${fdesc}"
|
||||
echo "${fname}.draw LINE1"
|
||||
echo "${fname}.type DERIVE"
|
||||
echo "${fname}.min 0"
|
||||
}
|
||||
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
|
||||
case ${STAT_TYPE} in
|
||||
state)
|
||||
cat ${STATFILE} | grep "^State Table" -A4 | grep "current" | awk '{print "state.value "$3}'
|
||||
;;
|
||||
state_act)
|
||||
cat ${STATFILE} | grep "^State Table" -A4 | tail -3 | awk '{print "state_"$1".value",$2}'
|
||||
;;
|
||||
source)
|
||||
cat ${STATFILE} | grep "^Source Tracking Table" -A4 | grep "current" | awk '{print "source.value "$3}'
|
||||
;;
|
||||
source_act)
|
||||
cat ${STATFILE} | grep "^Source Tracking Table" -A4 | tail -3 | awk '{print "source_"$1".value",$2}'
|
||||
;;
|
||||
counters)
|
||||
cat ${STATFILE} | grep "^Counters" -A15 | tail -15 | awk '{print "counter_"$1".value",$2}'
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
elif [ "$1" == "suggest" ]; then
|
||||
echo "state"
|
||||
echo "state_act"
|
||||
echo "source"
|
||||
echo "source_act"
|
||||
echo "counters"
|
||||
|
||||
elif [ "$1" == "autoconf" ]; then
|
||||
${PFCTL} -si >/dev/null 2>&1 && echo yes || echo no
|
||||
exit 0
|
||||
|
||||
elif [ "$1" == "config" ]; then
|
||||
|
||||
LIMITFILE=`mktemp -t pf`
|
||||
${PFCTL} -vsm > ${LIMITFILE} 2>/dev/null
|
||||
MAX_STATES=`cat ${LIMITFILE} | grep "^states" | awk '{print $4}'`
|
||||
MAX_SRC=`cat ${LIMITFILE} | grep "^src-nodes" | awk '{print $4}'`
|
||||
rm ${LIMITFILE}
|
||||
|
||||
|
||||
case ${STAT_TYPE} in
|
||||
state)
|
||||
echo "graph_title State Table Entries"
|
||||
echo "graph_args --lower-limit 0 --base 1000"
|
||||
echo "graph_vlabel states"
|
||||
echo "graph_category firewall"
|
||||
|
||||
echo "state.label current"
|
||||
echo "state.critical ${MAX_STATES}"
|
||||
;;
|
||||
state_act)
|
||||
echo "graph_title State Table Activity"
|
||||
echo "graph_args --lower-limit 0 --base 1000"
|
||||
echo "graph_vlabel actions / second"
|
||||
echo "graph_category firewall"
|
||||
|
||||
print_config "state_searches" "search"
|
||||
print_config "state_inserts" "insert"
|
||||
print_config "state_removals" "removal"
|
||||
;;
|
||||
source)
|
||||
echo "graph_title Source Tracking Table Entries"
|
||||
echo "graph_args --lower-limit 0 --base 1000"
|
||||
echo "graph_vlabel sources"
|
||||
echo "graph_category firewall"
|
||||
|
||||
echo "source.label current"
|
||||
echo "source.min 0"
|
||||
echo "source.critical ${MAX_SRC}"
|
||||
;;
|
||||
source_act)
|
||||
echo "graph_title Source Tracking Table Activity"
|
||||
echo "graph_args --lower-limit 0 --base 1000"
|
||||
echo "graph_vlabel actions / second"
|
||||
echo "graph_category firewall"
|
||||
|
||||
print_config "source_searches" "search"
|
||||
print_config "source_inserts" "insert"
|
||||
print_config "source_removals" "removal"
|
||||
;;
|
||||
counters)
|
||||
echo "graph_title Misc Counters"
|
||||
echo "graph_args --lower-limit 0 --base 1000"
|
||||
echo "graph_vlabel actions / second"
|
||||
echo "graph_category firewall"
|
||||
|
||||
for i in `cat ${STATFILE} | grep "^Counters" -A15 | tail -15 | awk '{print $1}' `; do
|
||||
print_config "counter_${i}" ${i}
|
||||
done
|
||||
;;
|
||||
esac
|
||||
|
||||
fi
|
||||
|
||||
rm ${STATFILE}
|
||||
|
132
udp_
Executable file
132
udp_
Executable file
@ -0,0 +1,132 @@
|
||||
#!/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.
|
||||
#
|
||||
#
|
||||
# 10-Aug-2015 @farrokhi
|
||||
# This script extracts UDP traffic statistics from "netstat -s"
|
||||
# on FreeBSD and feeds to munin
|
||||
#
|
||||
# Magic markers:
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf suggest
|
||||
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
STAT_TYPE=`echo $SCRIPT_NAME | sed -n s/udp_//p`
|
||||
NETSTAT="/usr/bin/netstat"
|
||||
|
||||
|
||||
STATFILE=`mktemp -t udp`
|
||||
${NETSTAT} -s > ${STATFILE} 2>/dev/null
|
||||
|
||||
|
||||
print_config()
|
||||
{
|
||||
local fname=$1; shift;
|
||||
local fdesc=$1; shift;
|
||||
|
||||
echo "${fname}.label ${fdesc}"
|
||||
echo "${fname}.type DERIVE"
|
||||
echo "${fname}.draw LINE1"
|
||||
echo "${fname}.min 0"
|
||||
}
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
|
||||
|
||||
case ${STAT_TYPE} in
|
||||
traffic)
|
||||
cat ${STATFILE} | grep "^udp:" -A12 | awk '
|
||||
/datagrams received/{print "received.value "$1};
|
||||
/ delivered$/ {print "delivered.value "$1};
|
||||
/datagrams output/ {print "sent.value "$1}
|
||||
'
|
||||
;;
|
||||
errors)
|
||||
cat ${STATFILE} | grep "^udp:" -A12 | awk '
|
||||
/incomplete header/ {print "incomplete_header.value "$1};
|
||||
/bad data length field/ {print "bad_datalen.value "$1};
|
||||
/bad checksum/ {print "bad_checksum.value "$1};
|
||||
/with no checksum/ {print "no_checksum.value "$1};
|
||||
/due to no socket/ {print "nosock_drop.value "$1};
|
||||
/due to full socket/ {print "nobuf_drop.value "$1};
|
||||
/not for hashed pcb/ {print "nothashed.value "$1};
|
||||
'
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
elif [ "$1" == "suggest" ]; then
|
||||
echo "traffic"
|
||||
echo "errors"
|
||||
|
||||
elif [ "$1" == "autoconf" ]; then
|
||||
${NETSTAT} -s >/dev/null 2>&1 && echo yes || echo no
|
||||
exit 0
|
||||
|
||||
elif [ "$1" == "config" ]; then
|
||||
|
||||
case ${STAT_TYPE} in
|
||||
traffic)
|
||||
echo "graph_title UDP Traffic"
|
||||
echo "graph_args --lower-limit 0 --base 1000"
|
||||
echo "graph_vlabel datagrams / second in (+) / out (-)"
|
||||
echo "graph_category protocols"
|
||||
|
||||
echo "received.label Traffic In/Out"
|
||||
echo "received.type DERIVE"
|
||||
echo "received.min 0"
|
||||
echo "received.graph no"
|
||||
|
||||
echo "delivered.label Delivered"
|
||||
echo "delivered.type DERIVE"
|
||||
echo "delivered.min 0"
|
||||
|
||||
echo "sent.label Traffic In/Out"
|
||||
echo "sent.type DERIVE"
|
||||
echo "sent.min 0"
|
||||
echo "sent.negative received"
|
||||
;;
|
||||
errors)
|
||||
echo "graph_title UDP Errors"
|
||||
echo "graph_args --lower-limit 0 --base 1000"
|
||||
echo "graph_vlabel datagrams / second"
|
||||
echo "graph_category protocols"
|
||||
|
||||
print_config "incomplete_header" "Incomplere header"
|
||||
print_config "bad_datalen" "Bad data length"
|
||||
print_config "bad_checksum" "Bad checksum"
|
||||
print_config "no_checksum" "No checksum"
|
||||
print_config "nosock_drop" "Dropped due to no socket"
|
||||
print_config "nobuf_drop" "Dropped due to full socket buffer"
|
||||
print_config "nothashed" "Not hashed for PCB"
|
||||
;;
|
||||
esac
|
||||
|
||||
fi
|
||||
|
||||
rm ${STATFILE}
|
||||
|
Loading…
x
Reference in New Issue
Block a user