alert enum and send alert logic

This commit is contained in:
mbecker20
2023-07-16 05:51:45 +00:00
parent 7694e3f565
commit 6c7dda2b67
6 changed files with 122 additions and 2 deletions

View File

@@ -0,0 +1,50 @@
use derive_variants::EnumVariants;
use serde::{Deserialize, Serialize};
use typeshare::typeshare;
use super::{server::stats::{StatsState, SystemProcess}, deployment::DockerContainerState};
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, EnumVariants)]
#[variant_derive(Serialize, Deserialize, Debug, Clone, Copy)]
#[serde(tag = "type", content = "data")]
pub enum Alert {
ServerUnreachable {
id: String,
name: String,
region: Option<String>,
},
ServerCpu {
id: String,
name: String,
region: Option<String>,
state: StatsState,
percentage: f64,
top_procs: Vec<SystemProcess>,
},
ServerMem {
id: String,
name: String,
region: String,
state: StatsState,
used: f64,
total: f64,
top_procs: Vec<SystemProcess>,
},
ServerDisk {
id: String,
name: String,
region: String,
state: StatsState,
path: String,
used: f64,
total: f64,
},
ContainerStateChange {
id: String,
name: String,
server: String, // server name
from: DockerContainerState,
to: DockerContainerState,
}
}

View File

@@ -8,6 +8,7 @@ use typeshare::typeshare;
use crate::optional_string;
pub mod alert;
pub mod alerter;
pub mod build;
pub mod builder;