summaryrefslogtreecommitdiffstats
path: root/web/api/badges/web_buffer_svg.c
diff options
context:
space:
mode:
Diffstat (limited to 'web/api/badges/web_buffer_svg.c')
-rw-r--r--web/api/badges/web_buffer_svg.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/web/api/badges/web_buffer_svg.c b/web/api/badges/web_buffer_svg.c
index 00b4ad650..080f2240f 100644
--- a/web/api/badges/web_buffer_svg.c
+++ b/web/api/badges/web_buffer_svg.c
@@ -893,6 +893,10 @@ int web_client_api_request_v1_badge(RRDHOST *host, struct web_client *w, char *u
int group = RRDR_GROUPING_AVERAGE;
uint32_t options = 0x00000000;
+ const RRDCALC_ACQUIRED *rca = NULL;
+ RRDCALC *rc = NULL;
+ RRDSET *st = NULL;
+
while(url) {
char *value = mystrsep(&url, "&");
if(!value || !*value) continue;
@@ -957,7 +961,7 @@ int web_client_api_request_v1_badge(RRDHOST *host, struct web_client *w, char *u
int scale = (scale_str && *scale_str)?str2i(scale_str):100;
- RRDSET *st = rrdset_find(host, chart);
+ st = rrdset_find(host, chart);
if(!st) st = rrdset_find_byname(host, chart);
if(!st) {
buffer_no_cacheable(w->response.data);
@@ -967,9 +971,10 @@ int web_client_api_request_v1_badge(RRDHOST *host, struct web_client *w, char *u
}
st->last_accessed_time = now_realtime_sec();
- RRDCALC *rc = NULL;
if(alarm) {
- rc = rrdcalc_find(st, alarm);
+ rca = rrdcalc_from_rrdset_get(st, alarm);
+ rc = rrdcalc_acquired_to_rrdcalc(rca);
+
if (!rc) {
buffer_no_cacheable(w->response.data);
buffer_svg(w->response.data, "alarm not found", NAN, "", NULL, NULL, -1, scale, 0, -1, -1, NULL, NULL);
@@ -1020,19 +1025,19 @@ int web_client_api_request_v1_badge(RRDHOST *host, struct web_client *w, char *u
label = dim;
}
else
- label = st->name;
+ label = rrdset_name(st);
}
if(!units) {
if(alarm) {
if(rc->units)
- units = rc->units;
+ units = rrdcalc_units(rc);
else
units = "";
}
else if(options & RRDR_OPTION_PERCENTAGE)
units = "%";
else
- units = st->units;
+ units = rrdset_units(st);
}
debug(D_WEB_CLIENT, "%llu: API command 'badge.svg' for chart '%s', alarm '%s', dimensions '%s', after '%lld', before '%lld', points '%d', group '%d', options '0x%08x'"
@@ -1111,7 +1116,8 @@ int web_client_api_request_v1_badge(RRDHOST *host, struct web_client *w, char *u
points, after, before, group, group_options, 0, options,
NULL, &latest_timestamp,
NULL, NULL, NULL,
- &value_is_null, NULL, 0, 0);
+ &value_is_null, NULL, 0, 0,
+ QUERY_SOURCE_API_BADGE);
// if the value cannot be calculated, show empty badge
if (ret != HTTP_RESP_OK) {
@@ -1143,7 +1149,8 @@ int web_client_api_request_v1_badge(RRDHOST *host, struct web_client *w, char *u
);
}
- cleanup:
+cleanup:
+ rrdcalc_from_rrdset_release(st, rca);
buffer_free(dimensions);
return ret;
}