diff options
| author | Robert Watson <rwatson@FreeBSD.org> | 2000-11-25 03:46:45 +0000 |
|---|---|---|
| committer | Robert Watson <rwatson@FreeBSD.org> | 2000-11-25 03:46:45 +0000 |
| commit | 7ace4e618aec6df22556850df7eeb04f519fef23 (patch) | |
| tree | 6340baec375c7d01353e086f1666fa8e58eb5144 | |
| parent | c20d96e7c4f3a911b2d3f054866ab3cb6e59379f (diff) | |
Notes
| -rw-r--r-- | usr.bin/systat/main.c | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/usr.bin/systat/main.c b/usr.bin/systat/main.c index 8454682e8eba0..f524dcacb8788 100644 --- a/usr.bin/systat/main.c +++ b/usr.bin/systat/main.c @@ -50,6 +50,7 @@ static const char rcsid[] = #include <err.h> #include <locale.h> #include <nlist.h> +#include <paths.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> @@ -57,14 +58,6 @@ static const char rcsid[] = #include "systat.h" #include "extern.h" -static struct nlist namelist[] = { -#define X_FIRST 0 -#define X_HZ 0 - { "_hz" }, -#define X_STATHZ 1 - { "_stathz" }, - { "" } -}; static int dellave; kvm_t *kd; @@ -73,7 +66,7 @@ double avenrun[3]; int col; int naptime = 5; int verbose = 1; /* to report kvm read errs */ -int hz, stathz; +struct clockinfo clkinfo; double hertz; char c; char *namp; @@ -88,7 +81,9 @@ main(argc, argv) int argc; char **argv; { - char errbuf[80]; + char errbuf[80]; + size_t size; + int err; (void) setlocale(LC_TIME, ""); @@ -137,16 +132,16 @@ main(argc, argv) warnx("couldn't set up load average window"); die(0); } - if (kvm_nlist(kd, namelist)) { - nlisterr(namelist); - exit(1); - } - if (namelist[X_FIRST].n_type == 0) - errx(1, "couldn't read namelist"); gethostname(hostname, sizeof (hostname)); - NREAD(X_HZ, &hz, sizeof(hz)); - NREAD(X_STATHZ, &stathz, sizeof(stathz)); - hertz = stathz ? stathz : hz; + + size = sizeof(clkinfo); + err = sysctlbyname("kern.clockrate", &clkinfo, &size, NULL, 0); + if (err != 0 || size != sizeof(clkinfo)) { + perror("kern.clockrate"); + die(0); + } + + hertz = clkinfo.stathz ? clkinfo.stathz : clkinfo.hz; (*curcmd->c_init)(); curcmd->c_flags |= CF_INIT; labels(); |
