0

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?

  • 1
    Does the output of chronyc sources give you the info you need? – Krackout Sep 23 at 15:05
  • chronyc sources would give only me info on source server. But I don't want to add Cisco device (local time server) as source only 0.centos.pool.ntp.org. So I need a way to query server without setting it as source or setting local time from it. – dualsport Sep 23 at 16:49
1

To adapt your existing command, try something like:

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

The address given must be one of your configured NTP servers. To do this, you should add the server to your sources list with the noselect option. This will tell chronyd to monitor the server but never synchronize from it. For example:

server cisco-ntp-server.example.com iburst noselect

Of course you can always continue to use ntpdate, and your question didn't specify why you are not willing to do this.

| improve this answer | |
  • nonselect might be answer to my problem. ntpdate (ntp) as far as I understand has been depreciated in CentOS8 or am I getting something wrong and can't find right package? – dualsport Sep 23 at 17:31
  • @dualsport Hm, you're right, it seems to have been dropped from CentOS 8. I can't find it either. In any case, noselect is probably going to do it for you. – Michael Hampton Sep 23 at 17:47
  • This seems like answer except zabbix_agent can't use chronyc, it get's "501 Not authorised" error and I am not exactly sure how to add user to allow to use this process. – dualsport Sep 23 at 19:08
  • @dualsport See if this helps serverfault.com/a/923484/126632 Otherwise increase the agent's log level and see what you can find in its logs. – Michael Hampton Sep 23 at 19:15
  • It seems to be an issue with Chrony where it can be run only under root or chrony user from what I understand (and I don't claim to understand much as I am mainly Win administrator): 401 4.2. I keep getting the error 501 Not authorised 402 403 Since version 2.2, the password command doesn't do anything and chronyc needs 404 to run locally under the root or chrony user, which are allowed to access the 405 chronyd's Unix domain command socket. – dualsport Sep 23 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.