Linter killed ntp-server.sh
karlshea opened this issue · 2 comments
karlshea commented
61064dc killed the output for ntp-server.sh:
old output
{"data":{"offset":"-0.002122","frequency":"-18.488","sys_jitter":"0.001733","clk_jitter":"0.003","clk_wander":"0.001","stratum":"1","time_since_reset":"307809","receive_buffers":"10","free_receive_buffers":"9","used_receive_buffers":"0","low_water_refills":"1","dropped_packets":"0","ignored_packets":"0","received_packets":"88722","packets_sent":"88712","packet_send_failures":"0","input_wakeups":"0","useful_input_wakeups":"89014"},"error":"0","errorString":"","version":"1"}
new output
{"data":{"offset":"-0.001836
0.000","frequency":"-18.464
37","sys_jitter":"0.001703
201701010000","clk_jitter":"","clk_wander":"","stratum":"1","time_since_reset":"306506","receive_buffers":"10","free_receive_buffers":"9","used_receive_buffers":"0","low_water_refills":"1","dropped_packets":"0","ignored_packets":"0","received_packets":"88326","packets_sent":"88316","packet_send_failures":"0","input_wakeups":"0","useful_input_wakeups":"88611"},"error":"0","errorString":"","version":"1"}
A bunch of keys keys are being mis-parsed (offset, frequency, sys_jitter), and then the change to the JSON output also is adding linefeeds.
old
OFFSET=`echo $NTPQ_RAW | $BIN_AWK -F ' ' '{print $3}'`
echo $OFFSET
gives -18.479
new
OFFSET=$(echo "$NTPQ_RAW" | $BIN_AWK -F ' ' '{print $3}')
echo $OFFSET
gives -18.479 37
If I change the new line to
OFFSET=$(echo $NTPQ_RAW | $BIN_AWK -F ' ' '{print $3}')
(removing quotes around $NTPQ_RAW
) it works again.
Full $NTPQ_RAW
is
3 0.000725 -18.485 0.002895 0.002 0.001 37 201701010000
(Sorry the numbers don't match up, I've been debugging and echoing different things)
I don't know enough about Bash to really figure out what the right change is here.