nagios: some enhancements + fixes for network_volume
This commit is contained in:
parent
737f61e844
commit
0d299cd3a0
1 changed files with 46 additions and 2 deletions
|
@ -1,10 +1,54 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
EXCLUDE_REGEXP='(lo|bond|vmbr)'
|
||||||
|
|
||||||
|
#
|
||||||
|
# Help function
|
||||||
|
#
|
||||||
|
usage() {
|
||||||
|
cat <<EOF
|
||||||
|
This script simply outputs the number of packets and volume of data
|
||||||
|
emitted and received by network devices. Its status is always 0/OK.
|
||||||
|
|
||||||
|
Usage :
|
||||||
|
$0 [-e egrep_exclude_pattern]
|
||||||
|
|
||||||
|
Example :
|
||||||
|
$0 -e '(lo|^br-|^veth)'
|
||||||
|
|
||||||
|
Default values:
|
||||||
|
egrep_exclude_pattern: $EXCLUDE_REGEXP
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Loop on parameters + tests
|
||||||
|
#
|
||||||
|
while getopts he: f; do
|
||||||
|
case "$f" in
|
||||||
|
'h')
|
||||||
|
usage
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
|
||||||
|
'e')
|
||||||
|
EXCLUDE_REGEXP="$OPTARG"
|
||||||
|
;;
|
||||||
|
|
||||||
|
\?)
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
# We don't bother buffering, let's output as we go
|
||||||
printf "OK |"
|
printf "OK |"
|
||||||
|
|
||||||
for i in $( cat /proc/net/dev | sed -n 's/^[[:space:]]*\([a-z0-9\.]\+\):.*/\1/p' ); do
|
# Loop on each device
|
||||||
if [ $( echo "$i" | egrep -c '(lo|bond|vmbr)' ) -gt 0 ]; then
|
for i in $( cat /proc/net/dev | sed -n 's/^[[:space:]]*\([a-z0-9\.\-]\+\):.*/\1/p' | sort ); do
|
||||||
|
if [ $( echo "$i" | egrep -c -e "$EXCLUDE_REGEXP" ) -gt 0 ]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
VOLUME_RECU="$( cat /proc/net/dev | sed -n "s/^[[:space:]]*$i:[[:space:]]*//p" | sed 's/[[:space:]]\+/ /g' | cut -d " " -f 1 )"
|
VOLUME_RECU="$( cat /proc/net/dev | sed -n "s/^[[:space:]]*$i:[[:space:]]*//p" | sed 's/[[:space:]]\+/ /g' | cut -d " " -f 1 )"
|
||||||
|
|
Loading…
Reference in a new issue