Community discussions

MikroTik App
 
stormpelican
just joined
Topic Author
Posts: 1
Joined: Thu Oct 13, 2022 12:31 pm

Logging of NTP client synchronization events

Thu Oct 13, 2022 2:29 pm

Hello everyone,
I'm new to this forum, and also to Miktotik scripting, so please bear with me.

I've taken over an existing rsc script for a 450Gx4 RouterBoard.
I want to add NTP functionality. The RB shall serve both as an NTP Client (to get current time from a "master" device via NTP) and as an NTP server (to provide the current time to multiple other devices). That's why I cannot use the integrated SNTP (it doesn't provide server functionality), but have to use the separate NTP package.

The functionality itself is working, no problem. But, I'm struggling with logging the synchronization events of the NTP client.
When using SNTP I would get a log entry like this in the log file:
sntp change time Jan/02/1970 00:04:06 => Oct/12/2022 10:52:16
Unfortunately this does not work with the NTP client, as it's not providing any logging functionality.
Could someone help me with this? How could I add such log entries using a script, that writes log entries in case there is a successful time synchronization?

Thanks in advance!
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3279
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Logging of NTP client synchronization events

Fri Oct 14, 2022 8:27 am

NTP do sends out logs.

Without Debug you get these logs.
script,info MikroTik: script=ntp status=synchronized
script,info MikroTik: script=ntp status=synchronized
With debug on:
ntp,debug MikroTik: tx dst-ip:224.0.1.1
ntp,debug MikroTik: tx dst-ip:192.168.5.10
ntp,debug MikroTik: CLIENT message received
ntp,debug MikroTik: rx src-ip:192.168.5.10 dst-ip:192.168.5.1
ntp,debug MikroTik: Message offset:-0.002303 delay:0.012773 disp:0.000003
ntp,debug MikroTik: rx src-ip:80.89.32.122 dst-ip:92.99.99.1
ntp,debug MikroTik: tx dst-ip:80.89.32.122
ntp,debug MikroTik: tx dst-ip:192.168.5.67
ntp,debug MikroTik: CLIENT message received
ntp,debug MikroTik: rx src-ip:192.168.5.67 dst-ip:192.168.5.1
ntp,debug MikroTik: tx dst-ip:192.168.5.14
ntp,debug MikroTik: CLIENT message received
ntp,debug MikroTik: rx src-ip:192.168.5.14 dst-ip:192.168.5.1
ntp,debug MikroTik: Message offset:-0.002005 delay:0.011548 disp:0.000002
ntp,debug MikroTik: rx src-ip:92.220.229.76 dst-ip:92.99.99.1
ntp,debug MikroTik: tx dst-ip:92.220.229.76

Who is online

Users browsing this forum: JDF and 20 guests