rrdcalctemplate.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. #ifndef NETDATA_RRDCALCTEMPLATE_H
  3. #define NETDATA_RRDCALCTEMPLATE_H 1
  4. #include "rrd.h"
  5. // RRDCALCTEMPLATE
  6. // these are to be applied to charts found dynamically
  7. // based on their context.
  8. struct rrdcalctemplate {
  9. uuid_t config_hash_id;
  10. STRING *name;
  11. STRING *exec;
  12. STRING *recipient;
  13. STRING *classification;
  14. STRING *component;
  15. STRING *type;
  16. STRING *context;
  17. STRING *family_match;
  18. SIMPLE_PATTERN *family_pattern;
  19. STRING *plugin_match;
  20. SIMPLE_PATTERN *plugin_pattern;
  21. STRING *module_match;
  22. SIMPLE_PATTERN *module_pattern;
  23. STRING *charts_match;
  24. SIMPLE_PATTERN *charts_pattern;
  25. STRING *source; // the source of this alarm
  26. STRING *units; // the units of the alarm
  27. STRING *info; // a short description of the alarm
  28. int update_every; // update frequency for the alarm
  29. // the red and green threshold of this alarm (to be set to the chart)
  30. NETDATA_DOUBLE green;
  31. NETDATA_DOUBLE red;
  32. // ------------------------------------------------------------------------
  33. // database lookup settings
  34. STRING *dimensions; // the chart dimensions
  35. STRING *foreach_dimension; // the group of dimensions that the lookup will be applied.
  36. SIMPLE_PATTERN *foreach_dimension_pattern; // used if and only if there is a simple pattern for the chart.
  37. RRDR_TIME_GROUPING group; // grouping method: average, max, etc.
  38. int before; // ending point in time-series
  39. int after; // starting point in time-series
  40. RRDCALC_OPTIONS options; // configuration options
  41. // ------------------------------------------------------------------------
  42. // notification delay settings
  43. int delay_up_duration; // duration to delay notifications when alarm raises
  44. int delay_down_duration; // duration to delay notifications when alarm lowers
  45. int delay_max_duration; // the absolute max delay to apply to this alarm
  46. float delay_multiplier; // multiplier for all delays when alarms switch status
  47. // ------------------------------------------------------------------------
  48. // notification repeat settings
  49. uint32_t warn_repeat_every; // interval between repeating warning notifications
  50. uint32_t crit_repeat_every; // interval between repeating critical notifications
  51. // ------------------------------------------------------------------------
  52. // Labels settings
  53. STRING *host_labels; // the label read from an alarm file
  54. SIMPLE_PATTERN *host_labels_pattern; // the simple pattern of labels
  55. STRING *chart_labels; // the chart label read from an alarm file
  56. SIMPLE_PATTERN *chart_labels_pattern; // the simple pattern of chart labels
  57. // ------------------------------------------------------------------------
  58. // expressions related to the alarm
  59. EVAL_EXPRESSION *calculation;
  60. EVAL_EXPRESSION *warning;
  61. EVAL_EXPRESSION *critical;
  62. struct rrdcalctemplate *next;
  63. struct rrdcalctemplate *prev;
  64. };
  65. #define foreach_rrdcalctemplate_read(host, rt) \
  66. dfe_start_read((host)->rrdcalctemplate_root_index, rt)
  67. #define foreach_rrdcalctemplate_done(rt) \
  68. dfe_done(rt)
  69. #define rrdcalctemplate_name(rt) string2str((rt)->name)
  70. #define rrdcalctemplate_exec(rt) string2str((rt)->exec)
  71. #define rrdcalctemplate_recipient(rt) string2str((rt)->recipient)
  72. #define rrdcalctemplate_classification(rt) string2str((rt)->classification)
  73. #define rrdcalctemplate_component(rt) string2str((rt)->component)
  74. #define rrdcalctemplate_type(rt) string2str((rt)->type)
  75. #define rrdcalctemplate_family_match(rt) string2str((rt)->family_match)
  76. #define rrdcalctemplate_plugin_match(rt) string2str((rt)->plugin_match)
  77. #define rrdcalctemplate_module_match(rt) string2str((rt)->module_match)
  78. #define rrdcalctemplate_charts_match(rt) string2str((rt)->charts_match)
  79. #define rrdcalctemplate_units(rt) string2str((rt)->units)
  80. #define rrdcalctemplate_info(rt) string2str((rt)->info)
  81. #define rrdcalctemplate_source(rt) string2str((rt)->source)
  82. #define rrdcalctemplate_dimensions(rt) string2str((rt)->dimensions)
  83. #define rrdcalctemplate_foreachdim(rt) string2str((rt)->foreach_dimension)
  84. #define rrdcalctemplate_host_labels(rt) string2str((rt)->host_labels)
  85. #define rrdcalctemplate_chart_labels(rt) string2str((rt)->chart_labels)
  86. #define RRDCALCTEMPLATE_HAS_DB_LOOKUP(rt) ((rt)->after)
  87. void rrdcalctemplate_link_matching_templates_to_rrdset(RRDSET *st);
  88. void rrdcalctemplate_free_unused_rrdcalctemplate_loaded_from_config(RRDCALCTEMPLATE *rt);
  89. void rrdcalctemplate_delete_all(RRDHOST *host);
  90. void rrdcalctemplate_add_from_config(RRDHOST *host, RRDCALCTEMPLATE *rt);
  91. void rrdcalctemplate_check_conditions_and_link(RRDCALCTEMPLATE *rt, RRDSET *st, RRDHOST *host);
  92. bool rrdcalctemplate_check_rrdset_conditions(RRDCALCTEMPLATE *rt, RRDSET *st, RRDHOST *host);
  93. void rrdcalctemplate_check_rrddim_conditions_and_link(RRDCALCTEMPLATE *rt, RRDSET *st, RRDDIM *rd, RRDHOST *host);
  94. void rrdcalctemplate_index_init(RRDHOST *host);
  95. void rrdcalctemplate_index_destroy(RRDHOST *host);
  96. #endif //NETDATA_RRDCALCTEMPLATE_H