Skip to content

Commit c709c7d

Browse files
authored
add new app: systemd-timesyncd (#608)
1 parent c344fed commit c709c7d

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

snmp/systemd-timesyncd

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/sh
2+
# Please make sure the paths below are correct.
3+
# Alternatively you can put them in $0.conf, meaning if you've named
4+
# this script ntp-client then it must go in ntp-client.conf .
5+
#
6+
# If you are unsure, which to set, run this script and make sure that
7+
# the JSON output variables match that in "ntpq -c rv".
8+
#
9+
################################################################
10+
# Don't change anything unless you know what are you doing #
11+
################################################################
12+
BIN_TIMEDATECTL='/usr/bin/env timedatectl'
13+
BIN_GREP='/usr/bin/env grep'
14+
BIN_AWK='/usr/bin/env awk'
15+
16+
NTP_OFFSET=$($BIN_TIMEDATECTL timesync-status | $BIN_GREP "Offset" | $BIN_AWK -F: '{print $2 + 0}')
17+
NTP_FREQUENCY=$($BIN_TIMEDATECTL timesync-status | $BIN_GREP "Frequency" | $BIN_AWK -F: '{print $2 + 0}')
18+
NTP_JITTER=$($BIN_TIMEDATECTL timesync-status | $BIN_GREP "Jitter" | $BIN_AWK -F: '{print $2 + 0}')
19+
NTP_DELAY=$($BIN_TIMEDATECTL timesync-status | $BIN_GREP "Delay" | $BIN_AWK -F: '{print $2 + 0}')
20+
21+
echo '{"data":{"offset":"'"$NTP_OFFSET"'","frequency":"'"$NTP_FREQUENCY"'","jitter":"'"$NTP_JITTER"'","delay":"'"$NTP_DELAY"'"},"version":"1","error":"0","errorString":""}'
22+
23+
exit 0

0 commit comments

Comments
 (0)