0e8f270742
fixes #2
50 lines
2.3 KiB
Rust
50 lines
2.3 KiB
Rust
/********************************************************************************
|
|
* Prometheus exporter for monitoring network connectivity using icmp pings *
|
|
* *
|
|
* Copyright (C) 2019-2020 Jan Christian Grünhage *
|
|
* Copyright (C) 2020 Famedly GmbH *
|
|
* *
|
|
* 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/>. *
|
|
********************************************************************************/
|
|
use log::error;
|
|
|
|
mod config;
|
|
mod metrics;
|
|
mod ping;
|
|
use crate::config::{read_config, setup_clap, setup_fern};
|
|
use crate::metrics::start_serving_metrics;
|
|
use crate::ping::start_pinging_hosts;
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<(), ()> {
|
|
let clap = setup_clap();
|
|
setup_fern(clap.occurrences_of("v"));
|
|
let config = match read_config(clap.value_of("config").unwrap()) {
|
|
Ok(config) => config,
|
|
Err(_) => {
|
|
error!("Couldn't read config file!");
|
|
return Err(());
|
|
}
|
|
};
|
|
|
|
tokio::spawn(start_pinging_hosts(config.clone()));
|
|
match start_serving_metrics(config.clone()).await {
|
|
Ok(_) => Ok(()),
|
|
Err(error) => {
|
|
error!("Couldn't serve metrics: {}", error);
|
|
Err(())
|
|
}
|
|
}
|
|
}
|