mirror of
https://github.com/moghtech/komodo.git
synced 2026-04-26 03:08:42 -05:00
add temp monitoring stuff and start of builder crud
This commit is contained in:
@@ -98,7 +98,7 @@ fn default_core_port() -> u16 {
|
||||
}
|
||||
|
||||
fn default_jwt_valid_for() -> Timelength {
|
||||
Timelength::OneWeek
|
||||
Timelength::OneDay
|
||||
}
|
||||
|
||||
fn default_log_level() -> LogLevel {
|
||||
|
||||
@@ -54,24 +54,24 @@ impl State {
|
||||
Ok((server, status))
|
||||
}
|
||||
|
||||
pub async fn get_server_status(
|
||||
&self,
|
||||
server_id: &str,
|
||||
) -> anyhow::Result<ServerStatus> {
|
||||
let server = self.get_server(server_id).await?;
|
||||
if !server.config.enabled {
|
||||
return Ok(ServerStatus::Disabled);
|
||||
}
|
||||
let status = match self
|
||||
.periphery_client(&server)
|
||||
.request(requests::GetHealth {})
|
||||
.await
|
||||
{
|
||||
Ok(_) => ServerStatus::Ok,
|
||||
Err(_) => ServerStatus::NotOk,
|
||||
};
|
||||
Ok(status)
|
||||
}
|
||||
// pub async fn get_server_status(
|
||||
// &self,
|
||||
// server_id: &str,
|
||||
// ) -> anyhow::Result<ServerStatus> {
|
||||
// let server = self.get_server(server_id).await?;
|
||||
// if !server.config.enabled {
|
||||
// return Ok(ServerStatus::Disabled);
|
||||
// }
|
||||
// let status = match self
|
||||
// .periphery_client(&server)
|
||||
// .request(requests::GetHealth {})
|
||||
// .await
|
||||
// {
|
||||
// Ok(_) => ServerStatus::Ok,
|
||||
// Err(_) => ServerStatus::NotOk,
|
||||
// };
|
||||
// Ok(status)
|
||||
// }
|
||||
|
||||
pub async fn get_server_check_permissions(
|
||||
&self,
|
||||
|
||||
@@ -4,7 +4,10 @@ use futures::future::join_all;
|
||||
use monitor_types::entities::{
|
||||
deployment::{BasicContainerInfo, Deployment, DockerContainerState},
|
||||
server::{
|
||||
stats::{AllSystemStats, BasicSystemStats, CpuUsage, ServerHealth, StatsState},
|
||||
stats::{
|
||||
AllSystemStats, BasicSystemStats, CpuUsage, ServerHealth, SingleDiskUsage, StatsState,
|
||||
SystemComponent,
|
||||
},
|
||||
Server, ServerConfig, ServerStatus,
|
||||
},
|
||||
};
|
||||
@@ -272,17 +275,43 @@ fn get_server_health(server: &Server, stats: &AllSystemStats) -> ServerHealth {
|
||||
health.disk = StatsState::Warning
|
||||
}
|
||||
|
||||
for disk in &stats.disk.disks {
|
||||
let perc = 100.0 * disk.used_gb / disk.total_gb;
|
||||
if perc >= *disk_critical {
|
||||
health
|
||||
.disks
|
||||
.insert(disk.mount.clone(), StatsState::Critical);
|
||||
for SingleDiskUsage {
|
||||
mount,
|
||||
used_gb,
|
||||
total_gb,
|
||||
} in &stats.disk.disks
|
||||
{
|
||||
let perc = 100.0 * used_gb / total_gb;
|
||||
let stats_state = if perc >= *disk_critical {
|
||||
StatsState::Critical
|
||||
} else if perc >= *disk_warning {
|
||||
health.disks.insert(disk.mount.clone(), StatsState::Warning);
|
||||
StatsState::Warning
|
||||
} else {
|
||||
health.disks.insert(disk.mount.clone(), StatsState::Ok);
|
||||
}
|
||||
StatsState::Ok
|
||||
};
|
||||
health.disks.insert(mount.clone(), stats_state);
|
||||
}
|
||||
|
||||
for SystemComponent {
|
||||
label,
|
||||
temp,
|
||||
critical,
|
||||
..
|
||||
} in &stats.components
|
||||
{
|
||||
let stats_state = if let Some(critical) = critical {
|
||||
let perc = temp / critical;
|
||||
if perc >= 0.95 {
|
||||
StatsState::Critical
|
||||
} else if perc >= 0.85 {
|
||||
StatsState::Warning
|
||||
} else {
|
||||
StatsState::Ok
|
||||
}
|
||||
} else {
|
||||
StatsState::Ok
|
||||
};
|
||||
health.temps.insert(label.clone(), stats_state);
|
||||
}
|
||||
|
||||
health
|
||||
|
||||
@@ -137,4 +137,5 @@ pub struct ServerHealth {
|
||||
pub mem: StatsState,
|
||||
pub disk: StatsState,
|
||||
pub disks: HashMap<PathBuf, StatsState>,
|
||||
pub temps: HashMap<String, StatsState>,
|
||||
}
|
||||
|
||||
13
lib/types/src/requests/api/builder.rs
Normal file
13
lib/types/src/requests/api/builder.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
// use monitor_macros::derive_crud_requests;
|
||||
|
||||
// use crate::{
|
||||
// entities::{
|
||||
// builder::{Builder},
|
||||
// update::Update,
|
||||
// },
|
||||
// MongoDocument,
|
||||
// };
|
||||
|
||||
|
||||
|
||||
// derive_crud_requests!(Builder);
|
||||
@@ -13,6 +13,9 @@ pub use deployment::*;
|
||||
mod build;
|
||||
pub use build::*;
|
||||
|
||||
mod builder;
|
||||
pub use builder::*;
|
||||
|
||||
//
|
||||
|
||||
#[typeshare]
|
||||
|
||||
Reference in New Issue
Block a user