aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2019-11-27 16:47:50 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2020-04-28 14:53:55 +0200
commit1e635ab55003d0a9b66f22947f5b4f8cbc7e2d1f (patch)
tree615189ce9ffda5a1b7a2fe9cc08b25fb41eca646
parent43d5cfc13b3664b4f1cd5ecabd782eef1ff52e57 (diff)
vty: show subscriber: show lu d,h,m,s ago, not just seconds
-rw-r--r--src/hlr_vty_subscr.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/hlr_vty_subscr.c b/src/hlr_vty_subscr.c
index 8079d10..a9262ba 100644
--- a/src/hlr_vty_subscr.c
+++ b/src/hlr_vty_subscr.c
@@ -53,8 +53,20 @@ static void dump_last_lu_seen(struct vty *vty, const char *domain_label, time_t
vty_out(vty, " last LU seen on %s: %s", domain_label, get_datestr(&last_lu_seen, datebuf, sizeof(datebuf)));
if (!timestamp_age(&last_lu_seen, &age))
vty_out(vty, " (invalid timestamp)%s", VTY_NEWLINE);
- else
- vty_out(vty, " (%us ago)%s", age, VTY_NEWLINE);
+ else {
+ vty_out(vty, " (");
+#define UNIT_AGO(UNITNAME, UNITVAL) \
+ if (age >= (UNITVAL)) { \
+ vty_out(vty, "%u%s", age / (UNITVAL), UNITNAME); \
+ age = age % (UNITVAL); \
+ }
+ UNIT_AGO("d", 60*60*24);
+ UNIT_AGO("h", 60*60);
+ UNIT_AGO("m", 60);
+ UNIT_AGO("s", 1);
+ vty_out(vty, " ago)%s", VTY_NEWLINE);
+#undef UNIT_AGO
+ }
}
static void subscr_dump_full_vty(struct vty *vty, struct hlr_subscriber *subscr)