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
Port hd_monitor to ROS2 #334
base: ros2
Are you sure you want to change the base?
Conversation
Thanks for your contribution @limaanto :) |
5c0891a
to
c6fb93c
Compare
Hi, I rebased the branch on |
FREE_PERCENT_LOW = 0.05 | ||
FREE_PERCENT_CRIT = 0.01 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be configurable
KeyValue(key=f'Name', value=self._path), | ||
KeyValue(key=f'Status', value=DICT_STATUS[diag.level]), | ||
KeyValue(key=f'Total (Go)', value=str(total_Go)), | ||
KeyValue(key=f'Available (%)', value=str(round(percent, 2))), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These don't have to be f-strings
]) | ||
|
||
diag.message = DICT_USAGE[diag.level] | ||
print(diag) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove this
def check_disk_usage(self, diag: DiagnosticStatus) -> DiagnosticStatus: | ||
diag.level = DiagnosticStatus.OK | ||
|
||
total, used, free = disk_usage(self._path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
total, used, free = disk_usage(self._path) | |
total, _, free = disk_usage(self._path) |
As promised in #319 (though it took quite a while..), here is a ported version of the HD monitor script.
After the discussions of #319, I decided to :
shutil.disk_usage
which comes with all python installs seemed like a good choicepath
to configure where the check is ran on. By default this is the home directory but can be changed with a ros paramI did not take the time to write the test yet, let me know if this is mandatory for merging (or if there is any other point for that matter)