sbm

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

commit ccd44aeeec1d5aefd1ddae46e186139193f98343
parent 6bf8a6799faea4ff85fe7a83c7941e9c01a04097
Author: Quentin Rameau <quinq@fifth.space>
Date:   Fri,  5 Aug 2016 12:49:15 +0200

Change the uptime format to "nd nh nm ns"

Diffstat:
Msbm.c | 15++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/sbm.c b/sbm.c @@ -238,10 +238,11 @@ printrxtx(void) char *rxsuffix, *txsuffix; double rxround, txround; uint64_t rxbits, txbits; - unsigned int days, hours, minutes; + unsigned int days, hours, minutes, seconds; getmonotime(&now); timersub(&now, &begin, &uptime); + seconds = uptime.tv_sec % 60; uptime.tv_sec /= 60; minutes = uptime.tv_sec % 60; uptime.tv_sec /= 60; @@ -257,13 +258,13 @@ printrxtx(void) (int)strlen(ifname) + 1, "", rxround, rxsuffix, txround, txsuffix); if (days != 0) - printf("%d day%s, ", days, - days > 1 ? "s" : ""); + printf("%dd ", days); if (hours != 0) - printf("%02d:%02d, ", hours, minutes); - else - printf("%d min%s, ", minutes, - minutes > 1 ? "s" : ""); + printf("%dh ", hours); + if (minutes != 0) + printf("%dm ", minutes); + if (seconds != 0) + printf("%ds", seconds); putchar('\n'); }