From c990b20179fd8f3fcbfb695e812666877aa20419 Mon Sep 17 00:00:00 2001 From: jhb Date: Tue, 19 Aug 2008 21:33:09 +0000 Subject: Use kvm_getcptime(3) to fetch the global CPU time stats from a crashdump since the 'cp_time' symbol doesn't exist in recent kernels. This fixes iostat and vmstat on crash dumps. MFC after: 1 week --- usr.sbin/iostat/iostat.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'usr.sbin/iostat') diff --git a/usr.sbin/iostat/iostat.c b/usr.sbin/iostat/iostat.c index b349cd2..d8e0bf4 100644 --- a/usr.sbin/iostat/iostat.c +++ b/usr.sbin/iostat/iostat.c @@ -124,11 +124,9 @@ struct nlist namelist[] = { { "_tk_nin" }, #define X_TK_NOUT 1 { "_tk_nout" }, -#define X_CP_TIME 2 - { "_cp_time" }, -#define X_BOOTTIME 3 +#define X_BOOTTIME 2 { "_boottime" }, -#define X_END 3 +#define X_END 2 { NULL }, }; @@ -463,11 +461,19 @@ main(int argc, char **argv) } if (Cflag > 0) { - if (readvar(kd, "kern.cp_time", X_CP_TIME, - &cur.cp_time, sizeof(cur.cp_time)) != 0) { - Cflag = 0; - warnx("disabling CPU time statistics"); + if (kd == NULL) { + if (readvar(kd, "kern.cp_time", 0, + &cur.cp_time, sizeof(cur.cp_time)) != 0) + Cflag = 0; + } else { + if (kvm_getcptime(kd, cur.cp_time) < 0) { + warnx("kvm_getcptime: %s", + kvm_geterr(kd)); + Cflag = 0; + } } + if (Cflag == 0) + warnx("disabling CPU time statistics"); } if (!--headercount) { -- cgit v1.1