sigar/exp/dump_kstats.c

25 lines
589 B
C
Raw Normal View History

2004-06-22 06:37:04 +08:00
#include <stdio.h>
#include <kstat.h>
/* gcc -lkstat -o dump_kstats dump_kstats.c */
static const char *kstat_type_names[] = {
"raw", "named", "intr", "io", "timer"
};
int main(int argc, char **argv) {
kstat_ctl_t *kc = kstat_open();
kstat_t *kp;
for (kp = kc->kc_chain; kp != 0; kp = kp->ks_next) {
if (strncmp(kp->ks_name, "kstat_", 6) == 0) {
continue;
}
2007-08-01 21:46:12 +08:00
fprintf(stdout, "%-5s %s.%s[%d]\n",
2004-06-22 06:37:04 +08:00
kstat_type_names[kp->ks_type],
2007-08-01 21:46:12 +08:00
kp->ks_module, kp->ks_name, kp->ks_instance);
2004-06-22 06:37:04 +08:00
}
kstat_close(kc);
}