final fix
parent
a68b31d076
commit
ad4ce178a9
|
|
@ -14,13 +14,11 @@ use config::{pull_local_config, init_config_grub_mechanism};
|
||||||
use net::init_api_grub_mechanism;
|
use net::init_api_grub_mechanism;
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
use log::{error, info, warn};
|
use log::{error, info, warn};
|
||||||
|
use monitoring::get_metrics_from_monitoring;
|
||||||
|
|
||||||
#[tokio::main(flavor = "multi_thread")]
|
#[tokio::main(flavor = "multi_thread")]
|
||||||
async fn main() -> Result<()>{
|
async fn main() -> Result<()>{
|
||||||
// 3 coroutines
|
dotenv::dotenv().ok();
|
||||||
// 1) unix-socket coroutine (for config updating)
|
|
||||||
// 2) api coroutine
|
|
||||||
// 3) ?
|
|
||||||
setup_logger().await?;
|
setup_logger().await?;
|
||||||
let config = get_config().await;
|
let config = get_config().await;
|
||||||
// config update channel
|
// config update channel
|
||||||
|
|
@ -41,13 +39,24 @@ async fn main() -> Result<()>{
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let event_grub = tokio::spawn(async move {
|
let event_grub = tokio::spawn(async move {
|
||||||
match init_api_grub_mechanism(config, &mut rx).await {
|
if std::env::var("ENODE_MONITORING_IP").is_ok() {
|
||||||
Ok(_) => {
|
match get_metrics_from_monitoring(0, 5).await {
|
||||||
info!("Grabing task deinitialized");
|
Ok(_) => {
|
||||||
},
|
info!("Grabing (eNODE.Monitoring) task deinitialized");
|
||||||
Err(er) => {
|
},
|
||||||
error!("Grabing task returned an error : {}", er);
|
Err(er) => {
|
||||||
},
|
error!("Grabing task returned an error : {}", er);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
match init_api_grub_mechanism(config, &mut rx).await {
|
||||||
|
Ok(_) => {
|
||||||
|
info!("Grabing task deinitialized");
|
||||||
|
},
|
||||||
|
Err(er) => {
|
||||||
|
error!("Grabing task returned an error : {}", er);
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let events_handler = vec![event_config, event_grub];
|
let events_handler = vec![event_config, event_grub];
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ use tokio::task::JoinHandle;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
use integr_structs::api::v3::{MetricOutput, PrometheusMetrics};
|
use integr_structs::api::v3::{MetricOutput, PrometheusMetrics};
|
||||||
|
use log::{error, info, warn};
|
||||||
// use chrono::{Local, DateTime};
|
// use chrono::{Local, DateTime};
|
||||||
|
|
||||||
pub async fn get_metrics_from_monitoring(duration: usize, delay: usize) -> anyhow::Result<()> {
|
pub async fn get_metrics_from_monitoring(duration: usize, delay: usize) -> anyhow::Result<()> {
|
||||||
|
|
@ -149,12 +150,16 @@ impl MonitoringImporter {
|
||||||
});
|
});
|
||||||
jh_vec.push(jh);
|
jh_vec.push(jh);
|
||||||
}
|
}
|
||||||
let mut vals = Vec::new();
|
// let mut vals = Vec::new();
|
||||||
for event in jh_vec {
|
for event in jh_vec {
|
||||||
match event.await {
|
match event.await {
|
||||||
Ok(val) => {
|
Ok(val) => {
|
||||||
if let Ok(val) = val {
|
if let Ok(val) = val {
|
||||||
vals.push(val);
|
match crate::export::Exporter::export_metrics(val).await {
|
||||||
|
Ok(bytes) => info!("Successfully transmitted {} bytes to the Prometehus exporter", bytes),
|
||||||
|
Err(er) => error!("Cannot export data to the Prometehus exporter due to : `{}`", er),
|
||||||
|
}
|
||||||
|
// vals.push(val);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(er) => println!("Fatal error on async task: {}", er),
|
Err(er) => println!("Fatal error on async task: {}", er),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue