File: NEWS

package info (click to toggle)
wmfire 1.2.4-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 700 kB
  • sloc: ansic: 796; sh: 785; makefile: 20
file content (41 lines) | stat: -rw-r--r-- 1,012 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Miscellaneous Ramblings
-----------------------

So, I tried to be clever and use rate adaptive network monitoring.
Needless to say, it didn't seem to work quite properly...always reading
too low. If slowly polled once per second without any filesystem blocking
I believe it should work.

----CODE----

int
update_net()
{
        glibtop_netload netload;
        unsigned long netdif;
        static unsigned long netmax = 1, netold = 0;
        int percent;

        glibtop_get_netload(&netload,net_dev);

        netdif = netload.bytes_total - netold;

        /* Reinitialise or restart on network down */
        if (net_init || netdif < 0) {
                net_init = 0;
                netmax = 1;
                netold = netload.bytes_total;

                return 0;
        }

        /* Rate adaptive to maximum transmission */
        if (netdif > netmax)
                netmax = netdif;

        percent = 100 * netdif / netmax;

        netold = netload.bytes_total;

        return percent;
}