rrd stats: improve io delay stats

This commit is contained in:
Dietmar Maurer 2020-05-28 19:11:37 +02:00
parent d80d1f9a2b
commit c94e1f655e
7 changed files with 48 additions and 44 deletions

View File

@ -875,8 +875,9 @@ fn get_rrd_stats(
&rrd_dir, &rrd_dir,
&[ &[
"total", "used", "total", "used",
"read_ios", "read_bytes", "read_ticks", "read_ios", "read_bytes",
"write_ios", "write_bytes", "write_ticks", "write_ios", "write_bytes",
"io_ticks",
], ],
timeframe, timeframe,
cf, cf,

View File

@ -36,8 +36,9 @@ fn get_node_stats(
"netin", "netout", "netin", "netout",
"loadavg", "loadavg",
"total", "used", "total", "used",
"read_ios", "read_bytes", "read_ticks", "read_ios", "read_bytes",
"write_ios", "write_bytes", "write_ticks", "write_ios", "write_bytes",
"io_ticks",
], ],
timeframe, timeframe,
cf, cf,

View File

@ -741,15 +741,14 @@ fn gather_disk_stats(disk_manager: Arc<DiskManage>, path: &Path, rrd_prefix: &st
rrd_update_derive(&rrd_key, stat.read_ios as f64); rrd_update_derive(&rrd_key, stat.read_ios as f64);
let rrd_key = format!("{}/read_bytes", rrd_prefix); let rrd_key = format!("{}/read_bytes", rrd_prefix);
rrd_update_derive(&rrd_key, (stat.read_sectors*512) as f64); rrd_update_derive(&rrd_key, (stat.read_sectors*512) as f64);
let rrd_key = format!("{}/read_ticks", rrd_prefix);
rrd_update_derive(&rrd_key, (stat.read_ticks as f64)/1000.0);
let rrd_key = format!("{}/write_ios", rrd_prefix); let rrd_key = format!("{}/write_ios", rrd_prefix);
rrd_update_derive(&rrd_key, stat.write_ios as f64); rrd_update_derive(&rrd_key, stat.write_ios as f64);
let rrd_key = format!("{}/write_bytes", rrd_prefix); let rrd_key = format!("{}/write_bytes", rrd_prefix);
rrd_update_derive(&rrd_key, (stat.write_sectors*512) as f64); rrd_update_derive(&rrd_key, (stat.write_sectors*512) as f64);
let rrd_key = format!("{}/write_ticks", rrd_prefix);
rrd_update_derive(&rrd_key, (stat.write_ticks as f64)/1000.0); let rrd_key = format!("{}/io_ticks", rrd_prefix);
rrd_update_derive(&rrd_key, (stat.io_ticks as f64)/1000.0);
} }
} }
} }

View File

@ -427,6 +427,8 @@ impl Disk {
} }
/// Read block device stats /// Read block device stats
///
/// see https://www.kernel.org/doc/Documentation/block/stat.txt
pub fn read_stat(&self) -> std::io::Result<Option<BlockDevStat>> { pub fn read_stat(&self) -> std::io::Result<Option<BlockDevStat>> {
if let Some(stat) = self.read_sys(Path::new("stat"))? { if let Some(stat) = self.read_sys(Path::new("stat"))? {
let stat = unsafe { std::str::from_utf8_unchecked(&stat) }; let stat = unsafe { std::str::from_utf8_unchecked(&stat) };
@ -434,17 +436,14 @@ impl Disk {
u64::from_str_radix(s, 10).unwrap_or(0) u64::from_str_radix(s, 10).unwrap_or(0)
}).collect(); }).collect();
if stat.len() < 8 { return Ok(None); } if stat.len() < 15 { return Ok(None); }
return Ok(Some(BlockDevStat { return Ok(Some(BlockDevStat {
read_ios: stat[0], read_ios: stat[0],
read_merges: stat[1],
read_sectors: stat[2], read_sectors: stat[2],
read_ticks: stat[3], write_ios: stat[4] + stat[11], // write + discard
write_ios: stat[4], write_sectors: stat[6] + stat[13], // write + discard
write_merges: stat[5], io_ticks: stat[10],
write_sectors: stat[6],
write_ticks: stat[7],
})); }));
} }
Ok(None) Ok(None)
@ -470,11 +469,8 @@ pub enum DiskType {
/// Represents the contents of the /sys/block/<dev>/stat file. /// Represents the contents of the /sys/block/<dev>/stat file.
pub struct BlockDevStat { pub struct BlockDevStat {
pub read_ios: u64, pub read_ios: u64,
pub read_merges: u64,
pub read_sectors: u64, pub read_sectors: u64,
pub read_ticks: u64, //milliseconds
pub write_ios: u64, pub write_ios: u64,
pub write_merges: u64,
pub write_sectors: u64, pub write_sectors: u64,
pub write_ticks: u64, //milliseconds pub io_ticks: u64, // milliseconds
} }

View File

@ -37,10 +37,7 @@ pub fn zfs_pool_stats(pool: &OsStr) -> Result<Option<BlockDevStat>, Error> {
write_sectors: stat[1]>>9, write_sectors: stat[1]>>9,
read_ios: stat[2], read_ios: stat[2],
write_ios: stat[3], write_ios: stat[3],
read_merges: 0, // there is no such info io_ticks: ticks,
write_merges: 0, // there is no such info
write_ticks: ticks,
read_ticks: ticks,
}; };
Ok(Some(stat)) Ok(Some(stat))

