CentOS 8 Chrony – how to query servers for time difference?

dualsport asked:

We are moving from CentOS 7 to CentOS 8 for our monitoring servers (Zabbix) and we use ntpdate to query for time to detect if our local time provider for all devices (Cisco device) hasn’t started drifting.

Basically query pool server, query local device and do math to determine if difference is greater than X.

Input:

ntpdate -p 1 -q 0.centos.pool.ntp.org | grep -oP ‘(?<=offset ).*?(?= sec)’

Output:

0.006313

Is there a way to query time (without setting server as source) using chrony or other tool in CentOS 8 that would work in similar fashion?

My answer:


To adapt your existing command, try something like:

[[email protected] ~]# chronyc ntpdata 2001:418:3ff::53 | grep -oP '(?<=Offset          : ).*?(?= sec)'
+0.000654742

The address given must be one of your configured NTP servers.


View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.