Solved

bash script report errors on interfaces

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
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…

685 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