LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   netstat -i (https://www.linuxquestions.org/questions/linux-networking-3/netstat-i-228465/)

r_213 09-09-2004 01:52 AM

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

druuna 09-09-2004 02:48 AM

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.

r_213 09-09-2004 04:02 AM

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?

druuna 09-09-2004 04:26 AM

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.

r_213 09-09-2004 06:10 AM

Ya thanks for ur reply . It was helpful.

Apart from reading the file..any other alternatives?


All times are GMT -5. The time now is 03:08 PM.