Compare commits
No commits in common. "ad4ce178a990c3cb252ac48b9df1b84aa45c9c3a" and "32a43f9ed80cf9c8c61b9200d4b6ca90f659742a" have entirely different histories.
ad4ce178a9
...
32a43f9ed8
|
|
@ -7,9 +7,4 @@ DB_PASSWORD = "db_user_password"
|
||||||
DB_DBNAME = "db_name"1
|
DB_DBNAME = "db_name"1
|
||||||
|
|
||||||
# Prometheus-Exporter info
|
# Prometheus-Exporter info
|
||||||
EXPORTER_URL = "http(s)://ip.ip.ip.ip:port"
|
EXPORTER_URL = "http(s)://ip.ip.ip.ip:port"
|
||||||
|
|
||||||
# eNODE.Monitoring configuration
|
|
||||||
ENODE_MONITORING_IP = "ip.ip.ip.ip"
|
|
||||||
ENODE_MONITORING_LOGIN = "admin_user_enode_monitoring" # admin user is required
|
|
||||||
ENODE_MONITORING_PASSWORD = "admin_password_enode_monitoring" # # admin password is required
|
|
||||||
|
|
@ -14,11 +14,13 @@ 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<()>{
|
||||||
dotenv::dotenv().ok();
|
// 3 coroutines
|
||||||
|
// 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
|
||||||
|
|
@ -39,24 +41,13 @@ async fn main() -> Result<()>{
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let event_grub = tokio::spawn(async move {
|
let event_grub = tokio::spawn(async move {
|
||||||
if std::env::var("ENODE_MONITORING_IP").is_ok() {
|
match init_api_grub_mechanism(config, &mut rx).await {
|
||||||
match get_metrics_from_monitoring(0, 5).await {
|
Ok(_) => {
|
||||||
Ok(_) => {
|
info!("Grabing task deinitialized");
|
||||||
info!("Grabing (eNODE.Monitoring) task deinitialized");
|
},
|
||||||
},
|
Err(er) => {
|
||||||
Err(er) => {
|
error!("Grabing task returned an error : {}", 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,7 +13,6 @@ 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<()> {
|
||||||
|
|
@ -150,16 +149,12 @@ 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 {
|
||||||
match crate::export::Exporter::export_metrics(val).await {
|
vals.push(val);
|
||||||
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