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

DiskIO values as extra attributes in Disk Entity #87

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

lockenkop
Copy link
Contributor

@lockenkop lockenkop commented Dec 11, 2023

psutil.disk_io_counters() in Disk Entity

Acording to psutil docs (https://psutil.readthedocs.io/en/latest/index.html#psutil.disk_io_counters)
most relevant values are supported on all except BSD.
Namely:

  • read_count
  • write_count
  • read_bytes
  • write_bytes

Other platform specific fields will only get accessed if on linux.

Windows may need an extra flag:

On Windows it may be necessary to issue diskperf -y command from cmd.exe first in order to enable IO counters.

Currently tested only on Linux with Console Warehouse. I'll check windows and display in HomeAssistant further this week.

@lockenkop lockenkop marked this pull request as draft December 11, 2023 13:08
Copy link
Collaborator

@infeeeee infeeeee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! I will take a look on Windows, psutil docs says this:

Note: on Windows "diskperf -y" command may need to be executed first otherwise this function won’t find any disk.

It should be called in Initialize on Win, use self.RunCommand()

I don't see how this data is useful for anything this way though, if you see the example application, the difference of these numbers should be divided by the update frequency to get actual speed: https://github.com/giampaolo/psutil/blob/master/scripts/iotop.py These numbers are just sums, counts, not per second, so by itself they don't say much.

Haven't tested just read the code yet.

IoTuring/Entity/Deployments/Disk/Disk.py Outdated Show resolved Hide resolved
IoTuring/Entity/Deployments/Disk/Disk.py Outdated Show resolved Hide resolved
IoTuring/Entity/Deployments/Disk/Disk.py Outdated Show resolved Hide resolved
@richibrics
Copy link
Owner

diskperf -y is needed only the first time, and a reboot is required before accessing those informations (diskperf) so I'd suggest the user to manually use that command in the cmd or ask the user if he wants to enable that characteristic and do it from IoTuring.
Although, that would need the configurations to know which is the host OS.

Co-authored-by: infeeeee <gyetpet@mailbox.org>
@lockenkop
Copy link
Contributor Author

so I'd suggest the user to manually use that command in the cmd or ask the user if he wants to enable that characteristic and do it from IoTuring. Although, that would need the configurations to know which is the host OS.

Doing this with self.RunCommand() at configuration and asking the user to reboot seems okay to me.
I'll test if its possible to check for the availability during configuration and show this step if it needs the change and reboot.
Playing around with the windows side of things this week.

@infeeeee
Copy link
Collaborator

infeeeee commented Dec 11, 2023 via email

@infeeeee infeeeee added the enhancement New feature or request label Jan 2, 2024
@richibrics
Copy link
Owner

Hi @lockenkop, which is the current state of this entity enhancement ?

@lockenkop
Copy link
Contributor Author

lockenkop commented Feb 27, 2024

Hi, o had some personal stuff going on and I am abroad until April. I was about to get some coding done starting this week. Sadly my surface's battery decided to become balloon. This PR should be nearly done. I'll see if I can do some finishing on my phone.

@richibrics
Copy link
Owner

No problem, work on it when you'll have free time or write what's missing so someone else will do it 💪
Thanks for your work !

@lockenkop
Copy link
Contributor Author

latest
I'll have to do some testing if the read and writerates are even remotely accurate.
At least they spike when i read or write a file, so it must be somewhat plausible.

@lockenkop lockenkop marked this pull request as ready for review July 12, 2024 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants