Skip to content

Instantly share code, notes, and snippets.

@mehulved
Created March 14, 2018 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mehulved/8c3bde2f7c33a980b8cbea8485b67639 to your computer and use it in GitHub Desktop.
Save mehulved/8c3bde2f7c33a980b8cbea8485b67639 to your computer and use it in GitHub Desktop.
#!/bin/bash
ETHTOOL=/sbin/ethtool
NETWORK_INTERFACE=eth0
ERROR_STATS=$($ETHTOOL -S $NETWORK_INTERFACE | grep errors | tr -d " ")
for STAT in $ERROR_STATS
do
KEY=$(echo $STAT | awk -F ':' '{print $1}')
VALUE=$(echo $STAT | awk -F ':' '{print $2}')
if [[ $VALUE != 0 ]]
then
echo "$KEY has non-zero value of $VALUE."
exit 1
else
echo "$KEY has value $VALUE."
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment