Hello, I am trying to find a way to keep hwclock in sync with the ntp-synced system time using busysbox ntpd. Ntpd is able to start a script after each change and every 11 minutes (parameter -S) but there seems to be no way to find out if the time is still synchronized i.e. there is at least one valid ntp server. The attached patch exports one more value to the script (last_update_recv_time) so that the script can at least check if the last update is within some limit. I consider this a workaround rather than a real solution because I would expect ntpd to set stratum to 16 when loosing contact to the upstream ntp servers but I could not find a proper way to handle this. Anyone any suggestions?
Greetings Andreas [Patch] ntpd: set additional env variable "last_update_recv_time" when running script Signed-off-by: Andreas Helmcke <[email protected]> --- networking/ntpd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/networking/ntpd.c b/networking/ntpd.c index 0f4319e..eec01aa 100644 --- a/networking/ntpd.c +++ b/networking/ntpd.c @@ -828,7 +828,7 @@ send_query_to_peer(peer_t *p) static void run_script(const char *action, double offset) { char *argv[3]; - char *env1, *env2, *env3, *env4; + char *env1, *env2, *env3, *env4, *env5; if (!G.script_name) return; @@ -847,6 +847,8 @@ static void run_script(const char *action, double offset) putenv(env3); env4 = xasprintf("%s=%f", "offset", offset); putenv(env4); + env5 = xasprintf("%s=%f", "last_update_recv_time", G.last_update_recv_time); + putenv(env5); /* Other items of potential interest: selected peer, * rootdelay, reftime, rootdisp, refid, ntp_status, * last_update_offset, last_update_recv_time, discipline_jitter, @@ -862,10 +864,12 @@ static void run_script(const char *action, double offset) unsetenv("freq_drift_ppm"); unsetenv("poll_interval"); unsetenv("offset"); + unsetenv("last_update_recv_time"); free(env1); free(env2); free(env3); free(env4); + free(env5); G.last_script_run = G.cur_time; } -- 1.8.1.2 _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
