start gathering stats using new rrd module
This commit is contained in:
parent
6359dc891a
commit
eaeda365e0
@ -34,6 +34,8 @@ async fn run() -> Result<(), Error> {
|
|||||||
|
|
||||||
config::update_self_signed_cert(false)?;
|
config::update_self_signed_cert(false)?;
|
||||||
|
|
||||||
|
proxmox_backup::rrd::create_rrdb_dir()?;
|
||||||
|
|
||||||
if let Err(err) = generate_auth_key() {
|
if let Err(err) = generate_auth_key() {
|
||||||
bail!("unable to generate auth key - {}", err);
|
bail!("unable to generate auth key - {}", err);
|
||||||
}
|
}
|
||||||
|
@ -108,6 +108,7 @@ async fn run() -> Result<(), Error> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
start_task_scheduler();
|
start_task_scheduler();
|
||||||
|
start_stat_generator();
|
||||||
|
|
||||||
server.await?;
|
server.await?;
|
||||||
log::info!("server shutting down, waiting for active workers to complete");
|
log::info!("server shutting down, waiting for active workers to complete");
|
||||||
@ -117,6 +118,13 @@ async fn run() -> Result<(), Error> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn start_stat_generator() {
|
||||||
|
let abort_future = server::shutdown_future();
|
||||||
|
let future = Box::pin(run_stat_generator());
|
||||||
|
let task = futures::future::select(future, abort_future);
|
||||||
|
tokio::spawn(task.map(|_| ()));
|
||||||
|
}
|
||||||
|
|
||||||
fn start_task_scheduler() {
|
fn start_task_scheduler() {
|
||||||
let abort_future = server::shutdown_future();
|
let abort_future = server::shutdown_future();
|
||||||
let future = Box::pin(run_task_scheduler());
|
let future = Box::pin(run_task_scheduler());
|
||||||
@ -579,3 +587,31 @@ async fn schedule_datastore_sync_jobs() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn run_stat_generator() {
|
||||||
|
|
||||||
|
loop {
|
||||||
|
let delay_target = Instant::now() + Duration::from_secs(10);
|
||||||
|
|
||||||
|
generate_host_stats().await;
|
||||||
|
|
||||||
|
tokio::time::delay_until(tokio::time::Instant::from_std(delay_target)).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn generate_host_stats() {
|
||||||
|
use proxmox::sys::linux::procfs::read_proc_stat;
|
||||||
|
use proxmox_backup::rrd;
|
||||||
|
|
||||||
|
match read_proc_stat() {
|
||||||
|
Ok(stat) => {
|
||||||
|
if let Err(err) = rrd::update_value("host/cpu", stat.cpu) {
|
||||||
|
eprintln!("rrd::update_value 'host/cpu' failed - {}", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
eprintln!("read_proc_stat failed - {}", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user