From be6447ca2038c84d2e946e27b897815e95c48e34 Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Sat, 14 Apr 2018 01:55:23 +0200 Subject: Utility function to return nanosecond timestamp Change-Id: I73261cae3ed9b4d449e2b83b0578ddd2c5df89f1 Signed-off-by: Romain Forlot --- src/plugins/tsdb.c | 9 +++++++++ src/plugins/tsdb.h | 2 ++ 2 files changed, 11 insertions(+) (limited to 'src') diff --git a/src/plugins/tsdb.c b/src/plugins/tsdb.c index f7a8ee2..e393109 100644 --- a/src/plugins/tsdb.c +++ b/src/plugins/tsdb.c @@ -15,6 +15,7 @@ * limitations under the License. */ +#include #include "tsdb.h" int influxdb_ping() @@ -41,3 +42,11 @@ int db_ping() return ret; } + +u_int64_t get_ts() +{ + struct timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + + return (int64_t)(ts.tv_sec) * (int64_t)1000000000 + (int64_t)(ts.tv_nsec); +} diff --git a/src/plugins/tsdb.h b/src/plugins/tsdb.h index d7d6c2f..5c0245c 100644 --- a/src/plugins/tsdb.h +++ b/src/plugins/tsdb.h @@ -43,3 +43,5 @@ void influxdb_write_curl_cb(void *closure, int status, CURL *curl, const char *r int influxdb_reader(void *args); int db_ping(); + +u_int64_t get_ts(); -- cgit 1.2.3-korg