Linux NTP offset HOWto

Hi guys.
I see windows “time offset” threshold is set to 30 seconds for warning alert and 60 seconds for critical.

Could you please tell me where i can set offset for Linux servers?

I see “State of NTP time synchronisation”, but you have to specify the stratum. Default is 200 and 300 ms. That’s really different to Windows.

How can i set the same, 30/60 seconds offset, no matter the stratum?
I have to create a rule per stratum?

Thanks!!!

Hallo,
which cmk Version is in use?
A manual check should offer these options.
Ralf

Hello,

you could use that ruleset to set the 30/60 second offset and just leave the stratum settings at the default value of 10. If the stratum of your time source you’re synchronizing with is that high i think it should trigger a WARN/CRIT state, as you probably shouldn’t synchronize it.

I also think that the System Time service for Windows hosts works a bit differently than for Linux hosts. On Windows it checks the time difference between the windows host and your monitoring server (at least that’s how it was with the “old” Windows agent). That is based on the assumption that your monitoring server has the correct time and is set as the reference value for the time on your Windows hosts. This behaviour might have been changed with the new Windows agent, so someone please correct me if I’m wrong on this.
On Linux it checks the output of the ntpq-command, so it really checks the time synchronisation of your monitored host and its NTP server.

Cheers,
Lorenz

@Andreas, CEE 1.6.0p21. Linux servers? CMK agents? 1.2.6, 1.4.0, all kind of stuff.
@Lorenz, exactly.

So, is there a way to do the same with Linux servers? compare their time with CMK server time? Take that offset?

Thanks!!

No way to do it guys?

You need to extend you Linux Agent. The last output should be a section with name

<<<systemtime>>>
1616796507

and timestamp of the agent call.
Now your Linux host should also show an time offset like on Windows. It should be the last section generated that you have no extra time from other sections generated.

Hi @gera83,
you can use this local check to convert the unix systemtime to windows systemtime output.
Checkmk then uses the systemtime checks made for windows for your linux systems. And you can use the rules made for windows.

Put this script in the localcheck directory e.g /usr/lib/check_mk_agent/local/

time.sh

#!/bin/bash

# unix sytemtime format to windows timeformat converter

if type date> /dev/null 2>&1 ;then

echo "<<<systemtime>>>"

date '+%s'

fi

Hope this helps you and use this script at your own risk.
Greetings Norm :wink:

2 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.