commit b8b3f4c0983606485917ac6b1e699b69e727acba
parent ef08593941ce8f3e782df9531a3f9f9970f00c59
Author: sin <sin@2f30.org>
Date: Thu, 11 Feb 2016 18:04:43 +0000
Remove delay code, it was wrong anyhow and not particularly useful
Diffstat:
2 files changed, 5 insertions(+), 16 deletions(-)
diff --git a/sbm.1 b/sbm.1
@@ -7,7 +7,6 @@
.Sh SYNOPSIS
.Nm sbm
.Op Fl i Ar interface
-.Op Fl d Ar delay
.Sh DESCRIPTION
.Nm
is a simple bandwidth monitor for OpenBSD.
@@ -16,8 +15,6 @@ is a simple bandwidth monitor for OpenBSD.
.It Fl i Ar interface
Monitor the selected interface. If not provided, the first
enumerated interface will be used.
-.It Fl d Ar delay
-Specify the sampling delay in milliseconds. Defaults to 1 second.
.El
.Sh AUTHORS
.An Dimitris Papastamos Aq Mt sin@2f30.org
diff --git a/sbm.c b/sbm.c
@@ -134,7 +134,7 @@ print(char *ifname, unsigned long long rxbits, unsigned long long txbits)
}
void
-loop(char *ifname, long long delay)
+loop(char *ifname)
{
unsigned long long oldrxbytes, rxbytes;
unsigned long long oldtxbytes, txbytes;
@@ -147,39 +147,31 @@ loop(char *ifname, long long delay)
(txbytes - oldtxbytes) * 8);
oldrxbytes = rxbytes;
oldtxbytes = txbytes;
- usleep(delay * 1000);
+ usleep(1000 * 1000);
}
}
void
usage(void)
{
- fprintf(stderr, "usage: %s [-i interface] [-d delay]\n", argv0);
+ fprintf(stderr, "usage: %s [-i interface]\n", argv0);
exit(1);
}
int
main(int argc, char *argv[])
{
- char ifname[IFNAMSIZ] = "", *arg;
- const char *errstr;
- long long delay = 1000;
+ char ifname[IFNAMSIZ] = "";
ARGBEGIN {
case 'i':
strlcpy(ifname, EARGF(usage()), sizeof(ifname));
break;
- case 'd':
- arg = EARGF(usage());
- delay = strtonum(arg, 100, 60000, &errstr);
- if (errstr)
- errx(1, "%s: %s", arg, errstr);
- break;
default:
usage();
} ARGEND
scan(ifname);
- loop(ifname, delay);
+ loop(ifname);
return 0;
}