From 7ea35e06fd54736fd9307ff2d419c54e0f4a525f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Mon, 9 Apr 2018 20:35:25 +0200 Subject: [PATCH] Print the time when stats last updated --- src/stats.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/stats.c b/src/stats.c index 5ac56fdc2..6c81d2dcc 100644 --- a/src/stats.c +++ b/src/stats.c @@ -445,6 +445,8 @@ stats_summary(struct conf *conf) { struct counters *counters = counters_init(STATS_END); time_t oldest = 0; + time_t updated = 0; + struct stat st; assert(conf); @@ -464,6 +466,11 @@ stats_summary(struct conf *conf) if (current != 0 && (oldest == 0 || current < oldest)) { oldest = current; } + if (stat(fname, &st) == 0) { + if (st.st_mtime > updated) { + updated = st.st_mtime; + } + } free(fname); } @@ -478,6 +485,12 @@ stats_summary(struct conf *conf) strftime(timestamp, sizeof(timestamp), "%c", tm); printf("stats zero time %s\n", timestamp); } + if (updated) { + struct tm *tm = localtime(&updated); + char timestamp[100]; + strftime(timestamp, sizeof(timestamp), "%c", tm); + printf("stats updated %s\n", timestamp); + } // ...and display them. for (int i = 0; stats_info[i].message; i++) { -- 2.47.2