Solved

bash script report errors on interfaces

Posted on 2009-05-12
1
398 Views
Last Modified: 2013-12-26
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

0
Comment
Question by:dpoper1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
dpoper1 earned 0 total points
ID: 24368446
Hi, I need assistance please, here is my joint 1 output file

eth0 errors:1 dropped:0 overruns:0 carrier:0
eth1 errors:0 dropped:0 overruns:0 carrier:0


but I am still getting the following error

./scriptname.sh: line 22: [: too many arguments the line 22 is the if statement.

Thanx

LIMIT="0"
ERR22=$(cat /root/joint1 | awk ' { print $2 }' | cut -d':' -f2)
 
while true; do
   for file in $ERR22;do
        if [ $ERR22 -gt $LIMIT ];
        then
        echo "cat/root/joint1 |awk ' { print $1, $2 }' "| mail $SUBJECT $ADMINS
        fi
   done
done

Open in new window

0

Featured Post

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question