diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs index d6074c2e..3ea0f7c0 100644 --- a/src/bin/proxmox-backup-proxy.rs +++ b/src/bin/proxmox-backup-proxy.rs @@ -41,6 +41,7 @@ use proxmox_backup::tools::{ disks::{ DiskManage, zfs_pool_stats, + get_pool_from_dataset, }, logrotate::LogRotate, socket::{ @@ -865,8 +866,9 @@ fn gather_disk_stats(disk_manager: Arc, path: &Path, rrd_prefix: &st let mut device_stat = None; match fs_type.as_str() { "zfs" => { - if let Some(pool) = source { - match zfs_pool_stats(&pool) { + if let Some(source) = source { + let pool = get_pool_from_dataset(&source).unwrap_or(&source); + match zfs_pool_stats(pool) { Ok(stat) => device_stat = stat, Err(err) => eprintln!("zfs_pool_stats({:?}) failed - {}", pool, err), } diff --git a/src/tools/disks/zfs.rs b/src/tools/disks/zfs.rs index d7c3907e..e0084939 100644 --- a/src/tools/disks/zfs.rs +++ b/src/tools/disks/zfs.rs @@ -16,6 +16,17 @@ lazy_static!{ }; } +/// returns pool from dataset path of the form 'rpool/ROOT/pbs-1' +pub fn get_pool_from_dataset(dataset: &OsStr) -> Option<&OsStr> { + if let Some(dataset) = dataset.to_str() { + if let Some(idx) = dataset.find('/') { + return Some(&dataset[0..idx].as_ref()); + } + } + + None +} + /// Returns kernel IO-stats for zfs pools pub fn zfs_pool_stats(pool: &OsStr) -> Result, Error> {