|
Home > Archive > Unix administration > September 2006 > Netstat with interval, how to stop after 10 lines
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Netstat with interval, how to stop after 10 lines
|
|
| rob@vangelder.co.nz 2006-09-04, 1:29 am |
| I'm using HPUX version 11
I would like to run 'netstat -i 1', but only return the first 10 lines
of output then return to the command line.
Could anyone please supply the command?
Regards,
Rob
| |
| Chris F.A. Johnson 2006-09-04, 1:29 am |
| On 2006-09-04, rob@vangelder.co.nz wrote:
> I'm using HPUX version 11
>
> I would like to run 'netstat -i 1', but only return the first 10 lines
> of output then return to the command line.
>
> Could anyone please supply the command?
netstat -i 1 | head
--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
| |
| Rob van Gelder 2006-09-04, 7:35 pm |
| Hi.
Thank you for your reply.
Unfortunately, this does not release control back to the command line.
I still have to press Ctrl+C.
Could you please offer suggestions?
Regards,
Rob
Chris F.A. Johnson wrote:
> On 2006-09-04, rob@vangelder.co.nz wrote:
>
> netstat -i 1 | head
>
> --
> Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
> Shell Scripting Recipes: | My code in this post, if any,
> A Problem-Solution Approach | is released under the
> 2005, Apress | GNU General Public Licence
| |
| Dave Hinz 2006-09-04, 7:35 pm |
| On 4 Sep 2006 14:15:22 -0700, Rob van Gelder <rob@vangelder.co.nz> wrote:
> Hi.
>
> Thank you for your reply.
>
> Unfortunately, this does not release control back to the command line.
> I still have to press Ctrl+C.
>
> Could you please offer suggestions?
Hi Rob.
A couple things - first, please don't top-post, it screws up the
context of the thread.
Second, what are you actually trying to _do_? I don't mean "see ten
lines of netstat", what are you trying to gain from that? There may be
a way to get you the information you want in a more effective way than
you may be thinking.
Dave Hinz
| |
| Rob van Gelder 2006-09-04, 7:35 pm |
|
Dave Hinz wrote:
> On 4 Sep 2006 14:15:22 -0700, Rob van Gelder <rob@vangelder.co.nz> wrote:
>
> Hi Rob.
>
> A couple things - first, please don't top-post, it screws up the
> context of the thread.
>
> Second, what are you actually trying to _do_? I don't mean "see ten
> lines of netstat", what are you trying to gain from that? There may be
> a way to get you the information you want in a more effective way than
> you may be thinking.
>
> Dave Hinz
My apologies for the top-post. I'm new here... differen't rules for
different groups.
I'm trying to collect packets per second (both in and out) and store
them in a database.
netstat -i 1 does it, but does not ever end.
Regards,
Rob
| |
| stilllearning 2006-09-05, 1:37 pm |
| Rob van Gelder wrote:
> Dave Hinz wrote:
>
> My apologies for the top-post. I'm new here... differen't rules for
> different groups.
>
> I'm trying to collect packets per second (both in and out) and store
> them in a database.
> netstat -i 1 does it, but does not ever end.
>
> Regards,
> Rob
The command terminates with a "Broken Pipe" message on my Solaris
system:
bash-2.03$ netstat -i 1 | head
input eri0 output input (Total) output
packets errs packets errs colls packets errs packets errs colls
12663642 0 11046708 4 0 13355696 0 11738762 4 0
2 0 3 0 0 2 0 3 0 0
2 0 2 0 0 2 0 2 0 0
2 0 2 0 0 2 0 2 0 0
1 0 2 0 0 1 0 2 0 0
1 0 2 0 0 1 0 2 0 0
5 0 6 0 0 6 0 7 0 0
2 0 2 0 0 2 0 2 0 0
Broken Pipe
bash-2.03$
If this does not work for you, here is an alternative:
Send the netstat output to a file, as a background process. For your
database, run "tail -1" on this file to get the latest statistics.
$ netstat -i 1 > mynetstats.out &
$ tail -1 mynetstats.out # run this every second to get
latest statistics.
|
|
|
|
|