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