summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ff70b10)
raw | patch | inline | side by side (parent: ff70b10)
author | Florian Forster <octo@noris.net> | |
Fri, 24 Dec 2010 09:17:08 +0000 (10:17 +0100) | ||
committer | Florian Forster <octo@noris.net> | |
Fri, 24 Dec 2010 09:17:08 +0000 (10:17 +0100) |
diff --git a/share/collection.js b/share/collection.js
index e071f2fe6bfb5fcf379863f13b1a090f1a79fc9a..7bcdc54fc0a01d01a6674a6d727bfabc2783b1be 100644 (file)
--- a/share/collection.js
+++ b/share/collection.js
params.action = "instance_data_json";
params.begin = begin || inst.begin;
params.end = end || inst.end;
- params.resolution = Math.round ((params.end - params.begin) / c4.config.width);
+ params.resolution = (params.end - params.begin) / c4.config.width;
$.getJSON ("collection.fcgi", params,
function (data)
index 53823f32eba28bb3cf61056940c3c1b7c8c70fe1..a2de10e4f437c91defebeea007272b58dd055823 100644 (file)
fwrite ((void *) str, /* size = */ len, /* nmemb = */ 1, stdout);
} /* }}} void write_callback */
+static int param_get_resolution (dp_time_t *resolution) /* {{{ */
+{
+ const char *tmp;
+ char *endptr;
+ double value;
+
+ tmp = param ("resolution");
+ if (tmp == NULL)
+ return (ENOENT);
+
+ errno = 0;
+ endptr = NULL;
+ value = strtod (tmp, &endptr);
+ if (errno != 0)
+ return (errno);
+ else if ((value <= 0.0) || (endptr == tmp))
+ return (EINVAL);
+
+ resolution->tv_sec = (time_t) value;
+ resolution->tv_nsec = (long) ((value - ((double) resolution->tv_sec)) * 1000000000.0);
+ return (0);
+} /* }}} int param_get_resolution */
+
int action_instance_data_json (void) /* {{{ */
{
graph_config_t *cfg;
dp_time_t dp_begin = { 0, 0 };
dp_time_t dp_end = { 0, 0 };
+ dp_time_t dp_resolution = { 0, 0 };
yajl_gen_config handler_config;
yajl_gen handler;
dp_end.tv_sec = tt_end;
dp_end.tv_nsec = 0;
+ dp_resolution.tv_sec = (tt_end - tt_begin) / 324;
+ param_get_resolution (&dp_resolution);
+
memset (&handler_config, 0, sizeof (handler_config));
handler_config.beautify = 0;
handler_config.indentString = " ";
printf ("\n");
status = inst_data_to_json (inst,
- dp_begin, dp_end, handler);
+ dp_begin, dp_end, dp_resolution, handler);
yajl_gen_free (handler);
diff --git a/src/graph_ident.c b/src/graph_ident.c
index 02e1aaa3f74518075f2e8cdd558b25bf32ef15eb..abf396de3ba4417518cb52a49a53a534433f5039 100644 (file)
--- a/src/graph_ident.c
+++ b/src/graph_ident.c
#include <sys/types.h>
#include <sys/stat.h>
#include <math.h>
+#include <assert.h>
#include "graph_ident.h"
#include "common.h"
{
dp_time_t begin;
dp_time_t end;
+ dp_time_t interval;
yajl_gen handler;
};
typedef struct ident_data_to_json__data_s ident_data_to_json__data_t;
double first_value_time_double;
double interval_double;
-
- /* TODO: Make points_num_limit configurable. */
- /* points_num_limit: The number of data-points to send at least. */
- size_t points_num_limit = 400;
+ double interval_requested;
size_t points_consolidate;
first_value_time_double = ((double) first_value_time.tv_sec)
+ (((double) first_value_time.tv_nsec) / 1000000000.0);
interval_double = ((double) interval.tv_sec)
+ (((double) interval.tv_nsec) / 1000000000.0);
+ interval_requested = ((double) data->interval.tv_sec)
+ + (((double) data->interval.tv_nsec) / 1000000000.0);
- if (data_points_num <= points_num_limit)
+ if (interval_requested < (2.0 * interval_double))
points_consolidate = 1;
else
- points_consolidate = data_points_num / points_num_limit;
+ points_consolidate = (size_t) (interval_requested / interval_double);
+ assert (points_consolidate >= 1);
if (points_consolidate > 1)
{
} /* }}} int ident_data_to_json__get_ds_name */
int ident_data_to_json (graph_ident_t *ident, /* {{{ */
- dp_time_t begin, dp_time_t end,
+ dp_time_t begin, dp_time_t end, dp_time_t res,
yajl_gen handler)
{
ident_data_to_json__data_t data;
data.begin = begin;
data.end = end;
+ data.interval = res;
data.handler = handler;
/* Iterate over all DS names */
diff --git a/src/graph_ident.h b/src/graph_ident.h
index 5f7b2d45aedcb9d9bf6ac03fb475950412c9e369..9cbd08ad337127f6c46765eaa84a930e51de3104 100644 (file)
--- a/src/graph_ident.h
+++ b/src/graph_ident.h
int ident_to_json (const graph_ident_t *ident,
yajl_gen handler);
int ident_data_to_json (graph_ident_t *ident,
- dp_time_t begin, dp_time_t end,
+ dp_time_t begin, dp_time_t end, dp_time_t interval,
yajl_gen handler);
int ident_describe (const graph_ident_t *ident, const graph_ident_t *selector,
diff --git a/src/graph_instance.c b/src/graph_instance.c
index 2249cc031b50e5b983ebfd9102150b058010671c..f2bb3ba49d2b94427bbab5915b3ac6e184a7d5c5 100644 (file)
--- a/src/graph_instance.c
+++ b/src/graph_instance.c
} /* }}} int inst_to_json */
int inst_data_to_json (const graph_instance_t *inst, /* {{{ */
- dp_time_t begin, dp_time_t end,
+ dp_time_t begin, dp_time_t end, dp_time_t res,
yajl_gen handler)
{
size_t i;
yajl_gen_array_open (handler);
for (i = 0; i < inst->files_num; i++)
- ident_data_to_json (inst->files[i], begin, end, handler);
+ ident_data_to_json (inst->files[i], begin, end, res, handler);
yajl_gen_array_close (handler);
return (0);
diff --git a/src/graph_instance.h b/src/graph_instance.h
index 56858533adb62ce7a297bb4325230354ca735b19..37c6b69a3c04b1d6a8bf1a8fa4ff9e7c95a89525 100644 (file)
--- a/src/graph_instance.h
+++ b/src/graph_instance.h
int inst_to_json (const graph_instance_t *inst, yajl_gen handler);
int inst_data_to_json (const graph_instance_t *inst,
- dp_time_t begin, dp_time_t end,
+ dp_time_t begin, dp_time_t end, dp_time_t res,
yajl_gen handler);
int inst_describe (graph_config_t *cfg, graph_instance_t *inst,