Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

bash script report errors on interfaces

Posted on 2009-05-12
1
Medium Priority
?
401 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
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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…
Utilizing an array to gracefully append to a list of EmailAddresses
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…

971 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