there is a utility called ntop. It has source code and looks the same as the command top. Top does have a source forge page but I don't know if they have any files released. It might not be what you want but it's worth a try.
If I find anything I'll post it.