summaryrefslogtreecommitdiffstats
path: root/libnetdata
diff options
context:
space:
mode:
authorCosta Tsaousis <costa@netdata.cloud>2023-07-06 01:49:32 +0300
committerGitHub <noreply@github.com>2023-07-06 01:49:32 +0300
commitc74bf56ee2910b5c90e5be2e31128580b85b9ca8 (patch)
tree6ef495ac5821ce2c4984d87feb65d79851dd38ec /libnetdata
parentb45570d251980309e7c2d956dea8886f8aa13bdc (diff)
Code reorg and cleanup - enrichment of /api/v2 (#15294)
* claim script now accepts the same params as the kickstart * rewrote buildinfo to unify all methods * added cloud unavailable in cloud status * added all exporters * renamed httpd to h2o * rename ENABLE_COMPRESSION to ENABLE_LZ4 * rename global variable * rename ENABLE_HTTPS to ENABLE_OPENSSL * fix coverity-scan for openssl * add lz4 to coverity-scan * added all plugins and most of the features * added all plugins and most of the features * generalize bitmap code so that we can have any size of bitmaps * cleanup * fix compilation without protobuf * fix compilation with others allocators * fix bitmap * comprehensive bitmaps unit test * bitmap as macros * added developer mode * added system info to build info * cloud available/unavailable * added /api/v2/info * added units and ni to transitions * when showing instances and transitions, show only the instances that have transitions * cleanup * add missing quotes * add anchor to transitions * added more to build info * calculate retention per tier and expose it to /api/v2/info * added currently collected metrics * do not show space and retention when no numbers are available * fix impossible overflow * Add function for transitions and execute callback * In case of error, reset and try next dictionary entry * Fix error message * simpler logic to maintain retention per tier * /api/v2/alert_transitions * Handle case of recipient null Convert after and before to usec * Add classification, type and component * working /api/v2/alert_transitions * Fix query to properly handle context and alert name * cleanup * Add search with transition * accept transition in /api/v2/alert_transitions * totaly dynamic facets * fixed debug info * restructured facets * cleanup; removal of options=transitions * updated alert entries flags * method to exec * Return also exec run timestamp Temp table cleanup only when we don't execute with a transition * cleanup obsolete anchor parameter * Add sql_get_alert_configuration function * added options=config to alert_transitions * added /api/v2/alert_config * preliminary work for /api/v2/claim * initialize variables; do not expose expected retention if no disk space info is available; do not report aclk as initializing when not claimed * fix claim session key filename * put a newline into the session key file * more progress on claiming * final /api/v2/claim endpoint * after claiming, refresh our state at the output * Fix query to fetch config * Remove debug log * add configuration objects * add configuration objects - fixed * respect the NETDATA_DISABLE_CLOUD env variable * NETDATA_DISABLE_CLOUD env variable sets the default, but the config sets the final value * use a new claimed_id on every claiming * regenerate random key on claiming and wait for online status * ignore write() return value when writing a newline * dont show cloud status disabled when claimed_id is missing * added ctx to alert instances * cleanup config and transitions from /api/v2/alerts * fix unused variable * in /api/v2/alert_config show 1 config without an array * show alert values conditionally, by appending options=values * When storing host info if the key value is empty, store unknown * added options=summary to control when the alerts summary is shown * increased http_api_v2 to version 5 * claming random key file is now not world readable * added local-listeners binary that detects all the listening ports, their IPs and their command lines --------- Co-authored-by: Stelios Fragkakis <52996999+stelfrag@users.noreply.github.com>
Diffstat (limited to 'libnetdata')
-rw-r--r--libnetdata/buffer/buffer.c4
-rw-r--r--libnetdata/buffer/buffer.h4
-rw-r--r--libnetdata/config/appconfig.c4
-rw-r--r--libnetdata/libnetdata.h99
4 files changed, 88 insertions, 23 deletions
diff --git a/libnetdata/buffer/buffer.c b/libnetdata/buffer/buffer.c
index 91bc4dd602..8d80c9fe0e 100644
--- a/libnetdata/buffer/buffer.c
+++ b/libnetdata/buffer/buffer.c
@@ -315,6 +315,8 @@ void buffer_json_initialize(BUFFER *wb, const char *key_quote, const char *value
if(add_anonymous_object)
buffer_fast_strcat(wb, "{", 1);
+
+ wb->content_type = CT_APPLICATION_JSON;
}
void buffer_json_finalize(BUFFER *wb) {
@@ -503,7 +505,7 @@ int buffer_unittest(void) {
return errors;
}
-#ifdef ENABLE_HTTPD
+#ifdef ENABLE_H2O
h2o_iovec_t buffer_to_h2o_iovec(BUFFER *wb) {
h2o_iovec_t ret;
ret.base = wb->buffer;
diff --git a/libnetdata/buffer/buffer.h b/libnetdata/buffer/buffer.h
index 17a7b378c1..d5adabd42a 100644
--- a/libnetdata/buffer/buffer.h
+++ b/libnetdata/buffer/buffer.h
@@ -6,7 +6,7 @@
#include "../string/utf8.h"
#include "../libnetdata.h"
-#ifdef ENABLE_HTTPD
+#ifdef ENABLE_H2O
#include "h2o/memory.h"
#endif
@@ -133,7 +133,7 @@ void buffer_char_replace(BUFFER *wb, char from, char to);
void buffer_print_sn_flags(BUFFER *wb, SN_FLAGS flags, bool send_anomaly_bit);
-#ifdef ENABLE_HTTPD
+#ifdef ENABLE_H2O
h2o_iovec_t buffer_to_h2o_iovec(BUFFER *wb);
#endif
diff --git a/libnetdata/config/appconfig.c b/libnetdata/config/appconfig.c
index 37b8d7c7d0..adca337614 100644
--- a/libnetdata/config/appconfig.c
+++ b/libnetdata/config/appconfig.c
@@ -518,9 +518,9 @@ int appconfig_get_boolean_ondemand(struct config *root, const char *section, con
s = appconfig_get(root, section, name, s);
if(!s) return value;
- if(!strcmp(s, "yes"))
+ if(!strcmp(s, "yes") || !strcmp(s, "true") || !strcmp(s, "on"))
return CONFIG_BOOLEAN_YES;
- else if(!strcmp(s, "no"))
+ else if(!strcmp(s, "no") || !strcmp(s, "false") || !strcmp(s, "off"))
return CONFIG_BOOLEAN_NO;
else if(!strcmp(s, "auto") || !strcmp(s, "on demand"))
return CONFIG_BOOLEAN_AUTO;
diff --git a/libnetdata/libnetdata.h b/libnetdata/libnetdata.h
index 80a0026896..8d87745f22 100644
--- a/libnetdata/libnetdata.h
+++ b/libnetdata/libnetdata.h
@@ -11,6 +11,21 @@ extern "C" {
#include <config.h>
#endif
+#ifdef ENABLE_LZ4
+#define ENABLE_RRDPUSH_COMPRESSION 1
+#endif
+
+#ifdef ENABLE_OPENSSL
+#define ENABLE_HTTPS 1
+#endif
+
+#ifdef HAVE_LIBDATACHANNEL
+#define ENABLE_WEBRTC 1
+#endif
+
+#define STRINGIFY(x) #x
+#define TOSTRING(x) STRINGIFY(x)
+
#define JUDYHS_INDEX_SIZE_ESTIMATE(key_bytes) (((key_bytes) + sizeof(Word_t) - 1) / sizeof(Word_t) * 4)
#if defined(NETDATA_DEV_MODE) && !defined(NETDATA_INTERNAL_CHECKS)
@@ -592,32 +607,80 @@ char *find_and_replace(const char *src, const char *find, const char *replace, c
#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
#ifdef ENV32BIT
+
+typedef struct bitmapX {
+ uint32_t bits;
+ uint32_t data[];
+} BITMAPX;
+
typedef struct bitmap256 {
- uint32_t data[8];
+ uint32_t bits;
+ uint32_t data[256 / 32];
} BITMAP256;
-#define bitmap256_get_bit(ptr, idx) (((ptr)->data[(idx) >> 5] & (1ULL << ((idx) & 31))) != 0)
-static inline void bitmap256_set_bit(BITMAP256 *ptr, uint8_t idx, bool value) {
- uint32_t mask = 1U << (idx & 31);
- if (value)
- ptr->data[idx >> 5] |= mask;
- else
- ptr->data[idx >> 5] &= ~mask;
+typedef struct bitmap1024 {
+ uint32_t bits;
+ uint32_t data[1024 / 32];
+} BITMAP1024;
+
+static inline BITMAPX *bitmapX_create(uint32_t bits) {
+ BITMAPX *bmp = (BITMAPX *)callocz(1, sizeof(BITMAPX) + sizeof(uint32_t) * ((bits + 31) / 32));
+ uint32_t *p = (uint32_t *)&bmp->bits;
+ *p = bits;
+ return bmp;
}
-#else // 64bit
+
+#define bitmapX_get_bit(ptr, idx) ((ptr)->data[(idx) >> 5] & (1U << ((idx) & 31)))
+#define bitmapX_set_bit(ptr, idx, value) do { \
+ register uint32_t _bitmask = 1U << ((idx) & 31); \
+ if (value) \
+ (ptr)->data[(idx) >> 5] |= _bitmask; \
+ else \
+ (ptr)->data[(idx) >> 5] &= ~_bitmask; \
+} while(0)
+
+#else // 64bit version of bitmaps
+
+typedef struct bitmapX {
+ uint32_t bits;
+ uint64_t data[];
+} BITMAPX;
+
typedef struct bitmap256 {
- uint64_t data[4];
+ uint32_t bits;
+ uint64_t data[256 / 64];
} BITMAP256;
-#define bitmap256_get_bit(ptr, idx) ((ptr)->data[(idx) >> 6] & (1ULL << ((idx) & 63)))
-static inline void bitmap256_set_bit(BITMAP256 *ptr, uint8_t idx, bool value) {
- uint64_t mask = 1ULL << (idx & 63);
- if (value)
- ptr->data[idx >> 6] |= mask;
- else
- ptr->data[idx >> 6] &= ~mask;
+typedef struct bitmap1024 {
+ uint32_t bits;
+ uint64_t data[1024 / 64];
+} BITMAP1024;
+
+static inline BITMAPX *bitmapX_create(uint32_t bits) {
+ BITMAPX *bmp = (BITMAPX *)callocz(1, sizeof(BITMAPX) + sizeof(uint64_t) * ((bits + 63) / 64));
+ bmp->bits = bits;
+ return bmp;
}
-#endif // 64bit
+
+#define bitmapX_get_bit(ptr, idx) ((ptr)->data[(idx) >> 6] & (1ULL << ((idx) & 63)))
+#define bitmapX_set_bit(ptr, idx, value) do { \
+ register uint64_t _bitmask = 1ULL << ((idx) & 63); \
+ if (value) \
+ (ptr)->data[(idx) >> 6] |= _bitmask; \
+ else \
+ (ptr)->data[(idx) >> 6] &= ~_bitmask; \
+} while(0)
+
+#endif // 64bit version of bitmaps
+
+#define BITMAPX_INITIALIZER(wanted_bits) { .bits = (wanted_bits), .data = {0} }
+#define BITMAP256_INITIALIZER (BITMAP256)BITMAPX_INITIALIZER(256)
+#define BITMAP1024_INITIALIZER (BITMAP1024)BITMAPX_INITIALIZER(1024)
+#define bitmap256_get_bit(ptr, idx) bitmapX_get_bit((BITMAPX *)ptr, idx)
+#define bitmap256_set_bit(ptr, idx, value) bitmapX_set_bit((BITMAPX *)ptr, idx, value)
+#define bitmap1024_get_bit(ptr, idx) bitmapX_get_bit((BITMAPX *)ptr, idx)
+#define bitmap1024_set_bit(ptr, idx, value) bitmapX_set_bit((BITMAPX *)ptr, idx, value)
+
#define COMPRESSION_MAX_MSG_SIZE 0x4000
#define PLUGINSD_LINE_MAX (COMPRESSION_MAX_MSG_SIZE - 1024)