]> granicus.if.org Git - vnstat/commitdiff
fix traffic rate calculation for the last entry of the 5 minute resolution list,...
authorTeemu Toivola <git@humdi.net>
Sun, 28 Apr 2019 10:59:43 +0000 (13:59 +0300)
committerTeemu Toivola <git@humdi.net>
Sun, 28 Apr 2019 10:59:43 +0000 (13:59 +0300)
CHANGES
src/daemon.c
src/dbshow.c
src/image.c

diff --git a/CHANGES b/CHANGES
index b1ceb4110a17ff084a01fb6355f9f3e93c18163e..449fdd43bc1d4593b5f3224dc77efd8e863af52d 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -4,6 +4,8 @@
    - O_CLOEXEC undeclared error when compiling with glibc older than 2.12
    - Image output --headertext wasn't being applied to some output types
    - DefaultDecimals setting wasn't controlling all outputs
+   - Traffic rate for the last entry of the 5 minute resolution list wasn't
+     being correctly calculated
  - New
    - Detection of 32-bit / 64-bit kernel interface counters for improving
      traffic calculations in rollover situations, cfg: 64bitInterfaceCounters
index 0d5862926345812d541b5789a842640315461e57..87e3db06763abc7b632081d1748e3f88b60c09cb 100644 (file)
@@ -568,7 +568,7 @@ int processifinfo(DSTATE *s, datacache **dc)
                }
 
                if (rxchange || txchange || cfg.trafficlessentries) {
-                       xferlog_add(&(*dc)->log, ifinfo.timestamp - (ifinfo.timestamp % 300), rxchange, txchange);
+                       xferlog_add(&(*dc)->log, (*dc)->updated - ((*dc)->updated % 300), rxchange, txchange);
                }
        }
        (*dc)->currx = ifinfo.rx;
index 5c42438869f5cd7ff6ffe38831b7177c7577feb4..7da5ffe9b44cc30106a061612b8d948cf786ad0d 100644 (file)
@@ -465,7 +465,11 @@ void showlist(const interfaceinfo *interface, const char *listname, const char *
                                } else if (listtype == 5) { // hour
                                        e_secs = (uint64_t)(d->tm_sec + (d->tm_min * 60));
                                } else if (listtype == 6) { // 5min
-                                       e_secs = 300;
+                                       if ((&interface->updated - ((uint64_t)&interface->updated % 300)) == (&datalist_i->timestamp - ((uint64_t)&datalist_i->timestamp % 300))) {
+                                               e_secs = (uint64_t)(d->tm_sec + (d->tm_min % 5 * 60));
+                                       } else {
+                                               e_secs = 300;
+                                       }
                                }
                        } else {
                                if (listtype == 1 || listtype == 4) { // day
index 165ad78dbee933adb23ea6ac905f43462b8135d6..60cd9a9c8837f7414a43b4aec937b26b7d02bfa7 100644 (file)
@@ -703,7 +703,11 @@ void drawlist(IMAGECONTENT *ic, const char *listname)
                                } else if (listtype == 5) { // hour
                                        e_secs = (uint64_t)(d->tm_sec + (d->tm_min * 60));
                                } else if (listtype == 6) { // 5min
-                                       e_secs = 300;
+                                       if ((&ic->interface.updated - ((uint64_t)&ic->interface.updated % 300)) == (&datalist_i->timestamp - ((uint64_t)&datalist_i->timestamp % 300))) {
+                                               e_secs = (uint64_t)(d->tm_sec + (d->tm_min % 5 * 60));
+                                       } else {
+                                               e_secs = 300;
+                                       }
                                }
                        } else {
                                if (listtype == 1 || listtype == 4) { // day