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

Add support for system values reporting #33

Merged
merged 8 commits into from
Jan 4, 2024

Conversation

elvioaruta
Copy link
Member

@elvioaruta elvioaruta commented Jan 3, 2024

Your checklist for this pull request

🚨Please review the guidelines for contributing to this repository.

  • Make sure you are requesting to pull a topic/feature/bugfix branch (right side). Don't request your main!
  • Make sure you are making a pull request against the main branch (left side). Also you should start your branch off our main.
  • Check your code additions will fail neither code linting checks nor unit test.

Description

Adds support for systems stats reporting.
Now it is possible to report CPU load, RAM Usage and HDD Usage.
This change allows the Edge SDK to report system values, which can be seen in the vitals widget.

@elvioaruta elvioaruta self-assigned this Jan 3, 2024
@@ -829,6 +831,35 @@ def set_pairs(key):

self.publish_protobuf(MQTT_SUBTOPIC_CUSTOM_DATA, msg)

def publish_system_stats(self, system_values):
Copy link
Member

Choose a reason for hiding this comment

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

I suggest changing this method's signature to publish_system_stats(self, cpu_load_percentage=None, ram_usage_percentage=None, hdd_usage_percentage=None, total_tx=None, total_rx=None, ts=None, elapsed_seconds=None) This way the SDK users can leverage IDE autocomplete features and minimize the chances of typos in the field names.

Copy link
Member Author

Choose a reason for hiding this comment

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

nice suggestion, I agree :)

msg.total_tx = total_tx
msg.total_rx = total_rx
msg.timestamp = ts if ts else int(time.time() * 1000)
msg.elapsed_seconds = elapsed_seconds
Copy link
Member

Choose a reason for hiding this comment

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

What happens if elapsed_seconds is not provided? If it's required we should either remove the default None value or calculate it using the previous system stat message ts

Copy link
Member Author

Choose a reason for hiding this comment

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

if elapsed_seconds is not provided, the platform won't calculate the Network rate, since it uses a delta, I think calculating using the previous message could work

Copy link
Member Author

@elvioaruta elvioaruta Jan 3, 2024

Choose a reason for hiding this comment

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

Network rate just using last seconds won't work, since we need to calculate Deltas, for now, I'll leave to the user the possibility of implementing that, since calculating deltas etc will be a particular implementation that could not satisfy how the user wants this to work

@elvioaruta
Copy link
Member Author

As discussed with @leandropineda , we'll leave the network implementation for later, ready for a re-review

@elvioaruta elvioaruta merged commit 6c81bba into main Jan 4, 2024
10 checks passed
@russell-inorbit russell-inorbit deleted the feature/adding-robot-vitals-support branch April 2, 2024 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants