mirror of
https://github.com/netdata/netdata.git
synced 2025-04-23 21:10:22 +00:00

* split rrdfunctions streaming and progress * simplified internal inline functions API * split rrdfunctions inflight management * split rrd functions exporters * renames * base dyncfg structure * config pluginsd * intercept dyncfg function calls * loading and saving of dyncfg metadata and data * save metadata and payload to a single file; added code to update the plugins with jobs and saved configs * basic working unit test * added payload to functions execution * removed old dyncfg code that is not needed any more * more cleanup * cleanup sender for functions with payload * dyncfg functions are not exposed as functions * remaining work to avoid indexing the \0 terminating character in dictionary keys * added back old dyncfg plugins.d commands as noop, to allow plugins continue working * working api; working streaming; * updated plugins.d documentation * aclk and http api requests share the same header parsing logic * added source type internal * fixed crashes * added god mode for tests * fixes * fixed messages * save host machine guids to configs * cleaner manipulation of supported commands * the functions event loop for external plugins can now process dyncfg requests * unified internal and external plugins dyncfg API * Netdata serves schema requests from /etc/netdata/schema.d and /var/lib/netdata/conf.d/schema.d * cleanup and various fixes; fixed bug in previous dyncfg implementation on streaming that was sending the paylod in a way that allowed other streaming commands to be multiplexed * internals go to a separate header file * fix duplicate ACLK requests sent by aclk queue mechanism * use fstat instead of stat * working api * plugin actions renamed to create and delete; dyncfg files are removed only from user actions * prevent deadlock by using the react callback * fix for string_strndupz() * better dyncfg unittests * more tests at the unittests * properly detect dyncfg functions * hide config functions from the UI * tree response improvements * send the initial update with payload * determine tty using stdout, not stderr * changes to statuses, cleanup and the code to bring all business logic into interception * do not crash when the status is empty * functions now propagate the source of the requests to plugins * avoid warning about unused functions * in the count at items for attention, do not count the orphan entries * save source into dyncfg * make the list null terminated * fixed invalid comparison * prevent memory leak on duplicated headers; log x-forwarded-for * more unit tests * added dyncfg unittests into the default unittests * more unit tests and fixes * more unit tests and fixes * fix dictionary unittests * config functions require admin access
80 lines
2.4 KiB
C
80 lines
2.4 KiB
C
#ifndef CHECKIN_JSON_H
|
|
#define CHECKIN_JSON_H 1
|
|
|
|
#if ENABLE_JSONC
|
|
#include <json-c/json.h>
|
|
// fix an older json-c bug
|
|
// https://github.com/json-c/json-c/issues/135
|
|
#ifdef error_description
|
|
#undef error_description
|
|
#endif // error_description
|
|
#endif // ENABLE_JSONC
|
|
|
|
#include "jsmn.h"
|
|
|
|
//https://www.ibm.com/support/knowledgecenter/en/SS9H2Y_7.6.0/com.ibm.dp.doc/json_parserlimits.html
|
|
#define JSON_NAME_LEN 256
|
|
#define JSON_FULLNAME_LEN 1024
|
|
|
|
typedef enum {
|
|
JSON_OBJECT = 0,
|
|
JSON_ARRAY = 1,
|
|
JSON_STRING = 2,
|
|
JSON_NUMBER = 3,
|
|
JSON_BOOLEAN = 4,
|
|
JSON_NULL = 5,
|
|
} JSON_ENTRY_TYPE;
|
|
|
|
typedef struct json_entry {
|
|
JSON_ENTRY_TYPE type;
|
|
char name[JSON_NAME_LEN + 1];
|
|
char fullname[JSON_FULLNAME_LEN + 1];
|
|
union {
|
|
char *string; // type == JSON_STRING
|
|
NETDATA_DOUBLE number; // type == JSON_NUMBER
|
|
int boolean; // type == JSON_BOOLEAN
|
|
size_t items; // type == JSON_ARRAY
|
|
} data;
|
|
size_t pos; // the position of this item in its parent
|
|
|
|
char *original_string;
|
|
|
|
void *callback_data;
|
|
int (*callback_function)(struct json_entry *);
|
|
} JSON_ENTRY;
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// public functions
|
|
|
|
#define JSON_OK 0
|
|
#define JSON_CANNOT_DOWNLOAD 1
|
|
#define JSON_CANNOT_PARSE 2
|
|
|
|
int json_parse(char *js, void *callback_data, int (*callback_function)(JSON_ENTRY *));
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// private functions
|
|
|
|
#ifdef ENABLE_JSONC
|
|
json_object *json_tokenise(char *js);
|
|
size_t json_walk(json_object *t, void *callback_data, int (*callback_function)(struct json_entry *));
|
|
#else
|
|
jsmntok_t *json_tokenise(char *js, size_t len, size_t *count);
|
|
size_t json_walk_tree(char *js, jsmntok_t *t, void *callback_data, int (*callback_function)(struct json_entry *));
|
|
#endif
|
|
|
|
size_t json_walk_object(char *js, jsmntok_t *t, size_t nest, size_t start, JSON_ENTRY *e);
|
|
size_t json_walk_array(char *js, jsmntok_t *t, size_t nest, size_t start, JSON_ENTRY *e);
|
|
size_t json_walk_string(char *js, jsmntok_t *t, size_t start, JSON_ENTRY *e);
|
|
size_t json_walk_primitive(char *js, jsmntok_t *t, size_t start, JSON_ENTRY *e);
|
|
|
|
int json_callback_print(JSON_ENTRY *e);
|
|
|
|
static inline void cleanup_json_object_pp(struct json_object **jobj) {
|
|
if(*jobj)
|
|
json_object_put(*jobj);
|
|
}
|
|
#define CLEAN_JSON_OBJECT _cleanup_(cleanup_json_object_pp) struct json_object
|
|
|
|
#endif // CHECKIN_JSON_H
|