alarm_stream.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. #ifndef ACLK_SCHEMA_WRAPPER_ALARM_STREAM_H
  3. #define ACLK_SCHEMA_WRAPPER_ALARM_STREAM_H
  4. #include <stdlib.h>
  5. #include "database/rrd.h"
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. struct start_alarm_streaming {
  10. char *node_id;
  11. bool resets;
  12. };
  13. struct start_alarm_streaming parse_start_alarm_streaming(const char *data, size_t len);
  14. enum aclk_alarm_status {
  15. ALARM_STATUS_NULL = 0,
  16. ALARM_STATUS_UNKNOWN = 1,
  17. ALARM_STATUS_REMOVED = 2,
  18. ALARM_STATUS_NOT_A_NUMBER = 3,
  19. ALARM_STATUS_CLEAR = 4,
  20. ALARM_STATUS_WARNING = 5,
  21. ALARM_STATUS_CRITICAL = 6
  22. };
  23. struct alarm_log_entry {
  24. char *node_id;
  25. char *claim_id;
  26. char *chart;
  27. char *name;
  28. char *family;
  29. uint64_t batch_id;
  30. uint64_t sequence_id;
  31. uint64_t when;
  32. char *config_hash;
  33. int32_t utc_offset;
  34. char *timezone;
  35. char *exec_path;
  36. char *conf_source;
  37. char *command;
  38. uint32_t duration;
  39. uint32_t non_clear_duration;
  40. enum aclk_alarm_status status;
  41. enum aclk_alarm_status old_status;
  42. uint64_t delay;
  43. uint64_t delay_up_to_timestamp;
  44. uint64_t last_repeat;
  45. int silenced;
  46. char *value_string;
  47. char *old_value_string;
  48. double value;
  49. double old_value;
  50. // updated alarm entry, when the status of the alarm has been updated by a later entry
  51. int updated;
  52. // rendered_info
  53. char *rendered_info;
  54. char *chart_context;
  55. char *chart_name;
  56. uint64_t event_id;
  57. char *transition_id;
  58. char *summary;
  59. };
  60. struct send_alarm_checkpoint {
  61. char *node_id;
  62. char *claim_id;
  63. };
  64. struct alarm_checkpoint {
  65. char *node_id;
  66. char *claim_id;
  67. char *checksum;
  68. };
  69. struct send_alarm_snapshot {
  70. char *node_id;
  71. char *claim_id;
  72. char *snapshot_uuid;
  73. };
  74. struct alarm_snapshot {
  75. char *node_id;
  76. char *claim_id;
  77. char *snapshot_uuid;
  78. uint32_t chunks;
  79. uint32_t chunk;
  80. };
  81. typedef void* alarm_snapshot_proto_ptr_t;
  82. void destroy_alarm_log_entry(struct alarm_log_entry *entry);
  83. char *generate_alarm_log_entry(size_t *len, struct alarm_log_entry *data);
  84. struct send_alarm_snapshot *parse_send_alarm_snapshot(const char *data, size_t len);
  85. void destroy_send_alarm_snapshot(struct send_alarm_snapshot *ptr);
  86. struct send_alarm_checkpoint parse_send_alarm_checkpoint(const char *data, size_t len);
  87. char *generate_alarm_checkpoint(size_t *len, struct alarm_checkpoint *data);
  88. alarm_snapshot_proto_ptr_t generate_alarm_snapshot_proto(struct alarm_snapshot *data);
  89. void add_alarm_log_entry2snapshot(alarm_snapshot_proto_ptr_t snapshot, struct alarm_log_entry *data);
  90. char *generate_alarm_snapshot_bin(size_t *len, alarm_snapshot_proto_ptr_t snapshot);
  91. #ifdef __cplusplus
  92. }
  93. #endif
  94. #endif /* ACLK_SCHEMA_WRAPPER_ALARM_STREAM_H */