plugins_d.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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_STOCK_PLUGINS_DIRECTORY_PATH 0
  19. #define PLUGINSD_KEYWORD_CHART "CHART"
  20. #define PLUGINSD_KEYWORD_DIMENSION "DIMENSION"
  21. #define PLUGINSD_KEYWORD_BEGIN "BEGIN"
  22. #define PLUGINSD_KEYWORD_END "END"
  23. #define PLUGINSD_KEYWORD_FLUSH "FLUSH"
  24. #define PLUGINSD_KEYWORD_DISABLE "DISABLE"
  25. #define PLUGINSD_KEYWORD_VARIABLE "VARIABLE"
  26. #define PLUGINSD_KEYWORD_LABEL "LABEL"
  27. #define PLUGINSD_KEYWORD_OVERWRITE "OVERWRITE"
  28. #define PLUGINSD_KEYWORD_GUID "GUID"
  29. #define PLUGINSD_KEYWORD_CONTEXT "CONTEXT"
  30. #define PLUGINSD_KEYWORD_TOMBSTONE "TOMBSTONE"
  31. #define PLUGINSD_KEYWORD_HOST "HOST"
  32. #define PLUGINSD_LINE_MAX 1024
  33. #define PLUGINSD_LINE_MAX_SSL_READ 512
  34. #define PLUGINSD_MAX_WORDS 20
  35. #define PLUGINSD_MAX_DIRECTORIES 20
  36. extern char *plugin_directories[PLUGINSD_MAX_DIRECTORIES];
  37. struct plugind {
  38. char id[CONFIG_MAX_NAME+1]; // config node id
  39. char filename[FILENAME_MAX+1]; // just the filename
  40. char fullfilename[FILENAME_MAX+1]; // with path
  41. char cmd[PLUGINSD_CMD_MAX+1]; // the command that it executes
  42. volatile pid_t pid;
  43. netdata_thread_t thread;
  44. size_t successful_collections; // the number of times we have seen
  45. // values collected from this plugin
  46. size_t serial_failures; // the number of times the plugin started
  47. // without collecting values
  48. int update_every; // the plugin default data collection frequency
  49. volatile sig_atomic_t obsolete; // do not touch this structure after setting this to 1
  50. volatile sig_atomic_t enabled; // if this is enabled or not
  51. time_t started_t;
  52. uint32_t version;
  53. struct plugind *next;
  54. };
  55. extern struct plugind *pluginsd_root;
  56. extern void *pluginsd_main(void *ptr);
  57. extern size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp, int trust_durations);
  58. extern int pluginsd_split_words(char *str, char **words, int max_words, char *recover_string, char **recover_location, int max_recover);
  59. extern int pluginsd_initialize_plugin_directories();
  60. extern int config_isspace(char c);
  61. extern int pluginsd_space(char c);
  62. #endif /* NETDATA_PLUGINS_D_H */