alarm_stream.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. enum alarm_log_status_aclk {
  10. ALARM_LOG_STATUS_UNSPECIFIED = 0,
  11. ALARM_LOG_STATUS_RUNNING = 1,
  12. ALARM_LOG_STATUS_IDLE = 2
  13. };
  14. struct alarm_log_entries {
  15. int64_t first_seq_id;
  16. struct timeval first_when;
  17. int64_t last_seq_id;
  18. struct timeval last_when;
  19. };
  20. struct alarm_log_health {
  21. char *claim_id;
  22. char *node_id;
  23. int enabled;
  24. enum alarm_log_status_aclk status;
  25. struct alarm_log_entries log_entries;
  26. };
  27. struct start_alarm_streaming {
  28. char *node_id;
  29. uint64_t batch_id;
  30. uint64_t start_seq_id;
  31. };
  32. struct start_alarm_streaming parse_start_alarm_streaming(const char *data, size_t len);
  33. char *parse_send_alarm_log_health(const char *data, size_t len);
  34. char *generate_alarm_log_health(size_t *len, struct alarm_log_health *data);
  35. enum aclk_alarm_status {
  36. ALARM_STATUS_NULL = 0,
  37. ALARM_STATUS_UNKNOWN = 1,
  38. ALARM_STATUS_REMOVED = 2,
  39. ALARM_STATUS_NOT_A_NUMBER = 3,
  40. ALARM_STATUS_CLEAR = 4,
  41. ALARM_STATUS_WARNING = 5,
  42. ALARM_STATUS_CRITICAL = 6
  43. };
  44. struct alarm_log_entry {
  45. char *node_id;
  46. char *claim_id;
  47. char *chart;
  48. char *name;
  49. char *family;
  50. uint64_t batch_id;
  51. uint64_t sequence_id;
  52. uint64_t when;
  53. char *config_hash;
  54. int32_t utc_offset;
  55. char *timezone;
  56. char *exec_path;
  57. char *conf_source;
  58. char *command;
  59. uint32_t duration;
  60. uint32_t non_clear_duration;
  61. enum aclk_alarm_status status;
  62. enum aclk_alarm_status old_status;
  63. uint64_t delay;
  64. uint64_t delay_up_to_timestamp;
  65. uint64_t last_repeat;
  66. int silenced;
  67. char *value_string;
  68. char *old_value_string;
  69. double value;
  70. double old_value;
  71. // updated alarm entry, when the status of the alarm has been updated by a later entry
  72. int updated;
  73. // rendered_info
  74. char *rendered_info;
  75. };
  76. struct send_alarm_snapshot {
  77. char *node_id;
  78. char *claim_id;
  79. uint64_t snapshot_id;
  80. uint64_t sequence_id;
  81. };
  82. struct alarm_snapshot {
  83. char *node_id;
  84. char *claim_id;
  85. uint64_t snapshot_id;
  86. uint32_t chunks;
  87. uint32_t chunk;
  88. };
  89. typedef void* alarm_snapshot_proto_ptr_t;
  90. void destroy_alarm_log_entry(struct alarm_log_entry *entry);
  91. char *generate_alarm_log_entry(size_t *len, struct alarm_log_entry *data);
  92. struct send_alarm_snapshot *parse_send_alarm_snapshot(const char *data, size_t len);
  93. void destroy_send_alarm_snapshot(struct send_alarm_snapshot *ptr);
  94. alarm_snapshot_proto_ptr_t generate_alarm_snapshot_proto(struct alarm_snapshot *data);
  95. void add_alarm_log_entry2snapshot(alarm_snapshot_proto_ptr_t snapshot, struct alarm_log_entry *data);
  96. char *generate_alarm_snapshot_bin(size_t *len, alarm_snapshot_proto_ptr_t snapshot);
  97. #ifdef __cplusplus
  98. }
  99. #endif
  100. #endif /* ACLK_SCHEMA_WRAPPER_ALARM_STREAM_H */