mirror of
https://github.com/netdata/netdata.git
synced 2025-04-25 13:33:48 +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
93 lines
3.3 KiB
C
93 lines
3.3 KiB
C
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
#ifndef NETDATA_RRDFUNCTIONS_H
|
|
#define NETDATA_RRDFUNCTIONS_H 1
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
#include "../libnetdata/libnetdata.h"
|
|
|
|
#define RRDFUNCTIONS_PRIORITY_DEFAULT 100
|
|
|
|
#define RRDFUNCTIONS_TIMEOUT_EXTENSION_UT (1 * USEC_PER_SEC)
|
|
|
|
typedef void (*rrd_function_result_callback_t)(BUFFER *wb, int code, void *result_cb_data);
|
|
typedef bool (*rrd_function_is_cancelled_cb_t)(void *is_cancelled_cb_data);
|
|
typedef void (*rrd_function_cancel_cb_t)(void *data);
|
|
typedef void (*rrd_function_register_canceller_cb_t)(void *register_cancel_cb_data, rrd_function_cancel_cb_t cancel_cb, void *cancel_cb_data);
|
|
typedef void (*rrd_function_progress_cb_t)(void *data, size_t done, size_t all);
|
|
typedef void (*rrd_function_progresser_cb_t)(void *data);
|
|
typedef void (*rrd_function_register_progresser_cb_t)(void *register_progresser_cb_data, rrd_function_progresser_cb_t progresser_cb, void *progresser_cb_data);
|
|
|
|
struct rrd_function_execute {
|
|
uuid_t *transaction;
|
|
const char *function;
|
|
BUFFER *payload;
|
|
const char *source;
|
|
|
|
usec_t *stop_monotonic_ut;
|
|
|
|
struct {
|
|
BUFFER *wb; // the response should be written here
|
|
rrd_function_result_callback_t cb;
|
|
void *data;
|
|
} result;
|
|
|
|
struct {
|
|
rrd_function_progress_cb_t cb;
|
|
void *data;
|
|
} progress;
|
|
|
|
struct {
|
|
rrd_function_is_cancelled_cb_t cb;
|
|
void *data;
|
|
} is_cancelled;
|
|
|
|
struct {
|
|
rrd_function_register_canceller_cb_t cb;
|
|
void *data;
|
|
} register_canceller;
|
|
|
|
struct {
|
|
rrd_function_register_progresser_cb_t cb;
|
|
void *data;
|
|
} register_progresser;
|
|
};
|
|
|
|
typedef int (*rrd_function_execute_cb_t)(struct rrd_function_execute *rfe, void *data);
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
#include "rrd.h"
|
|
|
|
void rrd_functions_host_init(RRDHOST *host);
|
|
void rrd_functions_host_destroy(RRDHOST *host);
|
|
|
|
// add a function, to be run from the collector
|
|
void rrd_function_add(RRDHOST *host, RRDSET *st, const char *name, int timeout, int priority, const char *help, const char *tags,
|
|
HTTP_ACCESS access, bool sync, rrd_function_execute_cb_t execute_cb,
|
|
void *execute_cb_data);
|
|
|
|
void rrd_function_del(RRDHOST *host, RRDSET *st, const char *name);
|
|
|
|
// call a function, to be run from anywhere
|
|
int rrd_function_run(RRDHOST *host, BUFFER *result_wb, int timeout_s, HTTP_ACCESS access, const char *cmd,
|
|
bool wait, const char *transaction,
|
|
rrd_function_result_callback_t result_cb, void *result_cb_data,
|
|
rrd_function_progress_cb_t progress_cb, void *progress_cb_data,
|
|
rrd_function_is_cancelled_cb_t is_cancelled_cb, void *is_cancelled_cb_data,
|
|
BUFFER *payload, const char *source);
|
|
|
|
int rrd_call_function_error(BUFFER *wb, const char *msg, int code);
|
|
|
|
bool rrd_function_available(RRDHOST *host, const char *function);
|
|
|
|
bool rrd_function_has_this_original_result_callback(uuid_t *transaction, rrd_function_result_callback_t cb);
|
|
|
|
#include "rrdfunctions-inline.h"
|
|
#include "rrdfunctions-inflight.h"
|
|
#include "rrdfunctions-exporters.h"
|
|
#include "rrdfunctions-streaming.h"
|
|
#include "rrdfunctions-progress.h"
|
|
|
|
#endif // NETDATA_RRDFUNCTIONS_H
|