1
0
Fork 0
scripts-admin-quickndirty-p.../nagios/check_network_volume.sh

17 lines
892 B
Bash
Executable file

#!/bin/sh
printf "OK |"
for i in $( cat /proc/net/dev | sed -n 's/^[[:space:]]*\([a-z0-9\.]\+\):.*/\1/p' ); do
if [ $( echo "$i" | egrep -c '(lo|bond|vmbr)' ) -gt 0 ]; then
continue
fi
VOLUME_RECU="$( cat /proc/net/dev | sed -n "s/^[[:space:]]*$i:[[:space:]]*//p" | sed 's/[[:space:]]\+/ /g' | cut -d " " -f 1 )"
VOLUME_EMIS="$( cat /proc/net/dev | sed -n "s/^[[:space:]]*$i:[[:space:]]*//p" | sed 's/[[:space:]]\+/ /g' | cut -d " " -f 9 )"
PAQUETS_RECUS="$( cat /proc/net/dev | sed -n "s/^[[:space:]]*$i:[[:space:]]*//p" | sed 's/[[:space:]]\+/ /g' | cut -d " " -f 2 )"
PAQUETS_EMIS="$( cat /proc/net/dev | sed -n "s/^[[:space:]]*$i:[[:space:]]*//p" | sed 's/[[:space:]]\+/ /g' | cut -d " " -f 10 )"
printf " %s_packets_in=%d %s_packets_out=%d %s_volume_in=%d %s_volume_out=%d" "$i" "$PAQUETS_RECUS" "$i" "$PAQUETS_EMIS" "$i" "$VOLUME_RECU" "$i" "$VOLUME_EMIS"
done
printf "\n"