From 9ef2eba5e4344c1370754004a997970ca11e16ca Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Sun, 8 Apr 2018 23:57:15 +0200 Subject: Introduce thread management for future reading job Change-Id: I1d47aef85c4a90d10d7cd5f85c357e9e35664836 Signed-off-by: Romain Forlot --- src/plugins/influxdb.c | 10 +++++++--- src/plugins/tsdb.c | 16 ++++++++-------- src/plugins/tsdb.h | 8 ++++++++ 3 files changed, 23 insertions(+), 11 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/influxdb.c b/src/plugins/influxdb.c index 74c1297..17c140d 100644 --- a/src/plugins/influxdb.c +++ b/src/plugins/influxdb.c @@ -15,7 +15,12 @@ * limitations under the License. */ +#define _GNU_SOURCE +#include +#include + #include "tsdb.h" +#include "wrap-json.h" int create_database() { @@ -37,7 +42,6 @@ int create_database() } curl_easy_cleanup(request); - free(post_data); if(ret == 0) AFB_NOTICE("Database 'agl-collector' created"); @@ -148,7 +152,7 @@ CURL *make_curl_write_post(const char *url, struct json_object *metric) curl = NULL; } else { - for(int i = lpd; i != 0; i--) { + for(long unsigned int i = lpd; i != 0; i--) { format_write_query(query, name, source, unit, identity, jv, timestamp); post_data[i] = i == lpd ? NULL : query; } @@ -169,5 +173,5 @@ CURL *influxdb_write(const char* host, int port, json_object *metric) strncat(url, host, strlen(host)); strncat(url, ":"DEFAULT_DBPORT"/write?db="DEFAULT_DB, strlen(":"DEFAULT_DBPORT"/write?db="DEFAULT_DB)); - curl_request = make_curl_write_post(url, metric); + return make_curl_write_post(url, metric); } diff --git a/src/plugins/tsdb.c b/src/plugins/tsdb.c index 20a3e89..f7a8ee2 100644 --- a/src/plugins/tsdb.c +++ b/src/plugins/tsdb.c @@ -17,14 +17,6 @@ #include "tsdb.h" -int db_ping() -{ - int ret = 0; - if(influxdb_ping() == 0) ret = INFLUX; - - return ret; -} - int influxdb_ping() { int ret = 0; @@ -41,3 +33,11 @@ int influxdb_ping() curl_easy_cleanup(request); return ret; } + +int db_ping() +{ + int ret = 0; + if(influxdb_ping() == 0) ret = INFLUX; + + return ret; +} diff --git a/src/plugins/tsdb.h b/src/plugins/tsdb.h index 967bce0..527f538 100644 --- a/src/plugins/tsdb.h +++ b/src/plugins/tsdb.h @@ -15,9 +15,17 @@ * limitations under the License. */ +#define AFB_BINDING_VERSION 2 +#include + #include #include "curl-wrap.h" +#define DEFAULT_DB "agl-garner" +#define DEFAULT_DBHOST "localhost" +#define DEFAULT_DBPORT "8086" +#define URL_MAXIMUM_LENGTH 2047 + enum db_available { INFLUX = 1, GRAPHITE = 2, -- cgit 1.2.3-korg