Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disk_io_counters() values on NetBSD are too high #770

Closed
giampaolo opened this issue Feb 14, 2016 · 5 comments
Closed

disk_io_counters() values on NetBSD are too high #770

giampaolo opened this issue Feb 14, 2016 · 5 comments

Comments

@giampaolo
Copy link
Owner

$ make install && python -c "import psutil; from pprint import pprint as pp; pp(psutil.disk_io_counters(1))"
{'wd0': sdiskio(read_count=13512837104935596480L, write_count=13511736081481412928L, read_bytes=13513043022849399608L, write_bytes=110518291808L)}

...also, they all look similar.
We're definitively doing something wrong.

@giampaolo
Copy link
Owner Author

Also they never increment. I tried writing a big file and checking the numbers but they remain the same.

@0-wiz-0
Copy link
Contributor

0-wiz-0 commented Feb 15, 2016

Seems I was late to the party. Sorry.
Thanks for fixing it so quickly!

@giampaolo
Copy link
Owner Author

In case you want to take it a shot at busy time....
I was trying this:

(long long) PSUTIL_KPT2DOUBLE(stats[i].time)

But I get results which are too low (in the order of the hundreds). I'm not sure how to properly convert that.

@0-wiz-0
Copy link
Contributor

0-wiz-0 commented Feb 15, 2016

vmstat uses:

        struct timeval   *time; /* Time spent in disk i/o. */
...
        static struct io_sysctl *drives = NULL;
...
        mib[0] = CTL_HW;
        mib[1] = HW_IOSTATS;
        mib[2] = sizeof(struct io_sysctl);

        size = ndrive * sizeof(struct io_sysctl);
        if (sysctl(mib, 3, drives, &size, NULL, 0) < 0)
                err(1, "sysctl hw.iostats failed");
        for (i = 0; i < ndrive; i++) {
...
                cur.time[i].tv_sec = drives[i].time_sec;
                cur.time[i].tv_usec = drives[i].time_usec;

Does that help?

@giampaolo
Copy link
Owner Author

Yeah I saw that but it doesn't help. In psutil we have to return milliseconds so we calculate them somehow. This:

#define PSUTIL_TV2DOUBLE(t) ((t).tv_sec + (t).tv_usec / 1000000.0)
PSUTIL_KPT2DOUBLE(stats[i].time);

...looks wrong because the resulting value is too small.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants