fix gathering io stats for zpools
if a datastore or root is not used directly on the pool dir (e.g. the installer creates 2 sub datasets ROOT/pbs-1), info in /proc/self/mountinfo returns not the pool, but the path to the dataset, which has no iostats itself in /proc/spl/kstat/zfs/ but only the pool itself so instead of not gathering data at all, gather the info from the underlying pool instead. if one has multiple datastores on the same pool those rrd stats will be the same for all those datastores now (instead of empty) similar to 'normal' directories Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
318b310638
commit
368f4c5416
@ -41,6 +41,7 @@ use proxmox_backup::tools::{
|
|||||||
disks::{
|
disks::{
|
||||||
DiskManage,
|
DiskManage,
|
||||||
zfs_pool_stats,
|
zfs_pool_stats,
|
||||||
|
get_pool_from_dataset,
|
||||||
},
|
},
|
||||||
logrotate::LogRotate,
|
logrotate::LogRotate,
|
||||||
socket::{
|
socket::{
|
||||||
@ -865,8 +866,9 @@ fn gather_disk_stats(disk_manager: Arc<DiskManage>, path: &Path, rrd_prefix: &st
|
|||||||
let mut device_stat = None;
|
let mut device_stat = None;
|
||||||
match fs_type.as_str() {
|
match fs_type.as_str() {
|
||||||
"zfs" => {
|
"zfs" => {
|
||||||
if let Some(pool) = source {
|
if let Some(source) = source {
|
||||||
match zfs_pool_stats(&pool) {
|
let pool = get_pool_from_dataset(&source).unwrap_or(&source);
|
||||||
|
match zfs_pool_stats(pool) {
|
||||||
Ok(stat) => device_stat = stat,
|
Ok(stat) => device_stat = stat,
|
||||||
Err(err) => eprintln!("zfs_pool_stats({:?}) failed - {}", pool, err),
|
Err(err) => eprintln!("zfs_pool_stats({:?}) failed - {}", pool, err),
|
||||||
}
|
}
|
||||||
|
@ -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
|
/// Returns kernel IO-stats for zfs pools
|
||||||
pub fn zfs_pool_stats(pool: &OsStr) -> Result<Option<BlockDevStat>, Error> {
|
pub fn zfs_pool_stats(pool: &OsStr) -> Result<Option<BlockDevStat>, Error> {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user