plugins_d.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 NETDATA_PLUGIN_HOOK_PLUGINSD \
  6. { \
  7. .name = "PLUGINSD", \
  8. .config_section = NULL, \
  9. .config_name = NULL, \
  10. .enabled = 1, \
  11. .thread = NULL, \
  12. .init_routine = NULL, \
  13. .start_routine = pluginsd_main \
  14. },
  15. #define PLUGINSD_FILE_SUFFIX ".plugin"
  16. #define PLUGINSD_FILE_SUFFIX_LEN strlen(PLUGINSD_FILE_SUFFIX)
  17. #define PLUGINSD_CMD_MAX (FILENAME_MAX*2)
  18. #define PLUGINSD_KEYWORD_CHART "CHART"
  19. #define PLUGINSD_KEYWORD_DIMENSION "DIMENSION"
  20. #define PLUGINSD_KEYWORD_BEGIN "BEGIN"
  21. #define PLUGINSD_KEYWORD_END "END"
  22. #define PLUGINSD_KEYWORD_FLUSH "FLUSH"
  23. #define PLUGINSD_KEYWORD_DISABLE "DISABLE"
  24. #define PLUGINSD_KEYWORD_VARIABLE "VARIABLE"
  25. #define PLUGINSD_LINE_MAX 1024
  26. #define PLUGINSD_MAX_WORDS 20
  27. #define PLUGINSD_MAX_DIRECTORIES 20
  28. extern char *plugin_directories[PLUGINSD_MAX_DIRECTORIES];
  29. struct plugind {
  30. char id[CONFIG_MAX_NAME+1]; // config node id
  31. char filename[FILENAME_MAX+1]; // just the filename
  32. char fullfilename[FILENAME_MAX+1]; // with path
  33. char cmd[PLUGINSD_CMD_MAX+1]; // the command that it executes
  34. volatile pid_t pid;
  35. netdata_thread_t thread;
  36. size_t successful_collections; // the number of times we have seen
  37. // values collected from this plugin
  38. size_t serial_failures; // the number of times the plugin started
  39. // without collecting values
  40. int update_every; // the plugin default data collection frequency
  41. volatile sig_atomic_t obsolete; // do not touch this structure after setting this to 1
  42. volatile sig_atomic_t enabled; // if this is enabled or not
  43. time_t started_t;
  44. struct plugind *next;
  45. };
  46. extern struct plugind *pluginsd_root;
  47. extern void *pluginsd_main(void *ptr);
  48. extern size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp, int trust_durations);
  49. extern int pluginsd_split_words(char *str, char **words, int max_words);
  50. extern int quoted_strings_splitter(char *str, char **words, int max_words, int (*custom_isspace)(char));
  51. extern int config_isspace(char c);
  52. #endif /* NETDATA_PLUGINS_D_H */