From c82348bb5359644963bd957732e6fc5746fdf98b Mon Sep 17 00:00:00 2001 From: "Zane C. Bowers-Hadley" Date: Wed, 20 Oct 2021 14:35:52 -0500 Subject: [PATCH 1/4] fix for ntp-server.sh from #376 --- snmp/ntp-server.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/snmp/ntp-server.sh b/snmp/ntp-server.sh index 30c7220..fba25a2 100755 --- a/snmp/ntp-server.sh +++ b/snmp/ntp-server.sh @@ -69,11 +69,11 @@ if [ $NTPQV = "p1" ]; then CLK_WANDER=$(echo $NTPQ_RAW | $BIN_AWK -F ' ' '{print $6}') fi -VER=$($BIN_NTPD --version) -if [ "$VER" = '4.2.6p5' ]; then - USECMD=$(echo "$BIN_NTPDC" -c iostats) +VER=$($BIN_NTPD --version 2>&1 | head -n 1) +if [[ "$VER" == *"4.2.6p5"* ]]; then + USECMD=$(echo "$BIN_NTPDC" -c iostats 127.0.0.1) else - USECMD=$(echo "$BIN_NTPQ" -c iostats localhost) + USECMD=$(echo "$BIN_NTPQ" -c iostats 127.0.0.1) fi CMD2=$($USECMD | $BIN_TR -d ' ' | $BIN_CUT -d : -f 2 | $BIN_TR '\n' ' ') From b99db0b3848b8bba8df6929980794e2f9558ebd6 Mon Sep 17 00:00:00 2001 From: "Zane C. Bowers-Hadley" Date: Wed, 20 Oct 2021 14:44:07 -0500 Subject: [PATCH 2/4] [[ -> [ tested on FreeBSD and works --- snmp/ntp-server.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snmp/ntp-server.sh b/snmp/ntp-server.sh index fba25a2..b3b78fb 100755 --- a/snmp/ntp-server.sh +++ b/snmp/ntp-server.sh @@ -70,7 +70,7 @@ if [ $NTPQV = "p1" ]; then fi VER=$($BIN_NTPD --version 2>&1 | head -n 1) -if [[ "$VER" == *"4.2.6p5"* ]]; then +if [ "$VER" == *"4.2.6p5"* ]; then USECMD=$(echo "$BIN_NTPDC" -c iostats 127.0.0.1) else USECMD=$(echo "$BIN_NTPQ" -c iostats 127.0.0.1) From d0278e8560d82413d913c5e4698c705438732163 Mon Sep 17 00:00:00 2001 From: "Zane C. Bowers-Hadley" Date: Wed, 20 Oct 2021 14:49:26 -0500 Subject: [PATCH 3/4] now happy on both linux and freebsd for ntpd --version output --- snmp/ntp-server.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snmp/ntp-server.sh b/snmp/ntp-server.sh index b3b78fb..b59f6c7 100755 --- a/snmp/ntp-server.sh +++ b/snmp/ntp-server.sh @@ -69,8 +69,8 @@ if [ $NTPQV = "p1" ]; then CLK_WANDER=$(echo $NTPQ_RAW | $BIN_AWK -F ' ' '{print $6}') fi -VER=$($BIN_NTPD --version 2>&1 | head -n 1) -if [ "$VER" == *"4.2.6p5"* ]; then +VER=$($BIN_NTPD --version 2>&1 | cut -d\ -f 2 | head -n 1) +if [ "$VER" == "4.2.6p5" ]; then USECMD=$(echo "$BIN_NTPDC" -c iostats 127.0.0.1) else USECMD=$(echo "$BIN_NTPQ" -c iostats 127.0.0.1) From d8edd140ce91a4b158b4dbcd7348759141c81b73 Mon Sep 17 00:00:00 2001 From: "Zane C. Bowers-Hadley" Date: Wed, 20 Oct 2021 14:53:40 -0500 Subject: [PATCH 4/4] pet the linter and hope everything is POSIX happy now.... works on freebsd and linux though --- snmp/ntp-server.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snmp/ntp-server.sh b/snmp/ntp-server.sh index b59f6c7..4fb02e8 100755 --- a/snmp/ntp-server.sh +++ b/snmp/ntp-server.sh @@ -70,7 +70,7 @@ if [ $NTPQV = "p1" ]; then fi VER=$($BIN_NTPD --version 2>&1 | cut -d\ -f 2 | head -n 1) -if [ "$VER" == "4.2.6p5" ]; then +if [ "$VER" = "4.2.6p5" ]; then USECMD=$(echo "$BIN_NTPDC" -c iostats 127.0.0.1) else USECMD=$(echo "$BIN_NTPQ" -c iostats 127.0.0.1)