shellcheck monitoring scripts #4
n
commented 2023-10-18 23:52:56 +02:00
Owner
```
In monitoring/check_gemini.sh line 12:
errorOutput=$(echo "gemini://$1/" | ${TLS_CLIENT} $1 2>&1 > /dev/null)
^-- SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
errorOutput=$(echo "gemini://$1/" | ${TLS_CLIENT} "$1" 2>&1 > /dev/null)
In monitoring/check_lastdate.sh line 14:
case "$opt" in
^-- SC2220 (warning): Invalid flags are not handled. Add a *) case.
In monitoring/check_lastdate.sh line 35:
if [ -z ${file} ]
^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
if [ -z "${file}" ]
In monitoring/check_lastdate.sh line 41:
lastdate=$(tail -2 ${file} | grep -o -E '^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2} [[:digit:]]{2}:[[:digit:]]{2}:[[:digit:]]{2}')
^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
lastdate=$(tail -2 "${file}" | grep -o -E '^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2} [[:digit:]]{2}:[[:digit:]]{2}:[[:digit:]]{2}')
In monitoring/check_lastdate.sh line 53:
message=$(echo "${file} not updated since ${delay} seconds")
^-- SC2116 (style): Useless echo? Instead of 'cmd $(echo foo)', just use 'cmd foo'.
In monitoring/check_lastdate.sh line 55:
if [ ${delay} -gt ${critical} ]
^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
if [ "${delay}" -gt "${critical}" ]
In monitoring/check_lastdate.sh line 59:
elif [ ${delay} -gt ${warning} ]
^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
elif [ "${delay}" -gt "${warning}" ]
In monitoring/check_postgresql_replication.sh line 9:
args=`getopt hw:c: $*`
^---------------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.
^-- SC2048 (warning): Use "$@" (with quotes) to prevent whitespace problems.
^-- SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
args=$(getopt hw:c: "$*")
In monitoring/check_postgresql_replication.sh line 10:
set -- $args
^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
set -- "$args"
In monitoring/check_postgresql_replication.sh line 33:
delay=`/usr/local/bin/psql -U postgres --pset expanded=yes -c "select now() - pg_last_xact_replay_timestamp() AS replication_delay;" | tail -2 | head -1 | cut -d '|' -f 2 | cut -d ' ' -f 2 | cut -d '.' -f 1 | awk -F: '{ print ($1 * 3600) + ($2 * 60) + $3 }'`
^-- SC2006 (style): Use $(...) notation instead of legacy backticks `...`.
Did you mean:
delay=$(/usr/local/bin/psql -U postgres --pset expanded=yes -c "select now() - pg_last_xact_replay_timestamp() AS replication_delay;" | tail -2 | head -1 | cut -d '|' -f 2 | cut -d ' ' -f 2 | cut -d '.' -f 1 | awk -F: '{ print ($1 * 3600) + ($2 * 60) + $3 }')
In monitoring/check_postgresql_replication.sh line 35:
if [ $delay -gt $critical ]
^----^ SC2086 (info): Double quote to prevent globbing and word splitting.
^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
if [ "$delay" -gt "$critical" ]
In monitoring/check_postgresql_replication.sh line 39:
elif [ $delay -gt $warning ]
^----^ SC2086 (info): Double quote to prevent globbing and word splitting.
^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
elif [ "$delay" -gt "$warning" ]
In monitoring/collectweather.sh line 3:
HOSTNAME="${COLLECTD_HOSTNAME:-`hostname -f`}"
^-----------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.
Did you mean:
HOSTNAME="${COLLECTD_HOSTNAME:-$(hostname -f)}"
In monitoring/collectweather.sh line 11:
for field in main.temp main.feels_like main.pressure main.humidity wind.speed wind.gust clouds.all rain.\"1h\" rain.\"3h\" snow.\"1h\" snow.\"3h\" sys.sunrise sys.sunset visibility;do
^---------^ SC2089 (warning): Quotes/backslashes will be treated literally. Rewrite using set/"$@" or functions.
In monitoring/collectweather.sh line 12:
key=`echo ${field} | sed 's/\./-/g' | sed 's/"//g'`
^-- SC2006 (style): Use $(...) notation instead of legacy backticks `...`.
^------^ SC2090 (warning): Quotes/backslashes in this variable will not be respected.
Did you mean:
key=$(echo ${field} | sed 's/\./-/g' | sed 's/"//g')
In monitoring/collectweather.sh line 13:
echo "PUTVAL $HOSTNAME/weather/gauge-${key} interval=$INTERVAL N:`jq .${field} $FILE | sed s/null/0/g`" ;
^-- SC2006 (style): Use $(...) notation instead of legacy backticks `...`.
^------^ SC2090 (warning): Quotes/backslashes in this variable will not be respected.
Did you mean:
echo "PUTVAL $HOSTNAME/weather/gauge-${key} interval=$INTERVAL N:$(jq .${field} $FILE | sed s/null/0/g)" ;
For more information:
https://www.shellcheck.net/wiki/SC2048 -- Use "$@" (with quotes) to prevent...
https://www.shellcheck.net/wiki/SC2089 -- Quotes/backslashes will be treate...
https://www.shellcheck.net/wiki/SC2090 -- Quotes/backslashes in this variab...
✘ n@lappy ~/git/scripts main shellcheck *.sh monitoring/*.sh
In monitoring/check_gemini.sh line 12:
errorOutput=$(echo "gemini://$1/" | ${TLS_CLIENT} $1 2>&1 > /dev/null)
^-- SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
errorOutput=$(echo "gemini://$1/" | ${TLS_CLIENT} "$1" 2>&1 > /dev/null)
In monitoring/check_lastdate.sh line 14:
case "$opt" in
^-- SC2220 (warning): Invalid flags are not handled. Add a *) case.
In monitoring/check_lastdate.sh line 35:
if [ -z ${file} ]
^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
if [ -z "${file}" ]
In monitoring/check_lastdate.sh line 41:
lastdate=$(tail -2 ${file} | grep -o -E '^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2} [[:digit:]]{2}:[[:digit:]]{2}:[[:digit:]]{2}')
^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
lastdate=$(tail -2 "${file}" | grep -o -E '^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2} [[:digit:]]{2}:[[:digit:]]{2}:[[:digit:]]{2}')
In monitoring/check_lastdate.sh line 53:
message=$(echo "${file} not updated since ${delay} seconds")
^-- SC2116 (style): Useless echo? Instead of 'cmd $(echo foo)', just use 'cmd foo'.
In monitoring/check_lastdate.sh line 55:
if [ ${delay} -gt ${critical} ]
^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
if [ "${delay}" -gt "${critical}" ]
In monitoring/check_lastdate.sh line 59:
elif [ ${delay} -gt ${warning} ]
^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
elif [ "${delay}" -gt "${warning}" ]
In monitoring/check_postgresql_replication.sh line 9:
args=`getopt hw:c: $*`
^---------------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.
^-- SC2048 (warning): Use "$@" (with quotes) to prevent whitespace problems.
^-- SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
args=$(getopt hw:c: "$*")
In monitoring/check_postgresql_replication.sh line 10:
set -- $args
^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
set -- "$args"
In monitoring/check_postgresql_replication.sh line 33:
delay=`/usr/local/bin/psql -U postgres --pset expanded=yes -c "select now() - pg_last_xact_replay_timestamp() AS replication_delay;" | tail -2 | head -1 | cut -d '|' -f 2 | cut -d ' ' -f 2 | cut -d '.' -f 1 | awk -F: '{ print ($1 * 3600) + ($2 * 60) + $3 }'`
^-- SC2006 (style): Use $(...) notation instead of legacy backticks `...`.
Did you mean:
delay=$(/usr/local/bin/psql -U postgres --pset expanded=yes -c "select now() - pg_last_xact_replay_timestamp() AS replication_delay;" | tail -2 | head -1 | cut -d '|' -f 2 | cut -d ' ' -f 2 | cut -d '.' -f 1 | awk -F: '{ print ($1 * 3600) + ($2 * 60) + $3 }')
In monitoring/check_postgresql_replication.sh line 35:
if [ $delay -gt $critical ]
^----^ SC2086 (info): Double quote to prevent globbing and word splitting.
^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
if [ "$delay" -gt "$critical" ]
In monitoring/check_postgresql_replication.sh line 39:
elif [ $delay -gt $warning ]
^----^ SC2086 (info): Double quote to prevent globbing and word splitting.
^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
elif [ "$delay" -gt "$warning" ]
In monitoring/collectweather.sh line 3:
HOSTNAME="${COLLECTD_HOSTNAME:-`hostname -f`}"
^-----------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.
Did you mean:
HOSTNAME="${COLLECTD_HOSTNAME:-$(hostname -f)}"
In monitoring/collectweather.sh line 11:
for field in main.temp main.feels_like main.pressure main.humidity wind.speed wind.gust clouds.all rain.\"1h\" rain.\"3h\" snow.\"1h\" snow.\"3h\" sys.sunrise sys.sunset visibility;do
^---------^ SC2089 (warning): Quotes/backslashes will be treated literally. Rewrite using set/"$@" or functions.
In monitoring/collectweather.sh line 12:
key=`echo ${field} | sed 's/\./-/g' | sed 's/"//g'`
^-- SC2006 (style): Use $(...) notation instead of legacy backticks `...`.
^------^ SC2090 (warning): Quotes/backslashes in this variable will not be respected.
Did you mean:
key=$(echo ${field} | sed 's/\./-/g' | sed 's/"//g')
In monitoring/collectweather.sh line 13:
echo "PUTVAL $HOSTNAME/weather/gauge-${key} interval=$INTERVAL N:`jq .${field} $FILE | sed s/null/0/g`" ;
^-- SC2006 (style): Use $(...) notation instead of legacy backticks `...`.
^------^ SC2090 (warning): Quotes/backslashes in this variable will not be respected.
Did you mean:
echo "PUTVAL $HOSTNAME/weather/gauge-${key} interval=$INTERVAL N:$(jq .${field} $FILE | sed s/null/0/g)" ;
For more information:
https://www.shellcheck.net/wiki/SC2048 -- Use "$@" (with quotes) to prevent...
https://www.shellcheck.net/wiki/SC2089 -- Quotes/backslashes will be treate...
https://www.shellcheck.net/wiki/SC2090 -- Quotes/backslashes in this variab...
```
n
referenced this issue from a commit 2023-10-19 17:53:57 +02:00
shellcheck manual fixes (#4)
n
referenced this issue from a pull request that will close it, 2023-10-19 17:56:51 +02:00
shellcheck monitoring scripts #6
n
referenced this issue from a pull request that will close it, 2023-10-19 18:00:47 +02:00
shellcheck manual fixes (#4) #7
n
closed this issue 2023-10-19 18:01:33 +02:00
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?