ros / diagnostics

Packages related to gathering, viewing, and analyzing diagnostics data from robots.
https://index.ros.org/p/diagnostics/
Other
89 stars 175 forks source link

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

Closed tonynajjar closed 3 months ago

tonynajjar commented 4 months ago

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?

ct2034 commented 3 months ago

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.