Skip to content

Commit 4a7c82d

Browse files
author
Martin Suehowicz
committed
Adding percent I/O time similar to iostat.
1 parent 1410d74 commit 4a7c82d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

diskstat/python_modules/diskstat.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ def update_stats():
155155
get_diff(dev, 'write_time', int(vals[10]))
156156

157157
get_diff(dev, 'io_time', int(vals[12]))
158+
get_percent_time(dev, 'percent_io_time', int(stats[dev]['io_time']))
158159
get_diff(dev, 'weighted_io_time', int(vals[13]))
159160

160161

@@ -186,6 +187,17 @@ def get_delta(dev, key, val, convert=1):
186187

187188
last_val[dev][key] = int(val)
188189

190+
def get_percent_time(dev, key, val):
191+
logging.debug(' get_percent_time for ' + dev + '_' + key)
192+
global stats, last_val
193+
194+
interval = (cur_time - last_update) * 1000
195+
196+
if interval > 0:
197+
stats[dev][key] = round(((val / interval) * 100),2)
198+
else:
199+
stats[dev][key] = 0
200+
189201
def get_diff(dev, key, val):
190202
logging.debug(' get_diff for ' + dev + '_' + key)
191203
global stats, last_val
@@ -275,6 +287,12 @@ def metric_init(params):
275287
'units': 'ms',
276288
'description': 'The time in milliseconds spent in I/O operations'},
277289

290+
percent_io_time = {
291+
'units': 'percent',
292+
'value_type': 'float',
293+
'format': '%f',
294+
'description': 'The percent of disk time spent on I/O operations'},
295+
278296
weighted_io_time = {
279297
'units': 'ms',
280298
'description': 'The weighted time in milliseconds spend in I/O operations. This measures each I/O start, I/O completion, I/O merge, or read of these stats by the number of I/O operations in progress times the number of milliseconds spent doing I/O.'}

0 commit comments

Comments
 (0)