summaryrefslogtreecommitdiffstats
path: root/aclk/schema-wrappers/alarm_stream.h
blob: e0bf31ce6e682231d578ce3bd9cd31d979178cd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef ACLK_SCHEMA_WRAPPER_ALARM_STREAM_H
#define ACLK_SCHEMA_WRAPPER_ALARM_STREAM_H

#include <stdlib.h>

#include "database/rrd.h"

#ifdef __cplusplus
extern "C" {
#endif

struct start_alarm_streaming {
    char *node_id;
    bool resets;
};

struct start_alarm_streaming parse_start_alarm_streaming(const char *data, size_t len);

enum aclk_alarm_status {
    ALARM_STATUS_NULL = 0,
    ALARM_STATUS_UNKNOWN = 1,
    ALARM_STATUS_REMOVED = 2,
    ALARM_STATUS_NOT_A_NUMBER = 3,
    ALARM_STATUS_CLEAR = 4,
    ALARM_STATUS_WARNING = 5,
    ALARM_STATUS_CRITICAL = 6
};

struct alarm_log_entry {
    char *node_id;
    char *claim_id;

    char *chart;
    char *name;
    char *family;

    uint64_t batch_id;
    uint64_t sequence_id;
    uint64_t when;

    char *config_hash;

    int32_t utc_offset;
    char *timezone;

    char *exec_path;
    char *conf_source;
    char *command;

    uint32_t duration;
    uint32_t non_clear_duration;

    enum aclk_alarm_status status;
    enum aclk_alarm_status old_status;
    uint64_t delay;
    uint64_t delay_up_to_timestamp;

    uint64_t last_repeat;
    int silenced;

    char *value_string;
    char *old_value_string;

    double value;
    double old_value;

    // updated alarm entry, when the status of the alarm has been updated by a later entry
    int updated;

    // rendered_info 
    char *rendered_info;

    char *chart_context;

    uint64_t event_id;
    char *transition_id;  
};

struct send_alarm_checkpoint {
    char *node_id;
    char *claim_id;
};

struct alarm_checkpoint {
    char *node_id;
    char *claim_id;
    char *checksum;
};

struct send_alarm_snapshot {
    char *node_id;
    char *claim_id;
    char *snapshot_uuid;
};

struct alarm_snapshot {
    char *node_id;
    char *claim_id;
    char *snapshot_uuid;
    uint32_t chunks;
    uint32_t chunk;
};

typedef void* alarm_snapshot_proto_ptr_t;

void destroy_alarm_log_entry(struct alarm_log_entry *entry);

char *generate_alarm_log_entry(size_t *len, struct alarm_log_entry *data);

struct send_alarm_snapshot *parse_send_alarm_snapshot(const char *data, size_t len);
void destroy_send_alarm_snapshot(struct send_alarm_snapshot *ptr);

struct send_alarm_checkpoint parse_send_alarm_checkpoint(const char *data, size_t len);
char *generate_alarm_checkpoint(size_t *len, struct alarm_checkpoint *data);

alarm_snapshot_proto_ptr_t generate_alarm_snapshot_proto(struct alarm_snapshot *data);
void add_alarm_log_entry2snapshot(alarm_snapshot_proto_ptr_t snapshot, struct alarm_log_entry *data);
char *generate_alarm_snapshot_bin(size_t *len, alarm_snapshot_proto_ptr_t snapshot);

#ifdef __cplusplus
}
#endif

#endif /* ACLK_SCHEMA_WRAPPER_ALARM_STREAM_H */