sbm

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

commit c0be38706db5461be5147c303a89393b2c977010
parent 670751a4b736acec3598bea6ef2ab843a0e639ae
Author: sin <sin@2f30.org>
Date:   Mon, 22 Feb 2016 15:24:33 +0000

Rename clock_gettime_tv() to getmonotime()

Diffstat:
Msbm.c | 10+++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/sbm.c b/sbm.c @@ -186,12 +186,12 @@ print(char *ifname, uint64_t rxbits, uint64_t txbits, } int -clock_gettime_tv(clockid_t clock_id, struct timeval *tv) +getmonotime(struct timeval *tv) { struct timespec ts; int ret; - ret = clock_gettime(clock_id, &ts); + ret = clock_gettime(CLOCK_MONOTONIC, &ts); if (ret < 0) return -1; tv->tv_sec = ts.tv_sec; @@ -222,16 +222,16 @@ loop(char *ifname, long count, struct timeval *delay) uint64_t oldtxpps, txpps, difftxpps; long n = 0; - clock_gettime_tv(CLOCK_MONOTONIC, &old); + getmonotime(&old); sample(ifname, &oldrxbytes, &oldtxbytes, &oldrxpps, &oldtxpps); for (;;) { usleep(100000); /* sleep for 100 ms */ sample(ifname, &rxbytes, &txbytes, &rxpps, &txpps); - clock_gettime_tv(CLOCK_MONOTONIC, &now); + getmonotime(&now); timersub(&now, &old, &diff); if (timercmp(&diff, delay, <)) continue; - clock_gettime_tv(CLOCK_MONOTONIC, &old); + getmonotime(&old); diffrxbits = (rxbytes - oldrxbytes) * 8; difftxbits = (txbytes - oldtxbytes) * 8; diffrxbits = diffrxbits * 1000 / tv2ms(&diff);