2020-04-17 12:11:25 +00:00
|
|
|
use anyhow::{Error};
|
2019-05-16 08:24:23 +00:00
|
|
|
|
|
|
|
use proxmox_backup::client::*;
|
|
|
|
|
2019-08-29 07:58:20 +00:00
|
|
|
async fn upload_speed() -> Result<usize, Error> {
|
2019-05-16 08:24:23 +00:00
|
|
|
|
|
|
|
let host = "localhost";
|
|
|
|
let datastore = "store2";
|
|
|
|
|
|
|
|
let username = "root@pam";
|
|
|
|
|
2020-01-25 11:18:00 +00:00
|
|
|
let options = HttpClientOptions::new()
|
|
|
|
.interactive(true)
|
|
|
|
.ticket_cache(true);
|
|
|
|
|
|
|
|
let client = HttpClient::new(host, username, options)?;
|
2019-05-16 08:24:23 +00:00
|
|
|
|
2019-07-25 11:44:01 +00:00
|
|
|
let backup_time = chrono::Utc::now();
|
|
|
|
|
2020-06-26 06:59:51 +00:00
|
|
|
let client = BackupWriter::start(client, None, datastore, "host", "speedtest", backup_time, false).await?;
|
2019-05-16 08:24:23 +00:00
|
|
|
|
2019-05-23 05:20:05 +00:00
|
|
|
println!("start upload speed test");
|
2019-08-29 07:58:20 +00:00
|
|
|
let res = client.upload_speedtest().await?;
|
2019-05-16 08:24:23 +00:00
|
|
|
|
|
|
|
Ok(res)
|
|
|
|
}
|
|
|
|
|
2020-01-20 11:52:22 +00:00
|
|
|
fn main() {
|
|
|
|
match proxmox_backup::tools::runtime::main(upload_speed()) {
|
2019-08-29 07:58:20 +00:00
|
|
|
Ok(mbs) => {
|
|
|
|
println!("average upload speed: {} MB/s", mbs);
|
|
|
|
}
|
|
|
|
Err(err) => {
|
|
|
|
eprintln!("ERROR: {}", err);
|
2019-05-16 08:24:23 +00:00
|
|
|
}
|
2019-08-29 07:58:20 +00:00
|
|
|
}
|
2019-05-16 08:24:23 +00:00
|
|
|
}
|