diff options
author | Costa Tsaousis <costa@netdata.cloud> | 2023-08-03 15:42:11 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-03 15:42:11 +0300 |
commit | ce75313de06ee1e8aa5a59d57625ca25d467f0f8 (patch) | |
tree | d9ea59af0ace84b34f627b2f72d67a39d5bcff4d /collectors/plugins.d | |
parent | a833f6674f09011b2e0134f045c4c8a39be8de75 (diff) |
systemd-journal plugin (#15363)
Diffstat (limited to 'collectors/plugins.d')
-rw-r--r-- | collectors/plugins.d/plugins_d.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/collectors/plugins.d/plugins_d.h b/collectors/plugins.d/plugins_d.h index 1e183c2dc8..4988b50719 100644 --- a/collectors/plugins.d/plugins_d.h +++ b/collectors/plugins.d/plugins_d.h @@ -99,8 +99,6 @@ void pluginsd_process_thread_cleanup(void *ptr); size_t pluginsd_initialize_plugin_directories(); - - #define pluginsd_function_result_begin_to_buffer(wb, transaction, code, content_type, expires) \ buffer_sprintf(wb \ , PLUGINSD_KEYWORD_FUNCTION_RESULT_BEGIN " \"%s\" %d \"%s\" %ld\n" \ @@ -125,4 +123,13 @@ size_t pluginsd_initialize_plugin_directories(); #define pluginsd_function_result_end_to_stdout() \ fprintf(stdout, "\n" PLUGINSD_KEYWORD_FUNCTION_RESULT_END "\n") +static inline void pluginsd_function_json_error(const char *transaction, int code, const char *msg) { + char buffer[PLUGINSD_LINE_MAX + 1]; + json_escape_string(buffer, msg, PLUGINSD_LINE_MAX); + + pluginsd_function_result_begin_to_stdout(transaction, code, "application/json", now_realtime_sec()); + fprintf(stdout, "{\"status\":%d,\"error_message\":\"%s\"}", code, buffer); + pluginsd_function_result_end_to_stdout(); +} + #endif /* NETDATA_PLUGINS_D_H */ |