Skip to content

Commit

Permalink
Adapt to new Broker monitoring syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
lablans committed Aug 12, 2024
1 parent 6471cad commit 2f0027c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "beamctl"
version = "0.3.0"
version = "0.4.0"
edition = "2021"
repository = "https://github.com/samply/beamctl"
documentation = "https://github.com/samply/beamctl"
Expand Down
7 changes: 5 additions & 2 deletions src/proxy_health.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::icinga::IcingaCode;

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProxyStatus {
last_active: SystemTime
last_disconnect: Option<SystemTime>,
}

pub async fn query_proxy_health(proxy_name: &str, api_key: &str, broker_url: &Url) -> Result<IcingaCode> {
Expand All @@ -29,7 +29,10 @@ pub async fn query_proxy_health(proxy_name: &str, api_key: &str, broker_url: &Ur
let Ok(status) = res.json::<ProxyStatus>().await else {
return Err(anyhow!("Got status 503 from broker without a proxy status!"));
};
let last_report_dur = status.last_active.elapsed().unwrap();
let last_report_dur = status.last_disconnect
.expect("This field should always exist, since we got code 503")
.elapsed()
.expect("Error: Check system time.");
let minutes = last_report_dur.as_secs() / 60;
let seconds = last_report_dur.as_secs() % 60;
println!("Beam.Proxy unavailable: last report was {minutes}m and {seconds}s ago!");
Expand Down

0 comments on commit 2f0027c

Please sign in to comment.