nload

I have been using nload for last few months monitoring the bandwith of syncing builds across servers. Turned out that there were lot of small files and that caused the slowdown.

Anyway, i liked nload and that it handily lets you visualize incoming and outgoing traffic. Easiest way is to just execute command nload and it will list all the devices and let you cycle thru them (via enter key), or alternatively nload eth0 for monitoring eth0.
Further details in man page (https://linux.die.net/man/1/nload)



One of the things, I have been looking for is to reset the counters (statistics). Apparently, nload documentation does not provide any information on how to do it.

Peering under the hood, makes it plain clear that it is reading it from stats as maintained in network driver. The only way to reset those is to either reload drivers or reboot.

https://github.com/rolandriegel/nload/blob/master/src/devreader-linux-sys.cpp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
void DevReaderLinuxSys::readFromDevice(DataFrame& dataFrame)
{
    string devPath = "/sys/class/net/";
    devPath += m_deviceName;
    
    struct stat sysStat;
    if(stat(devPath.c_str(), &sysStat) < 0 || ! S_ISDIR(sysStat.st_mode))
        return;

    dataFrame.setTotalDataIn(readULongSysEntry("statistics/rx_bytes"));
    dataFrame.setTotalDataOut(readULongSysEntry("statistics/tx_bytes"));

    dataFrame.setTotalPacketsIn(readULongSysEntry("statistics/rx_packets"));
    dataFrame.setTotalPacketsOut(readULongSysEntry("statistics/tx_packets"));

    dataFrame.setTotalErrorsIn(readULongSysEntry("statistics/rx_errors"));
    dataFrame.setTotalErrorsOut(readULongSysEntry("statistics/tx_errors"));
    
    dataFrame.setTotalDropsIn(readULongSysEntry("statistics/rx_dropped"));
    dataFrame.setTotalDropsOut(readULongSysEntry("statistics/tx_dropped"));
    
    dataFrame.setValid(true);
}