Compare commits
2 Commits
32a43f9ed8
...
ad4ce178a9
| Author | SHA1 | Date |
|---|---|---|
|
|
ad4ce178a9 | |
|
|
a68b31d076 |
|
|
@ -7,4 +7,9 @@ DB_PASSWORD = "db_user_password"
|
|||
DB_DBNAME = "db_name"1
|
||||
|
||||
# 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,13 +14,11 @@ use config::{pull_local_config, init_config_grub_mechanism};
|
|||
use net::init_api_grub_mechanism;
|
||||
use tokio::sync::mpsc;
|
||||
use log::{error, info, warn};
|
||||
use monitoring::get_metrics_from_monitoring;
|
||||
|
||||
#[tokio::main(flavor = "multi_thread")]
|
||||
async fn main() -> Result<()>{
|
||||
// 3 coroutines
|
||||
// 1) unix-socket coroutine (for config updating)
|
||||
// 2) api coroutine
|
||||
// 3) ?
|
||||
dotenv::dotenv().ok();
|
||||
setup_logger().await?;
|
||||
let config = get_config().await;
|
||||
// config update channel
|
||||
|
|
@ -41,13 +39,24 @@ async fn main() -> Result<()>{
|
|||
}
|
||||
});
|
||||
let event_grub = tokio::spawn(async move {
|
||||
match init_api_grub_mechanism(config, &mut rx).await {
|
||||
Ok(_) => {
|
||||
info!("Grabing task deinitialized");
|
||||
},
|
||||
Err(er) => {
|
||||
error!("Grabing task returned an error : {}", er);
|
||||
},
|
||||
if std::env::var("ENODE_MONITORING_IP").is_ok() {
|
||||
match get_metrics_from_monitoring(0, 5).await {
|
||||
Ok(_) => {
|
||||
info!("Grabing (eNODE.Monitoring) task deinitialized");
|
||||
},
|
||||
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];
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ use tokio::task::JoinHandle;
|
|||
use std::pin::Pin;
|
||||
use std::future::Future;
|
||||
use integr_structs::api::v3::{MetricOutput, PrometheusMetrics};
|
||||
use log::{error, info, warn};
|
||||
// use chrono::{Local, DateTime};
|
||||
|
||||
pub async fn get_metrics_from_monitoring(duration: usize, delay: usize) -> anyhow::Result<()> {
|
||||
|
|
@ -149,12 +150,16 @@ impl MonitoringImporter {
|
|||
});
|
||||
jh_vec.push(jh);
|
||||
}
|
||||
let mut vals = Vec::new();
|
||||
// let mut vals = Vec::new();
|
||||
for event in jh_vec {
|
||||
match event.await {
|
||||
Ok(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),
|
||||
|
|
|
|||
Loading…
Reference in New Issue