Skip to content

Commit

Permalink
#756 (FreeBSD / disk_io_counters()): add busy_time
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Jan 14, 2016
1 parent a2bf22d commit 0ddcfd9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions psutil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1799,12 +1799,13 @@ def disk_io_counters(perdisk=False):
rawdict = _psplatform.disk_io_counters()
if not rawdict:
raise RuntimeError("couldn't find any physical disk")
nt = getattr(_psplatform, 'sdiskio', _common.sdiskio)
if perdisk:
for disk, fields in rawdict.items():
rawdict[disk] = _common.sdiskio(*fields)
rawdict[disk] = nt(*fields)
return rawdict
else:
return _common.sdiskio(*[sum(x) for x in zip(*rawdict.values())])
return nt(*[sum(x) for x in zip(*rawdict.values())])


# =====================================================================
Expand Down
4 changes: 4 additions & 0 deletions psutil/_psbsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@
'pmmap_grouped', 'path rss, private, ref_count, shadow_count')
pmmap_ext = namedtuple(
'pmmap_ext', 'addr, perms path rss, private, ref_count, shadow_count')
sdiskio = namedtuple('sdiskio', ['read_count', 'write_count',
'read_bytes', 'write_bytes',
'read_time', 'write_time',
'busy_time'])

# set later from __init__.py
NoSuchProcess = None
Expand Down
5 changes: 3 additions & 2 deletions psutil/arch/bsd/freebsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -759,13 +759,14 @@ psutil_disk_io_counters(PyObject *self, PyObject *args) {
current.unit_number);

py_disk_info = Py_BuildValue(
"(KKKKLL)",
"(KKKKLLL)",
current.operations[DEVSTAT_READ], // no reads
current.operations[DEVSTAT_WRITE], // no writes
current.bytes[DEVSTAT_READ], // bytes read
current.bytes[DEVSTAT_WRITE], // bytes written
(long long) PSUTIL_BT2MSEC(current.duration[DEVSTAT_READ]), // r time
(long long) PSUTIL_BT2MSEC(current.duration[DEVSTAT_WRITE]) // w time
(long long) PSUTIL_BT2MSEC(current.duration[DEVSTAT_WRITE]), // w time
(long long) PSUTIL_BT2MSEC(current.busy_time) // busy time
); // finished transactions
if (!py_disk_info)
goto error;
Expand Down

0 comments on commit 0ddcfd9

Please sign in to comment.