If you are trying to get speed information on remote servers, you need to be running an snmp daemon, probably from the
net-snmp package.Then you basically pull
ifInOctects and
ifOutOctets from the remote server and compare it to the previous value.
If you are doing it on a local server you basically pull and parse
/proc/net/netstat and then compare it to a previous value. Somewhere around I have a copy of the code that generates the bandwidth meter on
kernel.org, and I could dig it up if you are interested.