ros / diagnostics

Packages related to gathering, viewing, and analyzing diagnostics data from robots.

Home Page:https://index.ros.org/p/diagnostics/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NTP monitor: implement diagnostic to check if synchronized to the correct source

tonynajjar opened this issue · comments

What do you think of adding to the NTP monitor an optional check for which source we are currently synchronized with? I have the case that although my chrony configuration is set to prefer a computer connected via ethernet, it sometimes switches to another source. I would like to detect this in the diagnostics.

Implementation details

I only researched how to do it for chrony. Unfortunately there is no python library for chrony so the method uses subprocess.run. We would run chronyc tracking and parse the server name (in this case nuc) and check whether it matches the user-configured wished server

chronyc tracking
Reference ID    : C0A80032 (nuc)
Stratum         : 4
Ref time (UTC)  : Tue Jun 04 14:10:00 2024
System time     : 0.000340873 seconds fast of NTP time
Last offset     : +0.000357083 seconds
RMS offset      : 0.000497816 seconds
Frequency       : 10.381 ppm slow
Residual freq   : +3.072 ppm
Skew            : 1.499 ppm
Root delay      : 0.037382413 seconds
Root dispersion : 0.001741173 seconds
Update interval : 32.5 seconds
Leap status     : Normal

What do you think @ct2034?

Hey @tonynajjar.

Thanks for the issue.
I think this is a very specific use case. If we do this, we could also add diagnostics monitors for all possible configuration options. And this is then nothing specific to robotics, but to Linux systems.
What you can do is check the time offset to the desired NTP server if that helps you.

Sorry, I close this. Feel free to reopen it if there are more people having this request or a more generic idea to solve this.