plugins_d.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. #ifndef NETDATA_PLUGINS_D_H
  3. #define NETDATA_PLUGINS_D_H 1
  4. #include "daemon/common.h"
  5. #define PLUGINSD_FILE_SUFFIX ".plugin"
  6. #define PLUGINSD_FILE_SUFFIX_LEN strlen(PLUGINSD_FILE_SUFFIX)
  7. #define PLUGINSD_CMD_MAX (FILENAME_MAX*2)
  8. #define PLUGINSD_STOCK_PLUGINS_DIRECTORY_PATH 0
  9. #define PLUGINSD_MAX_DIRECTORIES 20
  10. extern char *plugin_directories[PLUGINSD_MAX_DIRECTORIES];
  11. struct plugind {
  12. char id[CONFIG_MAX_NAME+1]; // config node id
  13. char filename[FILENAME_MAX+1]; // just the filename
  14. char fullfilename[FILENAME_MAX+1]; // with path
  15. char cmd[PLUGINSD_CMD_MAX+1]; // the command that it executes
  16. size_t successful_collections; // the number of times we have seen
  17. // values collected from this plugin
  18. size_t serial_failures; // the number of times the plugin started
  19. // without collecting values
  20. RRDHOST *host; // the host the plugin collects data for
  21. int update_every; // the plugin default data collection frequency
  22. struct {
  23. SPINLOCK spinlock;
  24. bool running; // do not touch this structure after setting this to 1
  25. bool enabled; // if this is enabled or not
  26. netdata_thread_t thread;
  27. pid_t pid;
  28. } unsafe;
  29. time_t started_t;
  30. struct plugind *prev;
  31. struct plugind *next;
  32. };
  33. extern struct plugind *pluginsd_root;
  34. size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp_plugin_input, FILE *fp_plugin_output, int trust_durations);
  35. void pluginsd_process_thread_cleanup(void *ptr);
  36. size_t pluginsd_initialize_plugin_directories();
  37. #endif /* NETDATA_PLUGINS_D_H */