netstat - monitoring - HP UX

This is a discussion on netstat - monitoring - HP UX ; Hello All, using the command 'netstat 5' gives me continous monitoring every 5 seconds. But when I use this in scripts. How do I stop it after 10 instances? Meaning, 'sar -u 5 5' will monitor cpu for every 5 ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: netstat - monitoring

  1. netstat - monitoring

    Hello All,

    using the command 'netstat 5' gives me continous monitoring every 5
    seconds. But when I use this in scripts. How do I stop it after 10
    instances?

    Meaning, 'sar -u 5 5' will monitor cpu for every 5 seconds for 5 times
    and STOP.
    How do I do the same with netstat?

    There is no option for the number of outputs....

    Is there something simmilar to 'netstat 5 5' ??

    Any input is appreciated..

    -- Satish


  2. Re: netstat - monitoring


    Satish wrote:
    > Hello All,
    >
    > using the command 'netstat 5' gives me continous monitoring every 5
    > seconds. But when I use this in scripts. How do I stop it after 10
    > instances?
    >
    > Meaning, 'sar -u 5 5' will monitor cpu for every 5 seconds for 5 times
    > and STOP.
    > How do I do the same with netstat?
    >
    > There is no option for the number of outputs....
    >
    > Is there something simmilar to 'netstat 5 5' ??
    >
    > Any input is appreciated..
    >
    > -- Satish


    I'd suggest something like:

    % cat netlist.sh
    #!/bin/ksh

    interval=$1
    iterations=$2

    netstat $1 &
    sleep $(expr $1 \* $2)
    kill $!

    %./netlist.sh 5 3
    (lan1)-> input output (Total)-> input output
    packets packets packets packets
    -2126205170 1367052622 -2122484504 1370773288
    -2126205152 1367052625 -2122484486 1370773291
    -2126205128 1367052626 -2122484462 1370773292
    %

    HTH,

    Jon


  3. Re: netstat - monitoring

    works fine for me.. thank you.

    -- Satish

    Jon Fife wrote:
    > Satish wrote:
    > > Hello All,
    > >
    > > using the command 'netstat 5' gives me continous monitoring every 5
    > > seconds. But when I use this in scripts. How do I stop it after 10
    > > instances?
    > >
    > > Meaning, 'sar -u 5 5' will monitor cpu for every 5 seconds for 5 times
    > > and STOP.
    > > How do I do the same with netstat?
    > >
    > > There is no option for the number of outputs....
    > >
    > > Is there something simmilar to 'netstat 5 5' ??
    > >
    > > Any input is appreciated..
    > >
    > > -- Satish

    >
    > I'd suggest something like:
    >
    > % cat netlist.sh
    > #!/bin/ksh
    >
    > interval=$1
    > iterations=$2
    >
    > netstat $1 &
    > sleep $(expr $1 \* $2)
    > kill $!
    >
    > %./netlist.sh 5 3
    > (lan1)-> input output (Total)-> input output
    > packets packets packets packets
    > -2126205170 1367052622 -2122484504 1370773288
    > -2126205152 1367052625 -2122484486 1370773291
    > -2126205128 1367052626 -2122484462 1370773292
    > %
    >
    > HTH,
    >
    > Jon



+ Reply to Thread