diff options
author | jhb <jhb@FreeBSD.org> | 2008-08-19 21:33:09 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2008-08-19 21:33:09 +0000 |
commit | c990b20179fd8f3fcbfb695e812666877aa20419 (patch) | |
tree | 1dc18c736ab6b496f42c560e76245b53c597656b /usr.sbin/iostat | |
parent | 67b02c52de29cfb44eea11a7c46f7bf5de57bf36 (diff) | |
download | FreeBSD-src-c990b20179fd8f3fcbfb695e812666877aa20419.zip FreeBSD-src-c990b20179fd8f3fcbfb695e812666877aa20419.tar.gz |
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
Diffstat (limited to 'usr.sbin/iostat')
-rw-r--r-- | usr.sbin/iostat/iostat.c | 22 |
1 files changed, 14 insertions, 8 deletions
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) { |