Add error percentage to cpu and ram monitor#548
Open
sangteak601 wants to merge 5 commits intoros:ros2from
Open
Add error percentage to cpu and ram monitor#548sangteak601 wants to merge 5 commits intoros:ros2from
sangteak601 wants to merge 5 commits intoros:ros2from
Conversation
Author
|
@ct2034 |
ct2034
requested changes
Mar 30, 2026
| if cpu_average > self._error_percentage: | ||
| stat.summary(DiagnosticStatus.ERROR, | ||
| f'CPU Average exceeds {self._error_percentage} percent') | ||
| elif cpu_average > self._warning_percentage: |
Collaborator
There was a problem hiding this comment.
This changes the behavior, because previously this warning was done per individual cpu. This is not bad per se. But the default behaviour should stay as it was previously
|
|
||
| # Declare and get parameters | ||
| node.declare_parameter('warning_percentage', 90) | ||
| node.declare_parameter('error_percentage', 100) |
Collaborator
There was a problem hiding this comment.
100 is a weird default value. I suggest 95
Comment on lines
16
to
+17
| * warning_percentage: If the CPU usage is > warning_percentage, a WARN status will be publised. | ||
| * error_percentage: If the CPU usage is > error_percentage, an ERROR status will be published. |
Collaborator
There was a problem hiding this comment.
please also make the this more precise in terms of average vs single cpu
| class CpuTask(DiagnosticTask): | ||
|
|
||
| def __init__(self, warning_percentage=90, window=1): | ||
| def __init__(self, warning_percentage=90, error_percentage=100, window=1): |
Collaborator
There was a problem hiding this comment.
Suggested change
| def __init__(self, warning_percentage=90, error_percentage=100, window=1): | |
| def __init__(self, warning_percentage, error_percentage, window): |
Collaborator
There was a problem hiding this comment.
this way its closer to the ram implementation and there are not too many place where defaults are set.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
At the moment, it is not possible to configure
cpu_monitororram_monitorto publish ERROR status. It would be good to have ERROR state. It would allow us to take actions before program exhibits unexpected behaviour.Also,
cpu_monitorwas updated to compare threshold to average cpu usage rather than individual cpu usage. This is aligned with howram_monitorworks and makes more sense, as in most cases users are more interested in average usage than individual usage.