LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   How to retrieve bytes sent (https://www.linuxquestions.org/questions/linux-networking-3/how-to-retrieve-bytes-sent-294212/)

AzidStar 02-24-2005 02:49 AM

How to retrieve number of bytes sent
 
Helllo everyone.

I was wondering if anyone knew how to retrieve the total amount of data sent on a interface (eth0, ppp0 etc.).
I want to do this from a C-program or perhaps from a shell-script.
The quick and dirty way would be to issue ifconfig and then parse out the data needed from the output.
But this solution does not appeal to me at all. After all ifconfig must be able to this by some means.
Are there some ioctl calls (would be super) that I can make?

Sincerly Kristoffer Nordström

linuxxed 02-24-2005 03:31 AM

Try ethereal or tcpdump ..

AzidStar 02-24-2005 03:41 AM

Nah .. sorry but ethereal and tcpdump are sniffers that are an "ongoing process" that has to look at all data that comes through.

What I am interrested is just retrieving the actual number of bytes that has been sent/recieved on a specific interface.
If you issue ifconfig you will see at the bottom of an interface:

RX bytes:6234130 (5.9 Mb) TX bytes:6234130 (5.9 Mb)

I'm interrested in the number there of how much data has been sent.
There has to be a low-level system command to be issued, like when I retrieve a IP-adress (netmask, ssid, etc) I just issue a ioctl command.

ioctl(skfd, SIOCGIWESSID, &wrq)

Simillary when ifconfig wants to know how much data has been sent it hasnt been running ethereal the whole time.

Hope I made myself a little bit more clearer.

Sincerly Kristoffer Nordström

AzidStar 02-25-2005 01:48 AM

*bump*

linuxxed 02-25-2005 04:26 AM

Quote:

Originally posted by AzidStar
*bump*

Ah . then look at SNMP. If you have net-snmp configured then just snmpwalk it and you should be able to retrieve all the info about the interface real time. I cant remember the exact enterprise.ucdavis..... you'll find it!

AzidStar 03-01-2005 03:25 AM

thnx ... I have worked with snmp before so it shouldnt be to hard to find it in the treestructure.

Sincerly Kristoffer Nordström


All times are GMT -5. The time now is 10:35 PM.