Quantcast
Channel: Is it possible to check NTPd status on a Busybox system? - Server Fault
Viewing all articles
Browse latest Browse all 3

Answer by mikewse for Is it possible to check NTPd status on a Busybox system?

$
0
0

BusyBox does not provide the IPC/RPC interfaces that are needed to query the status of a running BusyBox NTP daemon, so even if you install one of the mentioned query utilities they will not be able to talk to BusyBox ntpd.

Running ntpd -w as mentioned in another answer will simply start another BusyBox ntpd instance from scratch and this new one will not talk to an already running ntpd process.

There is however another way to get status information from BusyBox ntpd, by using its program/script interface. See the -S flag:

~# ntpd --helpBusyBox v1.30.1 () multi-call binary.Usage: ntpd [-dnqNwl] [-I IFACE] [-S PROG] [-p PEER]...NTP client/server        -d      Verbose (may be repeated)        -n      Do not daemonize        -q      Quit after clock is set        -N      Run at high priority        -w      Do not set time (only query peers), implies -n        -S PROG Run PROG after stepping time, stratum change, and every 11 min        -p PEER Obtain time from PEER (may be repeated)        -l      Also run as server on port 123        -I IFACE Bind server to IFACE, implies -l

The specified program will be executed regularly depending on different time events and NTP information is supplied as args to the program and in its environment. I find no info about this interface so the source code seems to be the docs in this case:

https://git.busybox.net/busybox/tree/networking/ntpd.c

Look up the function run_script() and you can see that it calls the external program with action as argument and stratum, freq_drift_ppm, poll_interval and offset as environment variables.

Chances are that your embedded Linux distro is already hooking into this interface. On my OpenWrt box ntpd is running with this command line:

/usr/sbin/ntpd -n -N -S /usr/sbin/ntpd-hotplug -p 0.openwrt.pool.ntp.org -p 1.openwrt.pool.ntp.org -p 2.openwrt.pool.ntp.org -p 3.openwrt.pool.ntp.org

and as you can see the program interface is hooking into OpenWrt's procd hotplug support. In OpenWrt this means that you instead add your NTP scripts to /etc/hotplug.d/ntp but the information supplied to your script is still the same, see NTP section here:

https://openwrt.org/docs/guide-user/base-system/hotplug


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images