Skip to content

Commit

Permalink
fix #770: [NetBSD] disk_io_counters() metrics didn't update.
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Jan 24, 2016
1 parent 4bec7e4 commit 6ebf9d4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Bug tracker at https://github.com/giampaolo/psutil/issues
- #764: [NetBSD] fix compilation on NetBSD-6.x.
- #767: [Linux] disk_io_counters() may raise ValueError on 2.6 kernels and it's
broken on 2.4 kernels.
- #770: [NetBSD] disk_io_counters() metrics didn't update.


3.4.2 - 2016-01-20
Expand Down
2 changes: 1 addition & 1 deletion psutil/_psbsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
else:
sdiskio = namedtuple('sdiskio', ['read_count', 'write_count',
'read_bytes', 'write_bytes',
'busy_time'])
])

# set later from __init__.py
NoSuchProcess = None
Expand Down
11 changes: 4 additions & 7 deletions psutil/arch/bsd/netbsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,22 +643,19 @@ psutil_disk_io_counters(PyObject *self, PyObject *args) {
PyErr_NoMemory();
goto error;
}
if (sysctl(mib, 2, stats, &len, NULL, 0) < 0 ) {
if (sysctl(mib, 3, stats, &len, NULL, 0) < 0 ) {
PyErr_SetFromErrno(PyExc_OSError);
goto error;
}

for (i = 0; i < dk_ndrive; i++) {
py_disk_info = Py_BuildValue(
"(KKKKLL)",
"(KKKK)",
stats[i].rxfer,
stats[i].wxfer,
stats[i].rbytes,
stats[i].wbytes,
// assume half read - half writes.
// TODO: why?
(long long) PSUTIL_KPT2DOUBLE(stats[i].time) / 2,
(long long) PSUTIL_KPT2DOUBLE(stats[i].time) / 2);
stats[i].wbytes
);
if (!py_disk_info)
goto error;
if (PyDict_SetItemString(py_retdict, stats[i].name, py_disk_info))
Expand Down

0 comments on commit 6ebf9d4

Please sign in to comment.