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

[systeminfo] Add CPU load channel, update dependencies #13292

Merged
merged 5 commits into from
Sep 11, 2022

Conversation

mherwege
Copy link
Contributor

Signed-off-by: Mark Herwege mark.herwege@telenet.be

The systeminfo binding currently provides average CPU load (expressed as average number of jobs queued) over 1, 5 and 15 minute intervals with respective channels. These measures are not available on Windows. There used to be a % CPU load channel, which was removed a while ago as the underlying oshi library changed.
It is still possible to get dynamic CPU load from current versions of the oshi library and have that available on all platforms (including Windows). That is implemented in this pull request.

This PR also updates the dependency to the latest version of the oshi libary (6.2.2). This version should also detect and support Apple M2 chips (not tested).

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
@mherwege mherwege added the enhancement An enhancement or new feature for an existing add-on label Aug 19, 2022
Copy link
Contributor

@lsiepel lsiepel left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -295,6 +296,14 @@
<config-description-ref uri="channel-type:systeminfo:highpriority_process"/>
</channel-type>

<channel-type id="cpuLoad">
<item-type>Number:Dimensionless</item-type>
Copy link
Contributor

@lolodomo lolodomo Sep 3, 2022

Choose a reason for hiding this comment

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

You are setting Number:Dimensionless but you are building a DecimalType state to update the channel state.
So Number looks sufficient?

case CHANNEL_CPU_LOAD:
DecimalType load = systeminfo.getSystemCpuLoad();
if (load != null) {
load = new DecimalType(load.doubleValue() * 100);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not using PercentType which is the appropriate state for a percentage state value ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lolodomo I think this would be the right thing to do.
However, I did the same thing as for the existing usedHeapPercent channel, which was the last channel added and uses Number:Dimensionless with an underlying DecimalType.
But there are also a number of older channels that represent a percentage, with just Number as the type.
Converting them all to PercentType and Number:Dimensionless would be a breaking change. Adding yet another different combination doesn't feel right.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lolodomo What is your view on this?

@@ -104,6 +104,7 @@ The binding introduces the following channels:

| Channel ID | Channel Description | Supported item type | Default priority | Advanced |
|--------------------|------------------------------------------------------------------|---------------------|------------------|----------|
| load | CPU Load in % | Number:Dimensionless| High | False |
Copy link
Contributor

Choose a reason for hiding this comment

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

See my other comments, I am not sure that Number:Dimensionless is more appropriate than Number.

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
Copy link
Contributor

@lolodomo lolodomo left a comment

Choose a reason for hiding this comment

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

LGTM

@lolodomo lolodomo merged commit 909d390 into openhab:main Sep 11, 2022
@lolodomo
Copy link
Contributor

I am not sure if the changed item type from Number to Number:Dimensionless for the channel type load_process is or not a breaking change.

@lolodomo lolodomo added this to the 3.4 milestone Sep 11, 2022
@mherwege
Copy link
Contributor Author

@lolodomo Thank you.

I am not sure if the changed item type from Number to Number:Dimensionless for the channel type load_process is or not a breaking change.

I think it is backward compatible, so nt a breaking change. I tested and was able to link a plain Number item to a Number:Dimensionless channel.

@mherwege mherwege deleted the systeminfo_cpuload branch September 12, 2022 07:04
leifbladt pushed a commit to leifbladt/openhab-addons that referenced this pull request Oct 15, 2022
* Add CPU load channel, update dependencies
* use PercentType, correct process CPU load
* Add and fix test

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
andan67 pushed a commit to andan67/openhab-addons that referenced this pull request Nov 6, 2022
* Add CPU load channel, update dependencies
* use PercentType, correct process CPU load
* Add and fix test

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
andrasU pushed a commit to andrasU/openhab-addons that referenced this pull request Nov 12, 2022
* Add CPU load channel, update dependencies
* use PercentType, correct process CPU load
* Add and fix test

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
marcelGoerentz pushed a commit to marcelGoerentz/openhab-addons that referenced this pull request Nov 14, 2022
* Add CPU load channel, update dependencies
* use PercentType, correct process CPU load
* Add and fix test

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
psmedley pushed a commit to psmedley/openhab-addons that referenced this pull request Feb 23, 2023
* Add CPU load channel, update dependencies
* use PercentType, correct process CPU load
* Add and fix test

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
nemerdaud pushed a commit to nemerdaud/openhab-addons that referenced this pull request Feb 28, 2023
* Add CPU load channel, update dependencies
* use PercentType, correct process CPU load
* Add and fix test

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature for an existing add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants