sbm

simple bandwidth monitor
git clone git://git.2f30.org/sbm
Log | Files | Refs | LICENSE

commit 670751a4b736acec3598bea6ef2ab843a0e639ae
parent dc8458f91696f8f808e1537efde130976d47a439
Author: sin <sin@2f30.org>
Date:   Mon, 22 Feb 2016 15:06:38 +0000

Fix minimum delay at 100 ms

CPU usage is minimized dramatically and lower periods are generally
not useful.

Diffstat:
Msbm.1 | 3++-
Msbm.c | 4+++-
2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/sbm.1 b/sbm.1 @@ -23,7 +23,8 @@ is 0, it will loop forever. This is the default. .It Fl d Ar delay Sample interface statistics every .Ar delay -ms. The default is 1000 ms. +ms. The default delay is 1000 ms and the minimum delay +is 100 ms. .It Fl i Ar interface Monitor the selected .Ar interface . diff --git a/sbm.c b/sbm.c @@ -225,7 +225,7 @@ loop(char *ifname, long count, struct timeval *delay) clock_gettime_tv(CLOCK_MONOTONIC, &old); sample(ifname, &oldrxbytes, &oldtxbytes, &oldrxpps, &oldtxpps); for (;;) { - usleep(1000); /* sleep for 1ms */ + usleep(100000); /* sleep for 100 ms */ sample(ifname, &rxbytes, &txbytes, &rxpps, &txpps); clock_gettime_tv(CLOCK_MONOTONIC, &now); timersub(&now, &old, &diff); @@ -273,6 +273,8 @@ main(int argc, char *argv[]) delay = strtol(EARGF(usage()), &end, 10); if (*end != '\0' || errno) errx(1, "invalid delay"); + if (delay < 100) + errx(1, "minimum delay is 100 ms"); break; case 'i': strncpy(ifname, EARGF(usage()), sizeof(ifname));