aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/iostat
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2008-08-19 21:33:09 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2008-08-19 21:33:09 +0000
commit32c9e3bd01d5569d30620e53b7d02a4ad57f0e75 (patch)
tree1dc18c736ab6b496f42c560e76245b53c597656b /usr.sbin/iostat
parentf110b23b7d7704cedcc9c5ac5568658938a81850 (diff)
downloadsrc-32c9e3bd01d5569d30620e53b7d02a4ad57f0e75.tar.gz
src-32c9e3bd01d5569d30620e53b7d02a4ad57f0e75.zip
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
Notes
Notes: svn path=/head/; revision=181881
Diffstat (limited to 'usr.sbin/iostat')
-rw-r--r--usr.sbin/iostat/iostat.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/usr.sbin/iostat/iostat.c b/usr.sbin/iostat/iostat.c
index b349cd2c96ee..d8e0bf497983 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) {