diff options
author | Mark Wong <mark@2ndQuadrant.com> | 2020-04-16 08:41:15 -0700 |
---|---|---|
committer | Mark Wong <mark@2ndQuadrant.com> | 2020-04-16 08:41:15 -0700 |
commit | ead50dd088d76ade6b39d8dcb4be9fffcdd6b3ad (patch) | |
tree | efa7c409b85d46c41498b2a4ddfab74c75e35075 | |
parent | 1e94e41d33a0300074fb6f4cff0b1fe981e77c80 (diff) |
m_freebsd: add support for displaying io stats
-rw-r--r-- | machine/m_freebsd.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/machine/m_freebsd.c b/machine/m_freebsd.c index 204610b..d290d63 100644 --- a/machine/m_freebsd.c +++ b/machine/m_freebsd.c @@ -92,6 +92,9 @@ struct pg_proc RB_ENTRY(pg_proc) entry; pid_t pid; + /* This will be the previous copy of ki_rusage. */ + struct rusage ki_rusage; + char *name; char *usename; int pgstate; @@ -131,6 +134,7 @@ RB_GENERATE(pgproc, pg_proc, entry, topproccmp) #define VP(pp, field) ((pp)->ki_##field) #define PRUID(pp) ((pp)->ki_ruid) #endif +#define RU(pp) (&(pp)->ki_rusage) /* what we consider to be process size: */ #if OSMAJOR <= 4 @@ -186,6 +190,9 @@ char *state_abbrev[] = }; +char fmt_header_io[] = + "PID USERNAME VCSW IVCSW READ WRITE FAULT TOTAL COMMAND"; + static kvm_t * kd; /* values that we stash away in _init and use in later routines */ @@ -634,6 +641,7 @@ get_process_info(struct system_info *si, { free(n); n = p; + memcpy(RU(n), RU(&junk2[0]), sizeof(struct rusage)); } if (mode == MODE_REPLICATION) @@ -690,6 +698,40 @@ char fmt[MAX_COLS]; /* static area where result is built */ char cmd[MAX_COLS]; char * +format_next_io(caddr_t handle) +{ + register struct kinfo_proc *pp; + struct handle *hp; + struct pg_proc n, *p = NULL; + + /* find and remember the next proc structure */ + hp = (struct handle *) handle; + pp = *(hp->next_proc++); + hp->remaining--; + + memset(&n, 0, sizeof(struct pg_proc)); + n.pid = PP(pp, pid); + p = RB_FIND(pgproc, &head_proc, &n); + + snprintf(fmt, sizeof(fmt), + "%5d %-*.*s %6ld %6ld %6ld %6ld %6ld %6ld %s", + PP(pp, pid), + namelength, namelength, + p->usename, + RU(pp)->ru_nvcsw - RU(p)->ru_nvcsw, + RU(pp)->ru_nivcsw - RU(p)->ru_nivcsw, + RU(pp)->ru_inblock - RU(p)->ru_inblock, + RU(pp)->ru_oublock - RU(p)->ru_oublock, + RU(pp)->ru_majflt - RU(p)->ru_majflt, + (RU(pp)->ru_inblock - RU(p)->ru_inblock) + + (RU(pp)->ru_oublock - RU(p)->ru_oublock) + + (RU(pp)->ru_majflt - RU(p)->ru_majflt), + p->name); + + return fmt; +} + +char * format_next_process(caddr_t handle) { |