reworked log and logError for pipes
This commit is contained in:
25
inc/sensor-scripts/speedtest.sh
Normal file
25
inc/sensor-scripts/speedtest.sh
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Usage: doSpeedtest [<interface>] [<speedtest-server-id>]
|
||||
function doSpeedtest {
|
||||
if ! [ "${1}" = "" ]; then
|
||||
INTERFACE=${1}
|
||||
INTERFACE_ARG="-I ${INTERFACE}"
|
||||
INTERFACE_TEXT=" from NIC '${INTERFACE}'"
|
||||
fi
|
||||
|
||||
if ! [ "${2}" = "" ]; then
|
||||
SERVER_ID=${2}
|
||||
SERVER_ARG="-s ${SERVER_ID}"
|
||||
SERVER_ID_TEXT=" to server ${SERVER_ID}"
|
||||
fi
|
||||
|
||||
logScript "Doing internet speedtest${INTERFACE_TEXT}${SERVER_ID_TEXT}"
|
||||
|
||||
if ! OUT=$(speedtest -f json); then
|
||||
logError "Speedtest failed"
|
||||
logError "${OUT}"
|
||||
else
|
||||
echo
|
||||
fi
|
||||
}
|
||||
Reference in New Issue
Block a user