diff options
author | Charles Longeau <chl@cvs.openbsd.org> | 2012-10-26 19:16:43 +0000 |
---|---|---|
committer | Charles Longeau <chl@cvs.openbsd.org> | 2012-10-26 19:16:43 +0000 |
commit | de60ac72edad27be2f0d29ba716b7d76bca2ec47 (patch) | |
tree | 475b2217ae716732dd80a3ac159af924382d17d9 /usr.sbin/smtpd/smtpctl.c | |
parent | c6e994ee3aee6111a8a777022604f0c6a3cf3eab (diff) |
add a new uptime.human entry in stats, derived from uptime, but displayed
in a human readable fashion:
uptime=123456
uptime.human=1d10h17m36s
ok gilles@
Diffstat (limited to 'usr.sbin/smtpd/smtpctl.c')
-rw-r--r-- | usr.sbin/smtpd/smtpctl.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/usr.sbin/smtpd/smtpctl.c b/usr.sbin/smtpd/smtpctl.c index 56c0ccb9146..da5f871e06a 100644 --- a/usr.sbin/smtpd/smtpctl.c +++ b/usr.sbin/smtpd/smtpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpctl.c,v 1.93 2012/10/14 11:58:23 gilles Exp $ */ +/* $OpenBSD: smtpctl.c,v 1.94 2012/10/26 19:16:42 chl Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -317,8 +317,8 @@ show_stats_output(void) { struct stat_kv kv, *kvp; struct imsg imsg; - int n; - + int n; + time_t duration; bzero(&kv, sizeof kv); @@ -349,10 +349,12 @@ again: return; } - if (strcmp(kvp->key, "uptime") == 0) - printf("%s=%zd\n", kvp->key, - time(NULL) - kvp->val.u.counter); - else { + if (strcmp(kvp->key, "uptime") == 0) { + duration = time(NULL) - kvp->val.u.counter; + printf("uptime=%zd\n", duration); + printf("uptime.human=%s\n", + duration_to_text(duration)); + } else { switch (kvp->val.type) { case STAT_COUNTER: printf("%s=%zd\n", |