LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 09-09-2004, 01:52 AM   #1
r_213
Member
 
Registered: Sep 2004
Posts: 36

Rep: Reputation: 15
netstat -i


The problem i am facing is that I need to parse the output of netstat -i.
The following is the output I got in my Linux box :-

Kernel Interface table
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0 1500 059003066 0 0 0103788427 0 0 0 BMRU
lo 16436 0 724237 0 0 0 724237 0 0 0 LRU


Here the values of Met and and RX-OK are printed together. There is no space delimiter. Is there any other way to parse the output. This problem occurs for RX-OVR and TX-Ok
 
Old 09-09-2004, 02:48 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
I don't think you can seperate these values when using netstat. You could use the values that can be found in /proc/net/netstat instead (try cat /proc/net/netstat).

You need to grab the appropriate part, but that should not be a problem.

Hope this gets you going again.
 
Old 09-09-2004, 04:02 AM   #3
r_213
Member
 
Registered: Sep 2004
Posts: 36

Original Poster
Rep: Reputation: 15
Thankyou for the reply,

But the solution you have given is for the output of netstat -s and not netstat -i.

For netstat -i the file is /proc/net/dev. But is there any other alternative other than this?
 
Old 09-09-2004, 04:26 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
You could use netstat, but then one needs to assume something:

The Met field is, to my knowledge, a single digit field. Personally I've only seen a 0 (zero) in this field. If this is true you can take the whole number, including the zero and strip it (the RX-OK value will never start with a zero).

I still think that using /proc/net/dev would be better (I don't like to assume things) and easier.
 
Old 09-09-2004, 06:10 AM   #5
r_213
Member
 
Registered: Sep 2004
Posts: 36

Original Poster
Rep: Reputation: 15
Ya thanks for ur reply . It was helpful.

Apart from reading the file..any other alternatives?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
possible intrusion? netstat branden_burger Linux - Security 3 03-03-2005 09:54 AM
netstat -s r_213 Linux - Networking 2 01-27-2005 06:45 AM
netstat question digsby0007 Linux - Networking 1 12-27-2003 05:33 PM
netstat...what is this stuff? hoffman Linux - Newbie 2 12-03-2003 11:00 AM
netstat sopiaz57 Linux - Networking 1 10-14-2003 03:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:19 AM.

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