diff options
Diffstat (limited to 'usr.bin/systat/vmstat.c')
-rw-r--r-- | usr.bin/systat/vmstat.c | 33 |
1 files changed, 7 insertions, 26 deletions
diff --git a/usr.bin/systat/vmstat.c b/usr.bin/systat/vmstat.c index b59e43941fc..00a5f5764ed 100644 --- a/usr.bin/systat/vmstat.c +++ b/usr.bin/systat/vmstat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmstat.c,v 1.87 2018/09/26 17:23:13 cheloha Exp $ */ +/* $OpenBSD: vmstat.c,v 1.88 2018/10/05 18:56:57 cheloha Exp $ */ /* $NetBSD: vmstat.c,v 1.5 1996/05/10 23:16:40 thorpej Exp $ */ /*- @@ -98,7 +98,6 @@ static time_t t; static double etime; static float hertz; static int nintr; -static int ncpu; static long *intrloc; static char **intrname; static int ipktsrow; @@ -201,12 +200,6 @@ initvmstat(void) return (-1); } - mib[0] = CTL_HW; - mib[1] = HW_NCPU; - size = sizeof(ncpu); - if (sysctl(mib, 2, &ncpu, &size, NULL, 0) < 0) - return (-1); - allocinfo(&s); allocinfo(&s1); allocinfo(&s2); @@ -599,12 +592,11 @@ putfloat(double f, int l, int c, int w, int d, int nz) static void getinfo(struct Info *si) { - static int cp_time2_mib[3] = { CTL_KERN, KERN_CPTIME2, 0 }; + static int cp_time_mib[] = { CTL_KERN, KERN_CPTIME }; static int nchstats_mib[2] = { CTL_KERN, KERN_NCHSTATS }; static int uvmexp_mib[2] = { CTL_VM, VM_UVMEXP }; static int vmtotal_mib[2] = { CTL_VM, VM_METER }; - int mib[4], cpu, i; - long cpu_time[CPUSTATES]; + int mib[4], i; size_t size; dkreadstats(); @@ -620,21 +612,10 @@ getinfo(struct Info *si) } } - memset(&si->time, 0, sizeof(si->time)); - for (cpu = 0; cpu < ncpu; cpu++) { - cp_time2_mib[2] = cpu; - size = sizeof(cpu_time); - if (sysctl(cp_time2_mib, 3, &cpu_time, &size, NULL, 0) < 0) { - if (errno != ENODEV) { - error("Can't get KERN_CPTIME2: %s\n", - strerror(errno)); - memset(&si->time, 0, sizeof(si->time)); - break; - } - continue; /* ignore offline CPUs */ - } - for (i = 0; i < nitems(si->time); i++) - si->time[i] += cpu_time[i]; + size = sizeof(si->time); + if (sysctl(cp_time_mib, 2, &si->time, &size, NULL, 0) < 0) { + error("Can't get KERN_CPTIME: %s\n", strerror(errno)); + memset(&si->time, 0, sizeof(si->time)); } size = sizeof(si->nchstats); |