summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/smtpctl.c
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2012-08-25 10:23:13 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2012-08-25 10:23:13 +0000
commit459fd55e400d54be5b404e3e83a138a2aea7a176 (patch)
tree77a16945f8e14d2ad1975997db68301d75088ac0 /usr.sbin/smtpd/smtpctl.c
parentb6702e5d938cae875a94aff3b385eb9edb621218 (diff)
- introduce struct stat_value
- statistics can now have a type (counter, timestamp, timeval, timespec and possibly others in the future) - stat_increment() / stat_decrement() now take an increment/decrement value and are at the moment only of type counter - stat_set() now takes a stat_value - provide helpers to convert raw values to stat_value ok eric@, ok chl@ while at it fix a rq_queue_dump() call using a bogus timestamp in scheduler ramqueue.
Diffstat (limited to 'usr.sbin/smtpd/smtpctl.c')
-rw-r--r--usr.sbin/smtpd/smtpctl.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/usr.sbin/smtpd/smtpctl.c b/usr.sbin/smtpd/smtpctl.c
index 194db853cc4..5ee206f15ab 100644
--- a/usr.sbin/smtpd/smtpctl.c
+++ b/usr.sbin/smtpd/smtpctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpctl.c,v 1.87 2012/08/19 14:16:58 chl Exp $ */
+/* $OpenBSD: smtpctl.c,v 1.88 2012/08/25 10:23:12 gilles Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -337,9 +337,32 @@ again:
}
if (strcmp(kvp->key, "uptime") == 0)
- printf("%s=%zd\n", kvp->key, time(NULL) - kvp->val);
- else
- printf("%s=%zd\n", kvp->key, kvp->val);
+ printf("%s=%zd\n", kvp->key,
+ time(NULL) - kvp->val.u.counter);
+ else {
+ switch (kvp->val.type) {
+ case STAT_COUNTER:
+ printf("%s=%zd\n",
+ kvp->key, kvp->val.u.counter);
+ break;
+ case STAT_TIMESTAMP:
+ printf("%s=%" PRId64 "\n",
+ kvp->key, (int64_t)kvp->val.u.timestamp);
+ break;
+ case STAT_TIMEVAL:
+ printf("%s=%zd.%zd\n",
+ kvp->key, kvp->val.u.tv.tv_sec,
+ kvp->val.u.tv.tv_usec);
+ break;
+ case STAT_TIMESPEC:
+ printf("%s=%li.%06li\n",
+ kvp->key,
+ kvp->val.u.ts.tv_sec * 1000000 +
+ kvp->val.u.ts.tv_nsec / 1000000,
+ kvp->val.u.ts.tv_nsec % 1000000);
+ break;
+ }
+ }
kv = *kvp;