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,
&[
"total", "used",
"read_ios", "read_bytes", "read_ticks",
"write_ios", "write_bytes", "write_ticks",
"read_ios", "read_bytes",
"write_ios", "write_bytes",
"io_ticks",
],
timeframe,
cf,

View File

@ -36,8 +36,9 @@ fn get_node_stats(
"netin", "netout",
"loadavg",
"total", "used",
"read_ios", "read_bytes", "read_ticks",
"write_ios", "write_bytes", "write_ticks",
"read_ios", "read_bytes",
"write_ios", "write_bytes",
"io_ticks",
],
timeframe,
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);
let rrd_key = format!("{}/read_bytes", rrd_prefix);
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);
rrd_update_derive(&rrd_key, stat.write_ios as f64);
let rrd_key = format!("{}/write_bytes", rrd_prefix);
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
///
/// see https://www.kernel.org/doc/Documentation/block/stat.txt
pub fn read_stat(&self) -> std::io::Result<Option<BlockDevStat>> {
if let Some(stat) = self.read_sys(Path::new("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)
}).collect();
if stat.len() < 8 { return Ok(None); }
if stat.len() < 15 { return Ok(None); }
return Ok(Some(BlockDevStat {
read_ios: stat[0],
read_merges: stat[1],
read_sectors: stat[2],
read_ticks: stat[3],
write_ios: stat[4],
write_merges: stat[5],
write_sectors: stat[6],
write_ticks: stat[7],
write_ios: stat[4] + stat[11], // write + discard
write_sectors: stat[6] + stat[13], // write + discard
io_ticks: stat[10],
}));
}
Ok(None)
@ -470,11 +469,8 @@ pub enum DiskType {
/// Represents the contents of the /sys/block/<dev>/stat file.
pub struct BlockDevStat {
pub read_ios: u64,
pub read_merges: u64,
pub read_sectors: u64,
pub read_ticks: u64, //milliseconds
pub write_ios: u64,
pub write_merges: 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,
read_ios: stat[2],
write_ios: stat[3],
read_merges: 0, // there is no such info
write_merges: 0, // there is no such info
write_ticks: ticks,
read_ticks: ticks,
io_ticks: ticks,
};
Ok(Some(stat))

View File

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

View File

@ -21,8 +21,24 @@ Ext.define('pve-rrd-node', {
'memused',
'swaptotal',
'swapused',
'roottotal',
'rootused',
'total',
'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',
{ type: 'date', dateFormat: 'timestamp', name: 'time' }
]
@ -146,8 +162,8 @@ Ext.define('PBS.ServerStatus', {
{
xtype: 'proxmoxRRDChart',
title: gettext('Root Disk IO Delay (ms)'),
fields: ['read_delay','write_delay'],
fieldTitles: [gettext('Read'), gettext('Write')],
fields: ['io_delay'],
fieldTitles: [gettext('IO Delay')],
store: rrdstore
},
]