From 910a6c8bb3fb274689fe5999405107c65e16516d Mon Sep 17 00:00:00 2001
From: Christof Schulze <christof.schulze@gmx.net>
Date: Fri, 29 Dec 2017 23:49:28 +0100
Subject: [PATCH] gluon-respondd: add current unix time to statistics (#1287)

---
 package/gluon-respondd/src/respondd.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/package/gluon-respondd/src/respondd.c b/package/gluon-respondd/src/respondd.c
index a31693e60..567d47c9f 100644
--- a/package/gluon-respondd/src/respondd.c
+++ b/package/gluon-respondd/src/respondd.c
@@ -34,6 +34,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
+#include <time.h>
 
 #include <sys/vfs.h>
 
@@ -211,11 +212,24 @@ static struct json_object * get_rootfs_usage(void) {
 	return jso;
 }
 
+static struct json_object * get_time(void) {
+	struct timespec now;
+
+	if (clock_gettime(CLOCK_REALTIME, &now) != 0)
+		return NULL;
+
+	return json_object_new_int64(now.tv_sec);
+}
+
 static struct json_object * respondd_provider_statistics(void) {
 	struct json_object *ret = json_object_new_object();
 
 	json_object_object_add(ret, "node_id", gluonutil_wrap_and_free_string(gluonutil_get_node_id()));
 
+	json_object *time = get_time();
+	if (time != NULL)
+		json_object_object_add(ret, "time", time);
+
 	json_object_object_add(ret, "rootfs_usage", get_rootfs_usage());
 	json_object_object_add(ret, "memory", get_memory());
 
-- 
GitLab