-
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
-
Re: netstat - monitoring
Satish wrote:[color=blue]
> 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[/color]
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
-
Re: netstat - monitoring
works fine for me.. thank you.
-- Satish
Jon Fife wrote:[color=blue]
> Satish wrote:[color=green]
> > 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[/color]
>
> 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[/color]