2015-08-13 09:21:55 +04:30
|
|
|
#!/bin/sh
|
|
|
|
#
|
2016-04-06 13:10:22 +04:30
|
|
|
# Copyright (c) 2016 Babak Farrokhi. All rights reserved.
|
2015-08-15 09:44:28 +04:30
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
#
|
2015-08-13 09:21:55 +04:30
|
|
|
# 12-Aug-2015 @farrokhi
|
|
|
|
# This script extracts IRQ interrupt rate for network interfaces from "vmstat -i"
|
|
|
|
# on FreeBSD and feeds to munin
|
|
|
|
#
|
|
|
|
# XXX: This script relies on lang/gawk (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/netirq_//p`
|
|
|
|
VMSTAT="/usr/bin/vmstat"
|
2015-08-24 19:31:12 +04:30
|
|
|
AWK=`which gawk` || ( echo "gawk not found"; exit 1 )
|
2015-08-13 09:21:55 +04:30
|
|
|
|
|
|
|
|
|
|
|
STATFILE=`mktemp -t netirq`
|
|
|
|
${VMSTAT} -i | sort -V > ${STATFILE} 2>/dev/null
|
|
|
|
|
|
|
|
if [ $# -lt 1 ]; then
|
|
|
|
|
2015-08-27 15:10:42 +04:30
|
|
|
if [ -z ${STAT_TYPE} ]; then
|
|
|
|
echo "Should run from symlink"
|
2015-08-13 09:21:55 +04:30
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
elif [ "$1" == "suggest" ]; then
|
|
|
|
for iface in `ifconfig -lu ether`; do
|
|
|
|
echo ${iface}
|
|
|
|
done
|
|
|
|
|
|
|
|
elif [ "$1" == "autoconf" ]; then
|
|
|
|
${VMSTAT} -i >/dev/null 2>&1 && echo yes || echo no
|
|
|
|
exit 0
|
|
|
|
|
|
|
|
elif [ "$1" == "config" ]; then
|
|
|
|
|
2015-08-27 15:10:42 +04:30
|
|
|
if [ -z ${STAT_TYPE} ]; then
|
|
|
|
echo "Should run from symlink";
|
2015-08-13 09:21:55 +04:30
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "graph_title IRQ Statistics for ${STAT_TYPE}"
|
|
|
|
echo "graph_args --lower-limit 0 --base 1000"
|
|
|
|
echo "graph_vlabel interrupts / second"
|
|
|
|
echo "graph_category system"
|
|
|
|
|
2015-08-15 09:23:48 +04:30
|
|
|
cat ${STATFILE} | ${AWK} '
|
|
|
|
BEGIN {
|
|
|
|
FS = "[ ]{2,}"
|
|
|
|
}
|
|
|
|
|
|
|
|
/'${STAT_TYPE}'/ {
|
|
|
|
split($1,name,":");
|
2017-02-08 12:30:20 +03:30
|
|
|
gsub(/ /,"", $1);
|
|
|
|
print name[1]".label " $1;
|
2015-08-15 09:23:48 +04:30
|
|
|
print name[1]".type DERIVE";
|
|
|
|
print name[1]".min 0";
|
|
|
|
print name[1]".draw LINE2";
|
|
|
|
}
|
|
|
|
'
|
2019-02-19 15:16:27 -05:00
|
|
|
else
|
|
|
|
|
|
|
|
${AWK} '
|
|
|
|
{ FS = "[ ]{2,}" }
|
|
|
|
/'${STAT_TYPE}'/ {
|
|
|
|
split($1,name,":");
|
|
|
|
print name[1]".value "$2
|
|
|
|
}' ${STATFILE}
|
2015-08-13 09:21:55 +04:30
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm ${STATFILE}
|
|
|
|
|
2019-02-19 15:16:27 -05:00
|
|
|
|