mirror of
https://github.com/moghtech/komodo.git
synced 2026-03-11 17:44:19 -05:00
uniform alert ts
This commit is contained in:
@@ -1,17 +1,14 @@
|
||||
use monitor_types::{
|
||||
entities::{
|
||||
alert::{Alert, AlertData, AlertDataVariant},
|
||||
deployment::Deployment,
|
||||
server::stats::SeverityLevel,
|
||||
update::ResourceTarget,
|
||||
},
|
||||
monitor_timestamp,
|
||||
use monitor_types::entities::{
|
||||
alert::{Alert, AlertData, AlertDataVariant},
|
||||
deployment::Deployment,
|
||||
server::stats::SeverityLevel,
|
||||
update::ResourceTarget,
|
||||
};
|
||||
|
||||
use crate::{helpers::resource::StateResource, state::State};
|
||||
|
||||
impl State {
|
||||
pub async fn alert_deployments(&self) {
|
||||
pub async fn alert_deployments(&self, ts: i64) {
|
||||
let mut alerts = Vec::<Alert>::new();
|
||||
for v in self.deployment_status_cache.get_list().await {
|
||||
if v.prev.is_none() {
|
||||
@@ -34,7 +31,6 @@ impl State {
|
||||
from: prev,
|
||||
to: v.curr.state,
|
||||
};
|
||||
let ts = monitor_timestamp();
|
||||
let alert = Alert {
|
||||
id: Default::default(),
|
||||
level: SeverityLevel::Warning,
|
||||
|
||||
@@ -5,7 +5,7 @@ use crate::state::State;
|
||||
|
||||
impl State {
|
||||
// called after cache update
|
||||
pub async fn check_alerts(&self) {
|
||||
tokio::join!(self.alert_servers(), self.alert_deployments());
|
||||
pub async fn check_alerts(&self, ts: i64) {
|
||||
tokio::join!(self.alert_servers(ts), self.alert_deployments(ts));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ type OpenDiskAlertMap = OpenAlertMap<PathBuf>;
|
||||
type OpenTempAlertMap = OpenAlertMap<String>;
|
||||
|
||||
impl State {
|
||||
pub async fn alert_servers(&self) {
|
||||
pub async fn alert_servers(&self, ts: i64) {
|
||||
let server_statuses = self.server_status_cache.get_list().await;
|
||||
let servers = self.get_all_servers_map().await;
|
||||
|
||||
@@ -64,7 +64,7 @@ impl State {
|
||||
// open unreachable alert
|
||||
let alert = Alert {
|
||||
id: Default::default(),
|
||||
ts: monitor_timestamp(),
|
||||
ts,
|
||||
resolved: false,
|
||||
resolved_ts: None,
|
||||
level: SeverityLevel::Critical,
|
||||
@@ -102,7 +102,7 @@ impl State {
|
||||
// open alert
|
||||
let alert = Alert {
|
||||
id: Default::default(),
|
||||
ts: monitor_timestamp(),
|
||||
ts,
|
||||
resolved: false,
|
||||
resolved_ts: None,
|
||||
level: health.cpu,
|
||||
@@ -184,7 +184,7 @@ impl State {
|
||||
// open alert
|
||||
let alert = Alert {
|
||||
id: Default::default(),
|
||||
ts: monitor_timestamp(),
|
||||
ts,
|
||||
resolved: false,
|
||||
resolved_ts: None,
|
||||
level: health.cpu,
|
||||
@@ -283,7 +283,7 @@ impl State {
|
||||
.and_then(|s| s.disk.disks.iter().find(|disk| disk.mount == *path));
|
||||
let alert = Alert {
|
||||
id: Default::default(),
|
||||
ts: monitor_timestamp(),
|
||||
ts,
|
||||
resolved: false,
|
||||
resolved_ts: None,
|
||||
level: *health,
|
||||
@@ -342,7 +342,7 @@ impl State {
|
||||
});
|
||||
let alert = Alert {
|
||||
id: Default::default(),
|
||||
ts: monitor_timestamp(),
|
||||
ts,
|
||||
resolved: false,
|
||||
resolved_ts: None,
|
||||
level: *health,
|
||||
|
||||
@@ -51,7 +51,7 @@ impl State {
|
||||
self.update_cache_for_server(&server).await;
|
||||
});
|
||||
join_all(futures).await;
|
||||
tokio::join!(self.check_alerts(), self.record_server_stats(ts));
|
||||
tokio::join!(self.check_alerts(ts), self.record_server_stats(ts));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user