health.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. #ifndef NETDATA_HEALTH_H
  3. #define NETDATA_HEALTH_H 1
  4. #include "daemon/common.h"
  5. extern unsigned int default_health_enabled;
  6. typedef enum __attribute__((packed)) {
  7. HEALTH_ENTRY_FLAG_PROCESSED = 0x00000001, // notifications engine has processed this
  8. HEALTH_ENTRY_FLAG_UPDATED = 0x00000002, // there is a more recent update about this transition
  9. HEALTH_ENTRY_FLAG_EXEC_RUN = 0x00000004, // notification script has been run (this is the intent, not the result)
  10. HEALTH_ENTRY_FLAG_EXEC_FAILED = 0x00000008, // notification script couldn't be run
  11. HEALTH_ENTRY_FLAG_SILENCED = 0x00000010,
  12. HEALTH_ENTRY_RUN_ONCE = 0x00000020,
  13. HEALTH_ENTRY_FLAG_EXEC_IN_PROGRESS = 0x00000040,
  14. HEALTH_ENTRY_FLAG_IS_REPEATING = 0x00000080,
  15. HEALTH_ENTRY_FLAG_SAVED = 0x10000000, // Saved to SQL
  16. HEALTH_ENTRY_FLAG_ACLK_QUEUED = 0x20000000, // Sent to Netdata Cloud
  17. HEALTH_ENTRY_FLAG_NO_CLEAR_NOTIFICATION = 0x80000000,
  18. } HEALTH_ENTRY_FLAGS;
  19. void health_entry_flags_to_json_array(BUFFER *wb, const char *key, HEALTH_ENTRY_FLAGS flags);
  20. #ifndef HEALTH_LISTEN_PORT
  21. #define HEALTH_LISTEN_PORT 19998
  22. #endif
  23. #ifndef HEALTH_LISTEN_BACKLOG
  24. #define HEALTH_LISTEN_BACKLOG 4096
  25. #endif
  26. #ifndef HEALTH_LOG_DEFAULT_HISTORY
  27. #define HEALTH_LOG_DEFAULT_HISTORY 432000
  28. #endif
  29. #ifndef HEALTH_LOG_MINIMUM_HISTORY
  30. #define HEALTH_LOG_MINIMUM_HISTORY 86400
  31. #endif
  32. #define HEALTH_SILENCERS_MAX_FILE_LEN 10000
  33. extern char *silencers_filename;
  34. extern SIMPLE_PATTERN *conf_enabled_alarms;
  35. extern DICTIONARY *health_rrdvars;
  36. void health_init(void);
  37. void health_reload(void);
  38. void health_aggregate_alarms(RRDHOST *host, BUFFER *wb, BUFFER* context, RRDCALC_STATUS status);
  39. void health_alarms2json(RRDHOST *host, BUFFER *wb, int all);
  40. void health_alert2json_conf(RRDHOST *host, BUFFER *wb, CONTEXTS_V2_OPTIONS all);
  41. void health_alarms_values2json(RRDHOST *host, BUFFER *wb, int all);
  42. void health_api_v1_chart_variables2json(RRDSET *st, BUFFER *buf);
  43. void health_api_v1_chart_custom_variables2json(RRDSET *st, BUFFER *buf);
  44. int health_alarm_log_open(RRDHOST *host);
  45. void health_alarm_log_save(RRDHOST *host, ALARM_ENTRY *ae);
  46. void health_alarm_log_load(RRDHOST *host);
  47. ALARM_ENTRY* health_create_alarm_entry(
  48. RRDHOST *host,
  49. uint32_t alarm_id,
  50. uint32_t alarm_event_id,
  51. const uuid_t config_hash_id,
  52. time_t when,
  53. STRING *name,
  54. STRING *chart,
  55. STRING *chart_context,
  56. STRING *chart_id,
  57. STRING *classification,
  58. STRING *component,
  59. STRING *type,
  60. STRING *exec,
  61. STRING *recipient,
  62. time_t duration,
  63. NETDATA_DOUBLE old_value,
  64. NETDATA_DOUBLE new_value,
  65. RRDCALC_STATUS old_status,
  66. RRDCALC_STATUS new_status,
  67. STRING *source,
  68. STRING *units,
  69. STRING *summary,
  70. STRING *info,
  71. int delay,
  72. HEALTH_ENTRY_FLAGS flags);
  73. void health_alarm_log_add_entry(RRDHOST *host, ALARM_ENTRY *ae);
  74. void health_readdir(RRDHOST *host, const char *user_path, const char *stock_path, const char *subpath);
  75. char *health_user_config_dir(void);
  76. char *health_stock_config_dir(void);
  77. void health_alarm_log_free(RRDHOST *host);
  78. void health_alarm_log_free_one_nochecks_nounlink(ALARM_ENTRY *ae);
  79. void *health_cmdapi_thread(void *ptr);
  80. char *health_edit_command_from_source(const char *source);
  81. void sql_refresh_hashes(void);
  82. void health_add_host_labels(void);
  83. void health_string2json(BUFFER *wb, const char *prefix, const char *label, const char *value, const char *suffix);
  84. #endif //NETDATA_HEALTH_H