View File

@ -5,24 +5,18 @@ Ext.define('pve-rrd-datastore', {
'total', 'total',
'read_ios', 'read_ios',
'read_bytes', 'read_bytes',
'read_ticks',
'write_ios', 'write_ios',
'write_bytes', 'write_bytes',
'write_ticks', 'io_ticks',
{ {
name: 'read_delay', calculate: function(data) { name: 'io_delay', calculate: function(data) {
if (data.read_ios === undefined || data.read_ios === 0 || data.read_ticks == undefined) { let ios = 0;
if (data.read_ios !== undefined) { ios += data.read_ios; }
if (data.write_ios !== undefined) { ios += data.write_ios; }
if (ios == 0 || data.io_ticks === undefined) {
return undefined; return undefined;
} }
return (data.read_ticks*1000)/data.read_ios; return (data.io_ticks*1000.0)/ios;
}
},
{
name: 'write_delay', calculate: function(data) {
if (data.write_ios === undefined || data.write_ios === 0 || data.write_ticks == undefined) {
return undefined;
}
return (data.write_ticks*1000)/data.write_ios;
} }
}, },
{ type: 'date', dateFormat: 'timestamp', name: 'time' } { type: 'date', dateFormat: 'timestamp', name: 'time' }
@ -85,9 +79,9 @@ Ext.define('PBS.DataStoreStatistic', {
}, },
{ {
xtype: 'proxmoxRRDChart', xtype: 'proxmoxRRDChart',
title: gettext('Delay (ms)'), title: gettext('IO Delay (ms)'),
fields: ['read_delay','write_delay'], fields: ['io_delay'],
fieldTitles: [gettext('Read'), gettext('Write')], fieldTitles: [gettext('IO Delay')],
store: rrdstore store: rrdstore
}, },
] ]

View File

@ -21,8 +21,24 @@ Ext.define('pve-rrd-node', {
'memused', 'memused',
'swaptotal', 'swaptotal',
'swapused', 'swapused',
'roottotal', 'total',
'rootused', 'used',
'read_ios',
'read_bytes',
'write_ios',
'write_bytes',
'io_ticks',
{
name: 'io_delay', calculate: function(data) {
let ios = 0;
if (data.read_ios !== undefined) { ios += data.read_ios; }
if (data.write_ios !== undefined) { ios += data.write_ios; }
if (ios == 0 || data.io_ticks === undefined) {
return undefined;
}
return (data.io_ticks*1000.0)/ios;
}
},
'loadavg', 'loadavg',
{ type: 'date', dateFormat: 'timestamp', name: 'time' } { type: 'date', dateFormat: 'timestamp', name: 'time' }
] ]
@ -146,8 +162,8 @@ Ext.define('PBS.ServerStatus', {
{ {
xtype: 'proxmoxRRDChart', xtype: 'proxmoxRRDChart',
title: gettext('Root Disk IO Delay (ms)'), title: gettext('Root Disk IO Delay (ms)'),
fields: ['read_delay','write_delay'], fields: ['io_delay'],
fieldTitles: [gettext('Read'), gettext('Write')], fieldTitles: [gettext('IO Delay')],
store: rrdstore store: rrdstore
}, },
] ]