rrdcalctemplate.h 3.2 KB

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