From 8011113ab06e4fe767fcb2e561d1a7655df8e755 Mon Sep 17 00:00:00 2001 From: Joan Date: Mon, 28 Oct 2024 11:15:22 +0100 Subject: [PATCH 1/2] Follow shellcheck recommendations on script --- .../6.0/record_speedtest.sh | 32 +++++++++---------- .../6.2/record_speedtest.sh | 32 +++++++++---------- .../6.4/record_speedtest.sh | 32 +++++++++---------- .../7.0/record_speedtest.sh | 32 +++++++++---------- 4 files changed, 64 insertions(+), 64 deletions(-) diff --git a/Applications/Template_App_Speedtest_Wan/6.0/record_speedtest.sh b/Applications/Template_App_Speedtest_Wan/6.0/record_speedtest.sh index 091a5f654..ba663dee2 100755 --- a/Applications/Template_App_Speedtest_Wan/6.0/record_speedtest.sh +++ b/Applications/Template_App_Speedtest_Wan/6.0/record_speedtest.sh @@ -38,9 +38,9 @@ test -z "$EGREP" && echo "egrep binary not found" && exit test -z "$RM" && echo "rm binary not found" && exit if [ "$($SPEEDTEST -V | $EGREP -c 'Speedtest by Ookla')" -lt 1 ];then - echo "The speedtest binary needs to be from Ookla." - echo "Please visit https://www.speedtest.net/apps/cli" - exit + echo "The speedtest binary needs to be from Ookla." + echo "Please visit https://www.speedtest.net/apps/cli" + exit fi # Temporary speedtest output @@ -49,22 +49,22 @@ OUTFILE=$($MKTEMP) # what time is it? NOW=$($DATE +%s) -$TIMEOUT $TIMEOUTTIME $SPEEDTEST $SPEEDTESTPARAMS -f json 2>/dev/null > $OUTFILE -if [ $($STAT -c %s $OUTFILE) -le 100 ];then - echo "ERROR running speedtest - output file too small - $OUTFILE" - echo "You may want to try running $SPEEDTEST -f json manually" - echo "and/or checking the contents of $OUTFILE" - exit +"$TIMEOUT" "$TIMEOUTTIME" "$SPEEDTEST" "$SPEEDTESTPARAMS" -f json 2>/dev/null > "$OUTFILE" +if [ "$($STAT -c %s "$OUTFILE")" -le 100 ];then + echo "ERROR running speedtest - output file too small - $OUTFILE" + echo "You may want to try running $SPEEDTEST -f json manually" + echo "and/or checking the contents of $OUTFILE" + exit fi -F="$($CAT $OUTFILE)" +F="$($CAT "$OUTFILE")" # do we have PSKID and PSKFILE? -if [ -f "$PSKFILE" -a -n "$PSKID" ];then - $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 - $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 +if [ -f "$PSKFILE" ] && [ -n "$PSKID" ];then + $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 + $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 else - $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 - $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 + $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 + $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 fi -$RM -f $OUTFILE +$RM -f "$OUTFILE" \ No newline at end of file diff --git a/Applications/Template_App_Speedtest_Wan/6.2/record_speedtest.sh b/Applications/Template_App_Speedtest_Wan/6.2/record_speedtest.sh index 091a5f654..ba663dee2 100755 --- a/Applications/Template_App_Speedtest_Wan/6.2/record_speedtest.sh +++ b/Applications/Template_App_Speedtest_Wan/6.2/record_speedtest.sh @@ -38,9 +38,9 @@ test -z "$EGREP" && echo "egrep binary not found" && exit test -z "$RM" && echo "rm binary not found" && exit if [ "$($SPEEDTEST -V | $EGREP -c 'Speedtest by Ookla')" -lt 1 ];then - echo "The speedtest binary needs to be from Ookla." - echo "Please visit https://www.speedtest.net/apps/cli" - exit + echo "The speedtest binary needs to be from Ookla." + echo "Please visit https://www.speedtest.net/apps/cli" + exit fi # Temporary speedtest output @@ -49,22 +49,22 @@ OUTFILE=$($MKTEMP) # what time is it? NOW=$($DATE +%s) -$TIMEOUT $TIMEOUTTIME $SPEEDTEST $SPEEDTESTPARAMS -f json 2>/dev/null > $OUTFILE -if [ $($STAT -c %s $OUTFILE) -le 100 ];then - echo "ERROR running speedtest - output file too small - $OUTFILE" - echo "You may want to try running $SPEEDTEST -f json manually" - echo "and/or checking the contents of $OUTFILE" - exit +"$TIMEOUT" "$TIMEOUTTIME" "$SPEEDTEST" "$SPEEDTESTPARAMS" -f json 2>/dev/null > "$OUTFILE" +if [ "$($STAT -c %s "$OUTFILE")" -le 100 ];then + echo "ERROR running speedtest - output file too small - $OUTFILE" + echo "You may want to try running $SPEEDTEST -f json manually" + echo "and/or checking the contents of $OUTFILE" + exit fi -F="$($CAT $OUTFILE)" +F="$($CAT "$OUTFILE")" # do we have PSKID and PSKFILE? -if [ -f "$PSKFILE" -a -n "$PSKID" ];then - $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 - $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 +if [ -f "$PSKFILE" ] && [ -n "$PSKID" ];then + $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 + $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 else - $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 - $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 + $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 + $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 fi -$RM -f $OUTFILE +$RM -f "$OUTFILE" \ No newline at end of file diff --git a/Applications/Template_App_Speedtest_Wan/6.4/record_speedtest.sh b/Applications/Template_App_Speedtest_Wan/6.4/record_speedtest.sh index 091a5f654..ba663dee2 100755 --- a/Applications/Template_App_Speedtest_Wan/6.4/record_speedtest.sh +++ b/Applications/Template_App_Speedtest_Wan/6.4/record_speedtest.sh @@ -38,9 +38,9 @@ test -z "$EGREP" && echo "egrep binary not found" && exit test -z "$RM" && echo "rm binary not found" && exit if [ "$($SPEEDTEST -V | $EGREP -c 'Speedtest by Ookla')" -lt 1 ];then - echo "The speedtest binary needs to be from Ookla." - echo "Please visit https://www.speedtest.net/apps/cli" - exit + echo "The speedtest binary needs to be from Ookla." + echo "Please visit https://www.speedtest.net/apps/cli" + exit fi # Temporary speedtest output @@ -49,22 +49,22 @@ OUTFILE=$($MKTEMP) # what time is it? NOW=$($DATE +%s) -$TIMEOUT $TIMEOUTTIME $SPEEDTEST $SPEEDTESTPARAMS -f json 2>/dev/null > $OUTFILE -if [ $($STAT -c %s $OUTFILE) -le 100 ];then - echo "ERROR running speedtest - output file too small - $OUTFILE" - echo "You may want to try running $SPEEDTEST -f json manually" - echo "and/or checking the contents of $OUTFILE" - exit +"$TIMEOUT" "$TIMEOUTTIME" "$SPEEDTEST" "$SPEEDTESTPARAMS" -f json 2>/dev/null > "$OUTFILE" +if [ "$($STAT -c %s "$OUTFILE")" -le 100 ];then + echo "ERROR running speedtest - output file too small - $OUTFILE" + echo "You may want to try running $SPEEDTEST -f json manually" + echo "and/or checking the contents of $OUTFILE" + exit fi -F="$($CAT $OUTFILE)" +F="$($CAT "$OUTFILE")" # do we have PSKID and PSKFILE? -if [ -f "$PSKFILE" -a -n "$PSKID" ];then - $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 - $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 +if [ -f "$PSKFILE" ] && [ -n "$PSKID" ];then + $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 + $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 else - $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 - $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 + $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 + $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 fi -$RM -f $OUTFILE +$RM -f "$OUTFILE" \ No newline at end of file diff --git a/Applications/Template_App_Speedtest_Wan/7.0/record_speedtest.sh b/Applications/Template_App_Speedtest_Wan/7.0/record_speedtest.sh index 091a5f654..ba663dee2 100755 --- a/Applications/Template_App_Speedtest_Wan/7.0/record_speedtest.sh +++ b/Applications/Template_App_Speedtest_Wan/7.0/record_speedtest.sh @@ -38,9 +38,9 @@ test -z "$EGREP" && echo "egrep binary not found" && exit test -z "$RM" && echo "rm binary not found" && exit if [ "$($SPEEDTEST -V | $EGREP -c 'Speedtest by Ookla')" -lt 1 ];then - echo "The speedtest binary needs to be from Ookla." - echo "Please visit https://www.speedtest.net/apps/cli" - exit + echo "The speedtest binary needs to be from Ookla." + echo "Please visit https://www.speedtest.net/apps/cli" + exit fi # Temporary speedtest output @@ -49,22 +49,22 @@ OUTFILE=$($MKTEMP) # what time is it? NOW=$($DATE +%s) -$TIMEOUT $TIMEOUTTIME $SPEEDTEST $SPEEDTESTPARAMS -f json 2>/dev/null > $OUTFILE -if [ $($STAT -c %s $OUTFILE) -le 100 ];then - echo "ERROR running speedtest - output file too small - $OUTFILE" - echo "You may want to try running $SPEEDTEST -f json manually" - echo "and/or checking the contents of $OUTFILE" - exit +"$TIMEOUT" "$TIMEOUTTIME" "$SPEEDTEST" "$SPEEDTESTPARAMS" -f json 2>/dev/null > "$OUTFILE" +if [ "$($STAT -c %s "$OUTFILE")" -le 100 ];then + echo "ERROR running speedtest - output file too small - $OUTFILE" + echo "You may want to try running $SPEEDTEST -f json manually" + echo "and/or checking the contents of $OUTFILE" + exit fi -F="$($CAT $OUTFILE)" +F="$($CAT "$OUTFILE")" # do we have PSKID and PSKFILE? -if [ -f "$PSKFILE" -a -n "$PSKID" ];then - $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 - $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 +if [ -f "$PSKFILE" ] && [ -n "$PSKID" ];then + $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 + $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 else - $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 - $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 + $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 + $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 fi -$RM -f $OUTFILE +$RM -f "$OUTFILE" \ No newline at end of file From d521176fb0afc9a19e9c5a6c063a5d5afd5716e0 Mon Sep 17 00:00:00 2001 From: Joan Date: Mon, 28 Oct 2024 11:17:49 +0100 Subject: [PATCH 2/2] fix whitespace --- .../6.0/record_speedtest.sh | 22 +++++++++---------- .../6.2/record_speedtest.sh | 22 +++++++++---------- .../6.4/record_speedtest.sh | 22 +++++++++---------- .../7.0/record_speedtest.sh | 22 +++++++++---------- 4 files changed, 44 insertions(+), 44 deletions(-) diff --git a/Applications/Template_App_Speedtest_Wan/6.0/record_speedtest.sh b/Applications/Template_App_Speedtest_Wan/6.0/record_speedtest.sh index ba663dee2..23acce79c 100755 --- a/Applications/Template_App_Speedtest_Wan/6.0/record_speedtest.sh +++ b/Applications/Template_App_Speedtest_Wan/6.0/record_speedtest.sh @@ -38,9 +38,9 @@ test -z "$EGREP" && echo "egrep binary not found" && exit test -z "$RM" && echo "rm binary not found" && exit if [ "$($SPEEDTEST -V | $EGREP -c 'Speedtest by Ookla')" -lt 1 ];then - echo "The speedtest binary needs to be from Ookla." - echo "Please visit https://www.speedtest.net/apps/cli" - exit + echo "The speedtest binary needs to be from Ookla." + echo "Please visit https://www.speedtest.net/apps/cli" + exit fi # Temporary speedtest output @@ -51,20 +51,20 @@ NOW=$($DATE +%s) "$TIMEOUT" "$TIMEOUTTIME" "$SPEEDTEST" "$SPEEDTESTPARAMS" -f json 2>/dev/null > "$OUTFILE" if [ "$($STAT -c %s "$OUTFILE")" -le 100 ];then - echo "ERROR running speedtest - output file too small - $OUTFILE" - echo "You may want to try running $SPEEDTEST -f json manually" - echo "and/or checking the contents of $OUTFILE" - exit + echo "ERROR running speedtest - output file too small - $OUTFILE" + echo "You may want to try running $SPEEDTEST -f json manually" + echo "and/or checking the contents of $OUTFILE" + exit fi F="$($CAT "$OUTFILE")" # do we have PSKID and PSKFILE? if [ -f "$PSKFILE" ] && [ -n "$PSKID" ];then - $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 - $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 + $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 + $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 else - $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 - $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 + $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 + $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 fi $RM -f "$OUTFILE" \ No newline at end of file diff --git a/Applications/Template_App_Speedtest_Wan/6.2/record_speedtest.sh b/Applications/Template_App_Speedtest_Wan/6.2/record_speedtest.sh index ba663dee2..23acce79c 100755 --- a/Applications/Template_App_Speedtest_Wan/6.2/record_speedtest.sh +++ b/Applications/Template_App_Speedtest_Wan/6.2/record_speedtest.sh @@ -38,9 +38,9 @@ test -z "$EGREP" && echo "egrep binary not found" && exit test -z "$RM" && echo "rm binary not found" && exit if [ "$($SPEEDTEST -V | $EGREP -c 'Speedtest by Ookla')" -lt 1 ];then - echo "The speedtest binary needs to be from Ookla." - echo "Please visit https://www.speedtest.net/apps/cli" - exit + echo "The speedtest binary needs to be from Ookla." + echo "Please visit https://www.speedtest.net/apps/cli" + exit fi # Temporary speedtest output @@ -51,20 +51,20 @@ NOW=$($DATE +%s) "$TIMEOUT" "$TIMEOUTTIME" "$SPEEDTEST" "$SPEEDTESTPARAMS" -f json 2>/dev/null > "$OUTFILE" if [ "$($STAT -c %s "$OUTFILE")" -le 100 ];then - echo "ERROR running speedtest - output file too small - $OUTFILE" - echo "You may want to try running $SPEEDTEST -f json manually" - echo "and/or checking the contents of $OUTFILE" - exit + echo "ERROR running speedtest - output file too small - $OUTFILE" + echo "You may want to try running $SPEEDTEST -f json manually" + echo "and/or checking the contents of $OUTFILE" + exit fi F="$($CAT "$OUTFILE")" # do we have PSKID and PSKFILE? if [ -f "$PSKFILE" ] && [ -n "$PSKID" ];then - $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 - $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 + $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 + $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 else - $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 - $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 + $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 + $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 fi $RM -f "$OUTFILE" \ No newline at end of file diff --git a/Applications/Template_App_Speedtest_Wan/6.4/record_speedtest.sh b/Applications/Template_App_Speedtest_Wan/6.4/record_speedtest.sh index ba663dee2..23acce79c 100755 --- a/Applications/Template_App_Speedtest_Wan/6.4/record_speedtest.sh +++ b/Applications/Template_App_Speedtest_Wan/6.4/record_speedtest.sh @@ -38,9 +38,9 @@ test -z "$EGREP" && echo "egrep binary not found" && exit test -z "$RM" && echo "rm binary not found" && exit if [ "$($SPEEDTEST -V | $EGREP -c 'Speedtest by Ookla')" -lt 1 ];then - echo "The speedtest binary needs to be from Ookla." - echo "Please visit https://www.speedtest.net/apps/cli" - exit + echo "The speedtest binary needs to be from Ookla." + echo "Please visit https://www.speedtest.net/apps/cli" + exit fi # Temporary speedtest output @@ -51,20 +51,20 @@ NOW=$($DATE +%s) "$TIMEOUT" "$TIMEOUTTIME" "$SPEEDTEST" "$SPEEDTESTPARAMS" -f json 2>/dev/null > "$OUTFILE" if [ "$($STAT -c %s "$OUTFILE")" -le 100 ];then - echo "ERROR running speedtest - output file too small - $OUTFILE" - echo "You may want to try running $SPEEDTEST -f json manually" - echo "and/or checking the contents of $OUTFILE" - exit + echo "ERROR running speedtest - output file too small - $OUTFILE" + echo "You may want to try running $SPEEDTEST -f json manually" + echo "and/or checking the contents of $OUTFILE" + exit fi F="$($CAT "$OUTFILE")" # do we have PSKID and PSKFILE? if [ -f "$PSKFILE" ] && [ -n "$PSKID" ];then - $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 - $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 + $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 + $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 else - $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 - $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 + $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 + $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 fi $RM -f "$OUTFILE" \ No newline at end of file diff --git a/Applications/Template_App_Speedtest_Wan/7.0/record_speedtest.sh b/Applications/Template_App_Speedtest_Wan/7.0/record_speedtest.sh index ba663dee2..23acce79c 100755 --- a/Applications/Template_App_Speedtest_Wan/7.0/record_speedtest.sh +++ b/Applications/Template_App_Speedtest_Wan/7.0/record_speedtest.sh @@ -38,9 +38,9 @@ test -z "$EGREP" && echo "egrep binary not found" && exit test -z "$RM" && echo "rm binary not found" && exit if [ "$($SPEEDTEST -V | $EGREP -c 'Speedtest by Ookla')" -lt 1 ];then - echo "The speedtest binary needs to be from Ookla." - echo "Please visit https://www.speedtest.net/apps/cli" - exit + echo "The speedtest binary needs to be from Ookla." + echo "Please visit https://www.speedtest.net/apps/cli" + exit fi # Temporary speedtest output @@ -51,20 +51,20 @@ NOW=$($DATE +%s) "$TIMEOUT" "$TIMEOUTTIME" "$SPEEDTEST" "$SPEEDTESTPARAMS" -f json 2>/dev/null > "$OUTFILE" if [ "$($STAT -c %s "$OUTFILE")" -le 100 ];then - echo "ERROR running speedtest - output file too small - $OUTFILE" - echo "You may want to try running $SPEEDTEST -f json manually" - echo "and/or checking the contents of $OUTFILE" - exit + echo "ERROR running speedtest - output file too small - $OUTFILE" + echo "You may want to try running $SPEEDTEST -f json manually" + echo "and/or checking the contents of $OUTFILE" + exit fi F="$($CAT "$OUTFILE")" # do we have PSKID and PSKFILE? if [ -f "$PSKFILE" ] && [ -n "$PSKID" ];then - $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 - $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 + $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 + $ZABBIX_SENDER --tls-connect psk --tls-psk-identity "$PSKID" --tls-psk-file "$PSKFILE" -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 else - $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 - $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 + $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[runtime]" -o "$NOW" > /dev/null 2>&1 + $ZABBIX_SENDER -z "$ZABSRV" -s "$SPDHOST" -k "custom.speedtest[json]" -o "$F" > /dev/null 2>&1 fi $RM -f "$OUTFILE" \ No newline at end of file