summaryrefslogtreecommitdiffstats
path: root/src/rrd2json.c
diff options
context:
space:
mode:
authorFederico Ceratto <federico.ceratto@gmail.com>2016-11-23 15:49:10 +0000
committerFederico Ceratto <federico.ceratto@gmail.com>2016-11-23 15:49:10 +0000
commit87649cf32bd0e14d5a903fb85b01e9f41a253540 (patch)
treebbefda6dac074aeb87529592e8e5064f69cbe024 /src/rrd2json.c
parentImported Upstream version 1.3.0+dfsg (diff)
downloadnetdata-87649cf32bd0e14d5a903fb85b01e9f41a253540.tar.xz
netdata-87649cf32bd0e14d5a903fb85b01e9f41a253540.zip
New upstream version 1.4.0+dfsgupstream/1.4.0+dfsg
Diffstat (limited to '')
-rw-r--r--src/rrd2json.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/rrd2json.c b/src/rrd2json.c
index 9009a8b1..474b5915 100644
--- a/src/rrd2json.c
+++ b/src/rrd2json.c
@@ -1,8 +1,5 @@
#include "common.h"
-#define HOSTNAME_MAX 1024
-char *hostname = "unknown";
-
void rrd_stats_api_v1_chart(RRDSET *st, BUFFER *wb)
{
pthread_rwlock_rdlock(&st->rwlock);
@@ -84,7 +81,7 @@ void rrd_stats_api_v1_charts(BUFFER *wb)
",\n\t\"update_every\": %d"
",\n\t\"history\": %d"
",\n\t\"charts\": {"
- , hostname
+ , localhost.hostname
, rrd_update_every
, rrd_default_history_entries
);
@@ -246,7 +243,7 @@ void rrd_stats_all_json(BUFFER *wb)
"\t\"history\": %d,\n"
"\t\"memory\": %lu\n"
"}\n"
- , hostname
+ , localhost.hostname
, rrd_update_every
, rrd_default_history_entries
, memory
@@ -1217,13 +1214,13 @@ RRDR *rrd2rrdr(RRDSET *st, long points, long long after, long long before, int g
absolute_period_requested = 0;
}
- // allow relative for before and after
- if(((before < 0)?-before:before) <= (st->update_every * st->entries)) {
+ // allow relative for before and after (smaller than 3 years)
+ if(((before < 0)?-before:before) <= (3 * 365 * 86400)) {
before = last_entry_t + before;
absolute_period_requested = 0;
}
- if(((after < 0)?-after:after) <= (st->update_every * st->entries)) {
+ if(((after < 0)?-after:after) <= (3 * 365 * 86400)) {
if(after == 0) after = -st->update_every;
after = before + after;
absolute_period_requested = 0;
@@ -1567,9 +1564,9 @@ int rrd2value(RRDSET *st, BUFFER *wb, calculated_number *n, const char *dimensio
}
if(r->result_options & RRDR_RESULT_OPTION_RELATIVE)
- wb->options |= WB_CONTENT_NO_CACHEABLE;
+ buffer_no_cacheable(wb);
else if(r->result_options & RRDR_RESULT_OPTION_ABSOLUTE)
- wb->options |= WB_CONTENT_CACHEABLE;
+ buffer_cacheable(wb);
options = rrdr_check_options(r, options, dimensions);
@@ -1595,9 +1592,9 @@ int rrd2format(RRDSET *st, BUFFER *wb, BUFFER *dimensions, uint32_t format, long
}
if(r->result_options & RRDR_RESULT_OPTION_RELATIVE)
- wb->options |= WB_CONTENT_NO_CACHEABLE;
+ buffer_no_cacheable(wb);
else if(r->result_options & RRDR_RESULT_OPTION_ABSOLUTE)
- wb->options |= WB_CONTENT_CACHEABLE;
+ buffer_cacheable(wb);
options = rrdr_check_options(r, options, (dimensions)?buffer_tostring(dimensions):NULL);