Skip to main content

stackpatrol_core/
event.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
4#[serde(rename_all = "snake_case", tag = "kind")]
5pub enum Event {
6    Heartbeat {
7        uptime_secs: u64,
8    },
9    ServiceDown {
10        name: String,
11    },
12    ServiceUp {
13        name: String,
14    },
15    /// Disk usage crossed the warning threshold (default 10pp below `disk_high`).
16    /// Heads-up alert before things go critical. Suppressed if the value is
17    /// already in critical range — `DiskHigh` covers that case.
18    DiskWarning {
19        mount: String,
20        percent: u8,
21    },
22    DiskHigh {
23        mount: String,
24        percent: u8,
25    },
26    /// Memory usage crossed the warning threshold (default 10pp below `memory_high`).
27    MemoryWarning {
28        percent: u8,
29    },
30    MemoryHigh {
31        percent: u8,
32    },
33    /// 1-minute load crossed the warning threshold (default 75% of `load_1m_high`).
34    LoadWarning {
35        load_1m: f32,
36    },
37    LoadHigh {
38        load_1m: f32,
39    },
40    HostUnreachable,
41}
42
43#[derive(Debug, Clone, Serialize, Deserialize)]
44pub struct EventEnvelope {
45    pub server_name: String,
46    pub timestamp: i64,
47    pub event: Event,
48}