summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 265c305)
raw | patch | inline | side by side (parent: 265c305)
author | Sebastian Harl <sh@tokkee.org> | |
Sat, 16 Aug 2014 19:38:21 +0000 (21:38 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sat, 16 Aug 2014 19:38:21 +0000 (21:38 +0200) |
src/frontend/query.c | patch | blob | history | |
src/include/frontend/connection.h | patch | blob | history | |
t/integration/simple_query.sh | patch | blob | history |
diff --git a/src/frontend/query.c b/src/frontend/query.c
index a30bee3e4b8f274730ff650d2ca84cc168fee58d..e0b7181161cde74bbf9ba50d96c49022444ec31e 100644 (file)
--- a/src/frontend/query.c
+++ b/src/frontend/query.c
if (CONN_LOOKUP(node)->filter)
filter = CONN_LOOKUP(node)->filter->matcher;
return sdb_fe_exec_lookup(conn, m, filter);
+ case CONNECTION_TIMESERIES:
+ return sdb_fe_exec_timeseries(conn,
+ CONN_TS(node)->hostname, CONN_TS(node)->metric,
+ &CONN_TS(node)->opts);
default:
sdb_log(SDB_LOG_ERR, "frontend: Unknown command %i", node->cmd);
return 0;
} /* sdb_fe_exec_lookup */
+int
+sdb_fe_exec_timeseries(sdb_conn_t *conn,
+ const char *hostname, const char *metric,
+ sdb_timeseries_opts_t *opts)
+{
+ sdb_strbuf_t *buf;
+
+ buf = sdb_strbuf_create(1024);
+ if (! buf) {
+ char errbuf[1024];
+ sdb_log(SDB_LOG_ERR, "frontend: Failed to create "
+ "buffer to handle TIMESERIES command: %s",
+ sdb_strerror(errno, errbuf, sizeof(errbuf)));
+
+ sdb_strbuf_sprintf(conn->errbuf, "Out of memory");
+ return -1;
+ }
+
+ if (sdb_store_fetch_timeseries(hostname, metric, opts, buf)) {
+ sdb_log(SDB_LOG_ERR, "frontend: Failed to fetch time-series");
+ sdb_strbuf_sprintf(conn->errbuf, "Failed to fetch time-series");
+ sdb_strbuf_destroy(buf);
+ return -1;
+ }
+
+ sdb_connection_send(conn, CONNECTION_OK,
+ (uint32_t)sdb_strbuf_len(buf), sdb_strbuf_string(buf));
+ sdb_strbuf_destroy(buf);
+ return 0;
+} /* sdb_fe_exec_timeseries */
+
/* vim: set tw=78 sw=4 ts=4 noexpandtab : */
index 16ad39a28a51f5c8be014a89ad0714b410806a5c..e963c94e58d0b7f30aa445b38504cdf3a554fbcd 100644 (file)
sdb_fe_exec_lookup(sdb_conn_t *conn, sdb_store_matcher_t *m,
sdb_store_matcher_t *filter);
+/*
+ * sdb_fe_exec_timeseries:
+ * Execute the 'TIMESERIES' command. Send the time-series for the specified
+ * host's metric, serialized as JSON, to the client. See
+ * sdb_store_fetch_timeseries for details.
+ *
+ * Returns:
+ * - 0 on success
+ * - a negative value else
+ */
+int
+sdb_fe_exec_timeseries(sdb_conn_t *conn,
+ const char *hostname, const char *metric,
+ sdb_timeseries_opts_t *opts);
+
#ifdef __cplusplus
} /* extern "C" */
#endif
index 4398b2b9da935be695ed80871cffc7db4690c976..a2df1b933e7d89d316c3fa57c8360cbf486f4c2e 100755 (executable)
-c "LOOKUP hosts MATCHING attribute.invalid = 'none'" )"
echo $output | grep -E '^\[\]$'
+run_sysdb -H "$SOCKET_FILE" \
+ -c "TIMESERIES 'invalid.host'.'invalid-metric'" && exit 1
+
stop_sysdbd