Skip to main content

max / makenotwork

2.1 KB · 70 lines History Blame Raw
1 //! offline alert/recovery messages. Domain half of the Alerter split;
2 //! shared dispatch/cooldown plumbing lives in the parent module.
3
4 use tracing::instrument;
5
6 use super::{AlertCategory, AlertMeta, Alerter};
7
8 impl Alerter {
9 /// All monitored targets are unreachable, likely a network issue with PoM itself.
10 #[instrument(skip_all)]
11 pub async fn send_monitoring_offline_alert(&self, target_count: usize) {
12 let alert_key = "monitoring:self";
13 let subject = format!("[PoM] all {target_count} targets unreachable");
14 let body = format!(
15 "All {target_count} monitored targets are non-operational.\n\
16 This likely indicates a network issue with the PoM instance itself,\n\
17 not an actual outage of all targets.\n\n\
18 Instance: {}\n\
19 Time: {}\n\n\
20 - PoM",
21 self.instance_name,
22 chrono::Utc::now().to_rfc3339(),
23 );
24
25 self.fire_failure(
26 &subject,
27 &body,
28 "critical",
29 "pom-monitoring",
30 Some("self"),
31 AlertMeta {
32 key: alert_key,
33 category: AlertCategory::MonitoringOffline,
34 from: None,
35 to: None,
36 error: None,
37 },
38 )
39 .await;
40 }
41
42 /// At least one target is reachable again after a monitoring-offline event.
43 #[instrument(skip_all)]
44 pub async fn send_monitoring_recovery(&self) {
45 let alert_key = "monitoring:self";
46 let subject = "[PoM] monitoring recovered".to_string();
47 let body = format!(
48 "At least one target is reachable again.\n\
49 Instance: {}\n\
50 Time: {}\n\n\
51 - PoM",
52 self.instance_name,
53 chrono::Utc::now().to_rfc3339(),
54 );
55
56 self.fire_recovery(
57 &subject,
58 &body,
59 AlertMeta {
60 key: alert_key,
61 category: AlertCategory::MonitoringRecovery,
62 from: None,
63 to: None,
64 error: None,
65 },
66 )
67 .await;
68 }
69 }
70