rrdcalctemplate.h 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. char *name;
  10. uint32_t hash_name;
  11. uuid_t config_hash_id;
  12. char *exec;
  13. char *recipient;
  14. char *classification;
  15. char *component;
  16. char *type;
  17. char *context;
  18. uint32_t hash_context;
  19. char *family_match;
  20. SIMPLE_PATTERN *family_pattern;
  21. char *plugin_match;
  22. SIMPLE_PATTERN *plugin_pattern;
  23. char *module_match;
  24. SIMPLE_PATTERN *module_pattern;
  25. char *charts_match;
  26. SIMPLE_PATTERN *charts_pattern;
  27. char *source; // the source of this alarm
  28. char *units; // the units of the alarm
  29. char *info; // a short description of the alarm
  30. int update_every; // update frequency for the alarm
  31. // the red and green threshold of this alarm (to be set to the chart)
  32. NETDATA_DOUBLE green;
  33. NETDATA_DOUBLE red;
  34. // ------------------------------------------------------------------------
  35. // database lookup settings
  36. char *dimensions; // the chart dimensions
  37. char *foreachdim; // the group of dimensions that the lookup will be applied.
  38. SIMPLE_PATTERN *spdim; // used if and only if there is a simple pattern for the chart.
  39. int foreachcounter; // the number of alarms created with foreachdim, this also works as an id of the
  40. // children
  41. RRDR_GROUPING group; // grouping method: average, max, etc.
  42. int before; // ending point in time-series
  43. int after; // starting point in time-series
  44. uint32_t options; // calculation options
  45. // ------------------------------------------------------------------------
  46. // notification delay settings
  47. int delay_up_duration; // duration to delay notifications when alarm raises
  48. int delay_down_duration; // duration to delay notifications when alarm lowers
  49. int delay_max_duration; // the absolute max delay to apply to this alarm
  50. float delay_multiplier; // multiplier for all delays when alarms switch status
  51. // ------------------------------------------------------------------------
  52. // notification repeat settings
  53. uint32_t warn_repeat_every; // interval between repeating warning notifications
  54. uint32_t crit_repeat_every; // interval between repeating critical notifications
  55. // ------------------------------------------------------------------------
  56. // Labels settings
  57. char *host_labels; // the label read from an alarm file
  58. SIMPLE_PATTERN *host_labels_pattern; // the simple pattern of labels
  59. // ------------------------------------------------------------------------
  60. // expressions related to the alarm
  61. EVAL_EXPRESSION *calculation;
  62. EVAL_EXPRESSION *warning;
  63. EVAL_EXPRESSION *critical;
  64. struct rrdcalctemplate *next;
  65. };
  66. #define RRDCALCTEMPLATE_HAS_DB_LOOKUP(rt) ((rt)->after)
  67. extern void rrdcalctemplate_link_matching(RRDSET *st);
  68. extern void rrdcalctemplate_free(RRDCALCTEMPLATE *rt);
  69. extern void rrdcalctemplate_unlink_and_free(RRDHOST *host, RRDCALCTEMPLATE *rt);
  70. extern void rrdcalctemplate_create_alarms(RRDHOST *host, RRDCALCTEMPLATE *rt, RRDSET *st);
  71. #endif //NETDATA_RRDCALCTEMPLATE_H