Sponsored Content
Full Discussion: Netstat -i notification
Operating Systems Linux Netstat -i notification Post 302703769 by sohk220 on Thursday 20th of September 2012 11:08:52 AM
Old 09-20-2012
Netstat -i notification

I'm a bit new to scripting, but have been working on some scripts. I create a script to monitor the network interface for netstat -i, but not sure if I am getting what I need...I'd like to grab the entire column for RX-DRP and inform me of which interface is giving the RX-DRP errors...here is a sample of my script.

Code:
#!/bin/bash
#----------------------------------------------------------------------------
# Check previous netstat output against current netstat output to determine
# if there are packet receive errors.  We have to do this because the counters
# are only cleared when the server is rebooted.
#----------------------------------------------------------------------------

NOW=`date`
echo "$NOW"
emailaddress=emailadr@yoursite.com
logfile=/tmp/1.out


ARGCOUNT=1

if [ $# -ne "$ARGCOUNT" ]
then
  echo "Usage: `basename $0` <$email-address>"
  exit 1
fi


#Check if previous Netstat -i output file exist

if [ -s $logfile ]
then

    OLDNETSTAT=`netstat -i | awk "{print $6}"  | cut -f 15,19,20 -d ' '`
    netstat -i |grep "RX-DRP" | awk "{print $6}" > $logfile  #take a new netstat snapshot
    NOWNETSTAT=`netstat -i | awk "{print $6}"  | cut -f 15,19,20 -d ' '`

    echo "OLDNETSTAT=$OLDNETSTAT"
    echo "NOWNETSTAT=$NOWNETSTAT"

    if [ $OLDNETSTAT -lt $NOWNETSTAT ]
    then
        NUMDROPS=$(( NOWNETSTAT - OLDNETSTAT ))
        servername=`hostname -s`
        MYMESSAGE="WARNING: netstat -i: $NUMDROPS new "RX-DRP" error(s) on $servername"
        mail -s "$MYMESSAGE" $1 < /dev/null
    fi

else
   echo "Running command: netstat -i | awk "{print $6}"  | cut -f 15,19,20 -d ' ' > $logfile"

   netstat -i | awk "{print $6}"  | cut -f 15,19,20 -d ' ' > $logfile
fi

any help would be great...

Thanks,
Moderator's Comments:
Mod Comment Please view this code tag video for how to use code tags when posting code and data.

Last edited by Corona688; 09-20-2012 at 12:15 PM..
 

10 More Discussions You Might Find Interesting

1. IP Networking

Netstat

Giving netstat command on the prompt gives commands such as localhost.43592 localhost.35237 32768 0 32768 0 TIME_WAIT localhost.43594 localhost.43595 32768 0 32768 0 TIME_WAIT localhost.43598 localhost.35237 32768 0 32768 0 TIME_WAIT... (6 Replies)
Discussion started by: DPAI
6 Replies

2. IP Networking

netstat

Hi what is the command to see the process name/application name along with the port number, connection status ... netstat is not giving process/application name Is there any way to know which application is holding which port? Thanks in advance (3 Replies)
Discussion started by: axes
3 Replies

3. UNIX for Dummies Questions & Answers

netstat not working

Hello, One of the solaris machine in our network is giving an error when the netstat command is executed. soloman:/home/db2admin->netstat ip open: Permission denied can't open mib stream: Bad file number But it works with root. I couldnt' get any useful info during my search in google. ... (2 Replies)
Discussion started by: k_pranava
2 Replies

4. AIX

netstat -anp

Hi Which options can I use to show program with its open ports on AIX?. Just like netstat on linux does: netstat -anp|grep 25 tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2112/sendmail: acce Thanks Time to start using code tags. Check your... (2 Replies)
Discussion started by: iga3725
2 Replies

5. Solaris

netstat -- what am i looking at?

Greetings to all, Here is a line of output from my netstat command cbp031.904 wdcprodhome.nfsd 98304 0 49640 0 ESTABLISHED The only thing i recognize is the unix machine "cbp031" but what is .904 and all the other data telling me? Thanks in advance. (3 Replies)
Discussion started by: Harleyrci
3 Replies

6. UNIX for Advanced & Expert Users

Help with netstat

Hi, I want to list the time for how long a secure connections last to my server/blade. i am using netstat command to get the same, but not sure how to get the time for how long connections is being ESTABLISHED. netstat -na | grep 'ESTABLISHED' | grep :443 |awk '{print $4}' | cut -d: -f1 |... (1 Reply)
Discussion started by: Siddheshk
1 Replies

7. UNIX for Dummies Questions & Answers

Need help with a netstat command

Do I have this command correct to show all current connections/sessions my Solaris box has? It does not seem to do anything. netstat -an | grep EST (6 Replies)
Discussion started by: SIFT3R
6 Replies

8. Red Hat

netstat

Hi Can any body tell me about TIME_WAIT status meaning in the following command output. # netstat -anp|grep 5000 tcp 0 0 127.0.0.1:50006 0.0.0.0:* LISTEN 5058/ccsd tcp 0 0 0.0.0.0:50008 0.0.0.0:* ... (3 Replies)
Discussion started by: mastansaheb
3 Replies

9. OS X (Apple)

netstat

When running netstat -i from the Command Terminal, It returns with 21 different connections.. The addresses all look like this: ::1 fe80:1::1 10:dd:b1:a5:c4:ba with Network names like Linke#2 fe80::8e2d How can I delve deeper into this to clarify what is going on with my network?... (0 Replies)
Discussion started by: dwfiedler
0 Replies

10. Shell Programming and Scripting

netstat output

Hi Team, Below is the output of netstat -an | grep 1533 tcp 0 0 17.18.18.12:583 10.3.2.0:1533 ESTABLISHED tcp 0 0 17.18.18.12:370 10.3.2.0:1533 ESTABLISHED Below is the o/p of netstat -a | grep server_name tcp 0 ... (4 Replies)
Discussion started by: Girish19
4 Replies
DDB(8)							    BSD System Manager's Manual 						    DDB(8)

NAME
ddb -- configure DDB kernel debugger properties SYNOPSIS
ddb capture [-M -core] [-N -system] print ddb capture [-M -core] [-N -system] status ddb script scriptname ddb script scriptname=script ddb scripts ddb unscript scriptname ddb pathname DESCRIPTION
The ddb utility configures certain aspects of the ddb(4) kernel debugger from user space that are not configured at compile-time or easily via sysctl(8) MIB entries. To ease configuration, commands can be put in a file which is processed using ddb as shown in the last synopsis line. An absolute pathname must be used. The file will be read line by line and applied as arguments to the ddb utility. Whitespace at the beginning of lines will be ignored as will lines where the first non-whitespace character is '#'. OUTPUT CAPTURE
The ddb utility can be used to extract the contents of the ddb(4) output capture buffer of the current live kernel, or from the crash dump of a kernel on disk. The following debugger commands are available from the command line: capture [-M core] [-N system] print Print the current contents of the ddb(4) output capture buffer. capture [-M core] [-N system] status Print the current status of the ddb(4) output capture buffer. SCRIPTING
The ddb utility can be used to configure aspects of ddb(4) scripting from user space; scripting support is described in more detail in ddb(4). Each of the debugger commands is available from the command line: script scriptname Print the script named scriptname. script scriptname=script Define a script named scriptname. As many scripts contain characters interpreted in special ways by the shell, it is advisable to enclose script in quotes. scripts List currently defined scripts. unscript scriptname Delete the script named scriptname. EXIT STATUS
The ddb utility exits 0 on success, and >0 if an error occurs. EXAMPLES
The following example defines a script that will execute when the kernel debugger is entered as a result of a break signal: ddb script kdb.enter.break="show pcpu; bt" The following example will delete the script: ddb unscript kdb.enter.break For further examples, see the ddb(4) and textdump(4) manual pages. SEE ALSO
ddb(4), textdump(4), sysctl(8) HISTORY
The ddb utility first appeared in FreeBSD 7.1. AUTHORS
Robert N M Watson BUGS
Ideally, ddb would not exist, as all pertinent aspects of ddb(4) could be configured directly via sysctl(8). BSD
December 24, 2008 BSD
All times are GMT -4. The time now is 07:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy