peshming/src/main.rs

47 lines
2.1 KiB
Rust
Raw Normal View History

2020-04-06 11:28:02 +00:00
/********************************************************************************
* Prometheus exporter for monitoring network connectivity using icmp pings *
* *
2022-07-25 07:33:06 +00:00
* Copyright (C) 2019-2022 Jan Christian Grünhage *
* Copyright (C) 2020-2021 Famedly GmbH *
2020-04-06 11:28:02 +00:00
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
********************************************************************************/
2021-04-23 12:32:26 +00:00
use anyhow::Result;
use async_anyhow_logger::catch;
2019-02-01 14:56:35 +00:00
mod cli;
2019-02-06 18:29:27 +00:00
mod config;
mod metrics;
mod ping;
use crate::{
config::{setup_app, App},
metrics::start_serving_metrics,
ping::start_pinging_hosts,
};
2019-02-01 14:56:35 +00:00
#[tokio::main]
async fn main() -> Result<()> {
let App { config, handle } = setup_app()?;
2021-04-23 12:32:26 +00:00
let ping_fut = catch(start_pinging_hosts(&config));
let serve_fut = catch(start_serving_metrics(&config, handle));
futures::pin_mut!(ping_fut);
futures::pin_mut!(serve_fut);
2019-02-01 14:56:35 +00:00
futures::future::select(ping_fut, serve_fut).await;
Ok(())
2019-02-01 14:56:35 +00:00
}