LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-05-2013, 09:59 AM   #1
rajaniyer123
Member
 
Registered: Feb 2004
Location: BARODA, GUJARAT
Posts: 259

Rep: Reputation: 30
Command to grep and the Drop Count for scripting


Hi,

I would like to set up the script to monitor the Network interface level packet drops, in which I would like to set up the logic in such a way that when dropped:0 will increase above 100 it should send alert.

RX packets:237722797 errors:0 dropped:0 overruns:0 frame:0

Please let me know an idea how we can set the logic for this in bash script ?

Thanks
Rajan
 
Old 06-06-2013, 01:12 AM   #2
rigor
Member
 
Registered: Sep 2003
Location: 19th moon ................. ................Planet Covid ................Another Galaxy;............. ................Not Yours
Posts: 705

Rep: Reputation: Disabled
rajaniyer123,

For the short term, depending on what you need, you might be able to do something, simple, and brute force such as this:

Code:
#!/bin/bash

dropped_count=`/sbin/ifconfig eth0 | fgrep 'RX packets' | cut -d: -f3-3 | cut -d' ' -f1`

while [[  1  -eq  1  ]]
    do
        if [[  $dropped_count  -gt  100  ]]
            then
            # Put actual ALERT logic here instead of the echo.
            echo ALERT
        fi

        sleep 60
    done
But long term, if I wanted to monitor dropped packets, especially if I thought I might need to do something more involved with it in the future, then for the sake of elegance, I might look into something like extending iptables, building a custom module, so I could launch whatever program I wished, when a threshold was exceeded.

Hope this helps.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get the count by using grep? thomas2004ch Linux - Newbie 3 12-02-2009 02:40 AM
Find/grep/wc command to find matching files, print filename and word count dbasch Linux - Newbie 10 09-14-2009 05:55 PM
How to grep and count on a single go? ZAMO Linux - Software 4 01-15-2009 03:08 AM
LXer: Using Grep To Streamline Your Shell And Command Line Scripting LXer Syndicated Linux News 0 08-08-2008 07:11 AM
How to count and make delay and drop packets forgely fakhrul Linux - Networking 2 04-12-2006 03:49 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration