summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xCMakeLists.txt50
-rw-r--r--Makefile.am28
-rw-r--r--collectors/cgroups.plugin/cgroup-network.c2
-rw-r--r--configure.ac12
-rw-r--r--database/rrd.h88
-rw-r--r--database/rrdcalc.c2
-rw-r--r--database/rrdcalc.h2
-rw-r--r--database/rrdcalctemplate.h2
-rw-r--r--database/rrdvar.h12
-rw-r--r--health/health.c1
-rw-r--r--health/health.d/net.conf4
-rw-r--r--health/health_config.c9
-rw-r--r--health/health_json.c1
-rw-r--r--health/health_log.c1
-rw-r--r--libnetdata/statistical/statistical.c189
-rw-r--r--libnetdata/statistical/statistical.h7
-rw-r--r--web/api/Makefile.am6
-rw-r--r--web/api/README.md65
-rw-r--r--web/api/badges/web_buffer_svg.c253
-rw-r--r--web/api/badges/web_buffer_svg.h7
-rw-r--r--web/api/exporters/Makefile.am8
-rw-r--r--web/api/exporters/README.md0
-rw-r--r--web/api/exporters/allmetrics.c113
-rw-r--r--web/api/exporters/allmetrics.h11
-rw-r--r--web/api/exporters/prometheus/Makefile.am8
-rw-r--r--web/api/exporters/prometheus/README.md3
-rw-r--r--web/api/exporters/shell/Makefile.am8
-rw-r--r--web/api/exporters/shell/README.md64
-rw-r--r--web/api/exporters/shell/allmetrics_shell.c159
-rw-r--r--web/api/exporters/shell/allmetrics_shell.h21
-rw-r--r--web/api/netdata-swagger.json (renamed from web/gui/netdata-swagger.json)4
-rw-r--r--web/api/netdata-swagger.yaml (renamed from web/gui/netdata-swagger.yaml)6
-rw-r--r--web/api/queries/Makefile.am18
-rw-r--r--web/api/queries/README.md0
-rw-r--r--web/api/queries/average/Makefile.am8
-rw-r--r--web/api/queries/average/README.md0
-rw-r--r--web/api/queries/average/average.c58
-rw-r--r--web/api/queries/average/average.h15
-rw-r--r--web/api/queries/incremental_sum/Makefile.am8
-rw-r--r--web/api/queries/incremental_sum/README.md0
-rw-r--r--web/api/queries/incremental_sum/incremental_sum.c68
-rw-r--r--web/api/queries/incremental_sum/incremental_sum.h15
-rw-r--r--web/api/queries/max/Makefile.am8
-rw-r--r--web/api/queries/max/README.md0
-rw-r--r--web/api/queries/max/max.c59
-rw-r--r--web/api/queries/max/max.h15
-rw-r--r--web/api/queries/median/Makefile.am8
-rw-r--r--web/api/queries/median/README.md0
-rw-r--r--web/api/queries/median/median.c78
-rw-r--r--web/api/queries/median/median.h15
-rw-r--r--web/api/queries/min/Makefile.am8
-rw-r--r--web/api/queries/min/README.md0
-rw-r--r--web/api/queries/min/min.c59
-rw-r--r--web/api/queries/min/min.h15
-rw-r--r--web/api/queries/query.c729
-rw-r--r--web/api/queries/query.h22
-rw-r--r--web/api/queries/rrdr.c624
-rw-r--r--web/api/queries/rrdr.h105
-rw-r--r--web/api/queries/ses/Makefile.am8
-rw-r--r--web/api/queries/ses/README.md1
-rw-r--r--web/api/queries/ses/ses.c74
-rw-r--r--web/api/queries/ses/ses.h15
-rw-r--r--web/api/queries/stddev/Makefile.am8
-rw-r--r--web/api/queries/stddev/README.md0
-rw-r--r--web/api/queries/stddev/stddev.c73
-rw-r--r--web/api/queries/stddev/stddev.h15
-rw-r--r--web/api/queries/sum/Makefile.am8
-rw-r--r--web/api/queries/sum/README.md0
-rw-r--r--web/api/queries/sum/sum.c60
-rw-r--r--web/api/queries/sum/sum.h15
-rw-r--r--web/api/rrd2json.c1546
-rw-r--r--web/api/rrd2json.h39
-rw-r--r--web/api/web_api_v1.c397
-rw-r--r--web/api/web_api_v1.h3
-rw-r--r--web/gui/Makefile.am2
-rw-r--r--web/server/web_client.c25
-rw-r--r--web/server/web_client.h3
-rw-r--r--web/server/web_client_cache.h5
-rw-r--r--web/server/web_server.h4
79 files changed, 3242 insertions, 2140 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e6e2f5fb42..0914e8480a 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -124,16 +124,15 @@ IF(LINUX)
# ${MNL_INCLUDE_DIRS}
ENDIF(LINUX)
+
# -----------------------------------------------------------------------------
# Detect libmnl
-IF(LINUX)
- pkg_check_modules(NFACCT libnetfilter_acct)
- # later we use:
- # ${NFACCT_LIBRARIES}
- # ${NFACCT_CFLAGS_OTHER}
- # ${NFACCT_INCLUDE_DIRS}
-ENDIF(LINUX)
+pkg_check_modules(NFACCT libnetfilter_acct)
+# later we use:
+# ${NFACCT_LIBRARIES}
+# ${NFACCT_CFLAGS_OTHER}
+# ${NFACCT_INCLUDE_DIRS}
# -----------------------------------------------------------------------------
@@ -370,6 +369,30 @@ set(API_PLUGIN_FILES
web/api/web_api_v1.h
web/api/badges/web_buffer_svg.c
web/api/badges/web_buffer_svg.h
+ web/api/exporters/allmetrics.c
+ web/api/exporters/allmetrics.h
+ web/api/exporters/shell/allmetrics_shell.c
+ web/api/exporters/shell/allmetrics_shell.h
+ web/api/queries/rrdr.c
+ web/api/queries/rrdr.h
+ web/api/queries/query.c
+ web/api/queries/query.h
+ web/api/queries/average/average.c
+ web/api/queries/average/average.h
+ web/api/queries/incremental_sum/incremental_sum.c
+ web/api/queries/incremental_sum/incremental_sum.h
+ web/api/queries/max/max.c
+ web/api/queries/max/max.h
+ web/api/queries/min/min.c
+ web/api/queries/min/min.h
+ web/api/queries/sum/sum.c
+ web/api/queries/sum/sum.h
+ web/api/queries/median/median.c
+ web/api/queries/median/median.h
+ web/api/queries/stddev/stddev.c
+ web/api/queries/stddev/stddev.h
+ web/api/queries/ses/ses.c
+ web/api/queries/ses/ses.h
)
set(STREAMING_PLUGIN_FILES
@@ -470,11 +493,6 @@ IF(LINUX)
SET(ENABLE_PLUGIN_CGROUP_NETWORK True)
SET(ENABLE_PLUGIN_APPS True)
- IF(IPMI_LIBRARIES)
- SET(ENABLE_PLUGIN_FREEIPMI True)
- ELSE()
- SET(ENABLE_PLUGIN_FREEIPMI False)
- ENDIF()
ELSEIF(FREEBSD)
add_executable(netdata config.h ${NETDATA_FILES} ${FREEBSD_PLUGIN_FILES})
@@ -483,7 +501,6 @@ ELSEIF(FREEBSD)
target_compile_options(netdata PUBLIC ${NETDATA_COMMON_CFLAGS})
SET(ENABLE_PLUGIN_CGROUP_NETWORK False)
SET(ENABLE_PLUGIN_APPS True)
- SET(ENABLE_PLUGIN_FREEIPMI False)
ELSEIF(MACOS)
add_executable(netdata config.h ${NETDATA_FILES} ${MACOS_PLUGIN_FILES})
@@ -492,10 +509,15 @@ ELSEIF(MACOS)
target_compile_options(netdata PUBLIC ${NETDATA_COMMON_CFLAGS})
SET(ENABLE_PLUGIN_CGROUP_NETWORK False)
SET(ENABLE_PLUGIN_APPS False)
- SET(ENABLE_PLUGIN_FREEIPMI False)
ENDIF()
+IF(IPMI_LIBRARIES)
+ SET(ENABLE_PLUGIN_FREEIPMI True)
+ELSE()
+ SET(ENABLE_PLUGIN_FREEIPMI False)
+ENDIF()
+
# -----------------------------------------------------------------------------
# apps.plugin
diff --git a/Makefile.am b/Makefile.am
index 5c8e6f444e..cbe05c5da8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -283,12 +283,36 @@ RRD_PLUGIN_FILES = \
$(NULL)
API_PLUGIN_FILES = \
+ web/api/badges/web_buffer_svg.c \
+ web/api/badges/web_buffer_svg.h \
+ web/api/exporters/allmetrics.c \
+ web/api/exporters/allmetrics.h \
+ web/api/exporters/shell/allmetrics_shell.c \
+ web/api/exporters/shell/allmetrics_shell.h \
+ web/api/queries/average/average.c \
+ web/api/queries/average/average.h \
+ web/api/queries/incremental_sum/incremental_sum.c \
+ web/api/queries/incremental_sum/incremental_sum.h \
+ web/api/queries/max/max.c \
+ web/api/queries/max/max.h \
+ web/api/queries/median/median.c \
+ web/api/queries/median/median.h \
+ web/api/queries/min/min.c \
+ web/api/queries/min/min.h \
+ web/api/queries/query.c \
+ web/api/queries/query.h \
+ web/api/queries/rrdr.c \
+ web/api/queries/rrdr.h \
+ web/api/queries/ses/ses.c \
+ web/api/queries/ses/ses.h \
+ web/api/queries/stddev/stddev.c \
+ web/api/queries/stddev/stddev.h \
+ web/api/queries/sum/sum.c \
+ web/api/queries/sum/sum.h \
web/api/rrd2json.c \
web/api/rrd2json.h \
web/api/web_api_v1.c \
web/api/web_api_v1.h \
- web/api/badges/web_buffer_svg.c \
- web/api/badges/web_buffer_svg.h \
$(NULL)
STREAMING_PLUGIN_FILES = \
diff --git a/collectors/cgroups.plugin/cgroup-network.c b/collectors/cgroups.plugin/cgroup-network.c
index 7fa7ee9608..0cf2a2633b 100644
--- a/collectors/cgroups.plugin/cgroup-network.c
+++ b/collectors/cgroups.plugin/cgroup-network.c
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-or-later
-#include "../../daemon/common.h"
+#include "libnetdata/libnetdata.h"
#ifdef HAVE_SETNS
#ifndef _GNU_SOURCE
diff --git a/configure.ac b/configure.ac
index a75f2e1f26..e0313dcd91 100644
--- a/configure.ac
+++ b/configure.ac
@@ -604,6 +604,18 @@ AC_CONFIG_FILES([
web/Makefile
web/api/Makefile
web/api/badges/Makefile
+ web/api/exporters/Makefile
+ web/api/exporters/shell/Makefile
+ web/api/exporters/prometheus/Makefile
+ web/api/queries/Makefile
+ web/api/queries/average/Makefile
+ web/api/queries/incremental_sum/Makefile
+ web/api/queries/max/Makefile
+ web/api/queries/median/Makefile
+ web/api/queries/min/Makefile
+ web/api/queries/ses/Makefile
+ web/api/queries/stddev/Makefile
+ web/api/queries/sum/Makefile
web/gui/Makefile
web/server/Makefile
web/server/single/Makefile
diff --git a/database/rrd.h b/database/rrd.h
index 57d94c4c86..19eb100cd4 100644
--- a/database/rrd.h
+++ b/database/rrd.h
@@ -15,7 +15,7 @@ typedef struct rrdcalctemplate RRDCALCTEMPLATE;
typedef struct alarm_entry ALARM_ENTRY;
#include "../daemon/common.h"
-
+#include "web/api/queries/query.h"
#include "rrdvar.h"
#include "rrdsetvar.h"
#include "rrddimvar.h"
@@ -749,28 +749,84 @@ extern void rrdset_isnot_obsolete(RRDSET *st);
#define rrdset_first_entry_t(st) ((time_t)(rrdset_last_entry_t(st) - rrdset_duration(st)))
// get the last slot updated in the round robin database
-#define rrdset_last_slot(st) ((unsigned long)(((st)->current_entry == 0) ? (st)->entries - 1 : (st)->current_entry - 1))
+#define rrdset_last_slot(st) ((size_t)(((st)->current_entry == 0) ? (st)->entries - 1 : (st)->current_entry - 1))
// get the first / oldest slot updated in the round robin database
-#define rrdset_first_slot(st) ((unsigned long)( (((st)->counter >= ((unsigned long)(st)->entries)) ? (unsigned long)( ((unsigned long)(st)->current_entry > 0) ? ((unsigned long)(st)->current_entry) : ((unsigned long)(st)->entries) ) - 1 : 0) ))
+// #define rrdset_first_slot(st) ((size_t)( (((st)->counter >= ((unsigned long)(st)->entries)) ? (unsigned long)( ((unsigned long)(st)->current_entry > 0) ? ((unsigned long)(st)->current_entry) : ((unsigned long)(st)->entries) ) - 1 : 0) ))
+
+// return the slot that has the oldest value
+
+static inline size_t rrdset_first_slot(RRDSET *st) {
+ if(st->counter >= (size_t)st->entries) {
+ // the database has been rotated at least once
+ // the oldest entry is the one that will be next
+ // overwritten by data collection
+ return (size_t)st->current_entry;
+ }
+
+ // we do not have rotated the db yet
+ // so 0 is the first entry
+ return 0;
+}
// get the slot of the round robin database, for the given timestamp (t)
// it always returns a valid slot, although may not be for the time requested if the time is outside the round robin database
-#define rrdset_time2slot(st, t) ( \
- ( (time_t)(t) >= rrdset_last_entry_t(st)) ? ( rrdset_last_slot(st) ) : \
- ( ((time_t)(t) <= rrdset_first_entry_t(st)) ? rrdset_first_slot(st) : \
- ( (rrdset_last_slot(st) >= (unsigned long)((rrdset_last_entry_t(st) - (time_t)(t)) / (unsigned long)((st)->update_every)) ) ? \
- (rrdset_last_slot(st) - (unsigned long)((rrdset_last_entry_t(st) - (time_t)(t)) / (unsigned long)((st)->update_every)) ) : \
- (rrdset_last_slot(st) - (unsigned long)((rrdset_last_entry_t(st) - (time_t)(t)) / (unsigned long)((st)->update_every)) + (unsigned long)(st)->entries ) \
- )))
+static inline size_t rrdset_time2slot(RRDSET *st, time_t t) {
+ size_t ret = 0;
+
+ if(t >= rrdset_last_entry_t(st)) {
+ // the requested time is after the last entry we have
+ ret = rrdset_last_slot(st);
+ }
+ else {
+ if(t <= rrdset_first_entry_t(st)) {
+ // the requested time is before the first entry we have
+ ret = rrdset_first_slot(st);
+ }
+ else {
+ if(rrdset_last_slot(st) >= ((rrdset_last_entry_t(st) - t) / (size_t)(st->update_every)))
+ ret = rrdset_last_slot(st) - ((rrdset_last_entry_t(st) - t) / (size_t)(st->update_every));
+ else
+ ret = rrdset_last_slot(st) - ((rrdset_last_entry_t(st) - t) / (size_t)(st->update_every)) + (unsigned long)st->entries;
+ }
+ }
+
+ if(unlikely(ret >= (size_t)st->entries)) {
+ error("INTERNAL ERROR: rrdset_time2slot() on %s returns values outside entries", st->name);
+ ret = (size_t)(st->entries - 1);
+ }
+
+ return ret;
+}
// get the timestamp of a specific slot in the round robin database
-#define rrdset_slot2time(st, slot) ( rrdset_last_entry_t(st) - \
- ((unsigned long)(st)->update_every * ( \
- ( (unsigned long)(slot) > rrdset_last_slot(st)) ? \
- ( (rrdset_last_slot(st) - (unsigned long)(slot) + (unsigned long)(st)->entries) ) : \
- ( (rrdset_last_slot(st) - (unsigned long)(slot)) )) \
- ))
+static inline time_t rrdset_slot2time(RRDSET *st, size_t slot) {
+ time_t ret;
+
+ if(slot >= (size_t)st->entries) {
+ error("INTERNAL ERROR: caller of rrdset_slot2time() gives invalid slot %zu", slot);
+ slot = (size_t)st->entries - 1;
+ }
+
+ if(slot > rrdset_last_slot(st)) {
+ ret = rrdset_last_entry_t(st) - (size_t)st->update_every * (rrdset_last_slot(st) - slot + (size_t)st->entries);
+ }
+ else {
+ ret = rrdset_last_entry_t(st) - (size_t)st->update_every;
+ }
+
+ if(unlikely(ret < rrdset_first_entry_t(st))) {
+ error("INTERNAL ERROR: rrdset_slot2time() on %s returns time too far in the past", st->name);
+ ret = rrdset_first_entry_t(st);
+ }
+
+ if(unlikely(ret > rrdset_last_entry_t(st))) {
+ error("INTERNAL ERROR: rrdset_slot2time() on %s returns time into the future", st->name);
+ ret = rrdset_last_entry_t(st);
+ }
+
+ return ret;
+}
// ----------------------------------------------------------------------------
// RRD DIMENSION functions
diff --git a/database/rrdcalc.c b/database/rrdcalc.c
index 32c244ff85..7f6a896b6f 100644
--- a/database/rrdcalc.c
+++ b/database/rrdcalc.c
@@ -363,7 +363,7 @@ inline RRDCALC *rrdcalc_create(RRDHOST *host, RRDCALCTEMPLATE *rt, const char *c
(rc->recipient)?rc->recipient:"DEFAULT",
rc->green,
rc->red,
- rc->group,
+ (int)rc->group,
rc->after,
rc->before,
rc->options,
diff --git a/database/rrdcalc.h b/database/rrdcalc.h
index 3dcaf50107..0c7cd0aa1e 100644
--- a/database/rrdcalc.h
+++ b/database/rrdcalc.h
@@ -54,7 +54,7 @@ struct rrdcalc {
// database lookup settings
char *dimensions; // the chart dimensions
- int group; // grouping method: average, max, etc.
+ RRDR_GROUPING group; // grouping method: average, max, etc.
int before; // ending point in time-series
int after; // starting point in time-series
uint32_t options; // calculation options
diff --git a/database/rrdcalctemplate.h b/database/rrdcalctemplate.h
index 5c139fbd37..2235ecaa16 100644
--- a/database/rrdcalctemplate.h
+++ b/database/rrdcalctemplate.h
@@ -35,7 +35,7 @@ struct rrdcalctemplate {
// database lookup settings
char *dimensions; // the chart dimensions
- int group; // grouping method: average, max, etc.
+ RRDR_GROUPING group; // grouping method: average, max, etc.
int before; // ending point in time-series
int after; // starting point in time-series
uint32_t options; // calculation options
diff --git a/database/rrdvar.h b/database/rrdvar.h
index 48c27cf7e6..6d1461b2aa 100644
--- a/database/rrdvar.h
+++ b/database/rrdvar.h
@@ -3,7 +3,7 @@
#ifndef NETDATA_RRDVAR_H
#define NETDATA_RRDVAR_H 1
-#include "rrd.h"
+#include "libnetdata/libnetdata.h"
extern int rrdvar_compare(void *a, void *b);
@@ -45,6 +45,12 @@ struct rrdvar {
time_t last_updated;
};
+#define RRDVAR_MAX_LENGTH 1024
+
+extern int rrdvar_fix_name(char *variable);
+
+#include "rrd.h"
+
extern RRDVAR *rrdvar_custom_host_variable_create(RRDHOST *host, const char *name);
extern void rrdvar_custom_host_variable_set(RRDHOST *host, RRDVAR *rv, calculated_number value);
extern int foreach_host_variable_callback(RRDHOST *host, int (*callback)(RRDVAR *rv, void *data), void *data);
@@ -54,10 +60,6 @@ extern int rrdvar_callback_for_all_host_variables(RRDHOST *host, int (*callback
extern calculated_number rrdvar2number(RRDVAR *rv);
-#define RRDVAR_MAX_LENGTH 1024
-
-extern int rrdvar_fix_name(char *variable);
-
extern RRDVAR *rrdvar_create_and_index(const char *scope, avl_tree_lock *tree, const char *name, RRDVAR_TYPE type, RRDVAR_OPTIONS options, void *value);
extern void rrdvar_free(RRDHOST *host, avl_tree_lock *tree, RRDVAR *rv);
diff --git a/health/health.c b/health/health.c
index 7b3b4755dc..ae0c464b1b 100644
--- a/health/health.c
+++ b/health/health.c
@@ -1,6 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-or-later
-#define NETDATA_HEALTH_INTERNALS
#include "health.h"
unsigned int default_health_enabled = 1;
diff --git a/health/health.d/net.conf b/health/health.d/net.conf
index 22a88927d0..015de79989 100644
--- a/health/health.d/net.conf
+++ b/