Link to home
Start Free TrialLog in
Avatar of M DXYZ
M DXYZFlag for United States of America

asked on

bash script report errors on interfaces

Hi, I need assistance with my script, I am basically quering the system for all of the active interfaces and then I am searching for all different types of errors on collisions, dropped packets overruns, carrier, frame, if any other number than zero appers it will send me an email. So far this is what I have, but I am getting errors.

The joint 1 file looks like
eth0 errors:1 dropped:0 overruns:0 carrier:0
eth1 errors:0 dropped:0 overruns:0 carrier:0

Thank you for your assistance.

Mike



#!/bin/bash
 
LIMIT="0"
SUBJECT="Network error on $hostname"
ADMINS=myemail@gmail.com
 
#The interface will be displayed
ETH=$(ifconfig | awk '/(eth)/ { print $1 }' | cut -d':' -f2 | head -4 > /root/eth)
 
TX=$(ifconfig | grep "TX packets" > /root/tx)
 
paste /root/eth /root/tx > /root/joint
 
COMPARE=$(awk '{print $1, $4, $5, $6, $7}' /root/joint | grep -Ev "TX|0" > joint1)            
 
if [ $COMPARE -ge  $LIMIT]
   echo "Error on interface
fi

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of M DXYZ
M DXYZ
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial