Solved

bash script report errors on interfaces

Posted on 2009-05-12
1
392 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This Windows batch file is useful for organizing image files from a digital camera or other source, but can have many other uses.  It simply renames the file(s) to match their create date.  For example, if you took a picture today at 1:40pm and the …
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…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

758 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now