Skip to content

Conversation

@rical
Copy link
Contributor

@rical rical commented Dec 2, 2025

Description

Add service runtime statistics monitoring with memory usage, uptime, and restart counts. Includes a new SimpleTable framework for clean CLI formatting that handles ANSI colors correctly.

TODO

I realise now that I want to improve the SimpleTable() class to dynamically space columns based on added data. But I submit this as is because I don't want to risk leaving it dangling. Basically it works fine as it is but it can be improved (as always).

Checklist

Tick relevant boxes, this PR is-a or has-a:

  • Bugfix
    • Regression tests
    • ChangeLog updates (for next release)
  • Feature
    • YANG model change => revision updated?
    • Regression tests added?
    • ChangeLog updates (for next release)
    • Documentation added?
  • Test changes
    • Checked in changed Readme.adoc (make test-spec)
    • Added new test to group Readme.adoc and yaml file
  • Code style update (formatting, renaming)
  • Refactoring (please detail in commit messages)
  • Build related changes
  • Documentation content changes
    • ChangeLog updated (for major changes)
  • Other (please describe):

@rical rical force-pushed the statd-add-service-stat branch 2 times, most recently from 4f60230 to 9a26231 Compare December 2, 2025 16:43
Copy link
Contributor

@wkz wkz left a comment

Choose a reason for hiding this comment

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

This looks great!

Don't these changes depend on the addition of memory stats to initctl -j though?

@rical
Copy link
Contributor Author

rical commented Dec 4, 2025

This looks great!

Thanks!

Don't these changes depend on the addition of memory stats to initctl -j though?

Yes and no. The code handles it gracefully if those stats aren't there yet, so it won't break anything. I wrote it this way intentionally so we could merge this without waiting for the finit upgrade that adds the memory counters. Basically wanted to keep this decoupled from the buildroot update.

@rical
Copy link
Contributor Author

rical commented Dec 17, 2025

@wkz Can we merge this in its current state? As I mentioned above, the fact that finit don't support mem counters yet should not break anything.

Add statistics container to service model with memory usage, uptime,
and restart count tracking.

Updates YANG revision to 2025-12-02.

Signed-off-by: Richard Alpe <richard@bit42.se>
Populate operational runtime statistics for services.

Signed-off-by: Richard Alpe <richard@bit42.se>
Replace manual f-string formatting with SimpleTable/Column classes.

This new "framework" handles ANSI colors and padding. Removing the
hassle of manually calculating padding. You simply specify the header
with max number of chars the data can be and if you want left/right
padding and the "framework" calculates the padding for you.

We use this new "framework" to pretty print the newly added services
statistics.

Signed-off-by: Richard Alpe <richard@bit42.se>
Signed-off-by: Richard Alpe <richard@bit42.se>
@troglobit
Copy link
Contributor

@wkz Can we merge this in its current state? As I mentioned above, the fact that finit don't support mem counters yet should not break anything.

I think so, we'll not backport this to v25.08.x anyway, and a Finit bump is incoming in PR #1327

- Remove fixed lengths from Column class
- Add dynamic width calculation to SimpleTable
- Update service table to use new batched printing

Signed-off-by: Richard Alpe <richard@bit42.se>
@rical rical force-pushed the statd-add-service-stat branch from 9a26231 to faebf70 Compare December 18, 2025 09:53
@mattiaswal mattiaswal requested a review from wkz December 18, 2025 13:38
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.

4 participants