shellcheck manual fixes (#4)
This commit is contained in:
parent
13e8b15ba3
commit
07c0c7a04d
4 changed files with 19 additions and 15 deletions
|
@ -9,7 +9,7 @@ then
|
|||
return 0
|
||||
fi
|
||||
|
||||
errorOutput=$(echo "gemini://$1/" | ${TLS_CLIENT} $1 2>&1 > /dev/null)
|
||||
errorOutput=$(echo "gemini://$1/" | ${TLS_CLIENT} "$1" 2>&1 > /dev/null)
|
||||
errorCode=$?
|
||||
|
||||
if [ $errorCode -gt 0 ]
|
||||
|
|
|
@ -25,6 +25,9 @@ while getopts "hF:C:W:" opt; do
|
|||
F)
|
||||
file=$OPTARG
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 [-h] [-w <warning> (default: $warning)] [-c <critical> (default: $critical) -F <filename>]"
|
||||
exit 3
|
||||
esac
|
||||
done
|
||||
|
||||
|
@ -32,13 +35,13 @@ shift $((OPTIND-1))
|
|||
|
||||
[ "$1" = "--" ] && shift
|
||||
|
||||
if [ -z ${file} ]
|
||||
if [ -z "${file}" ]
|
||||
then
|
||||
echo "ERROR: please provide filename to parse with $0 -F <filename>"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
lastdate=$(tail -2 ${file} | grep -o -E '^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2} [[:digit:]]{2}:[[:digit:]]{2}:[[:digit:]]{2}')
|
||||
lastdate=$(tail -2 "${file}" | grep -o -E '^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2} [[:digit:]]{2}:[[:digit:]]{2}:[[:digit:]]{2}')
|
||||
lastts=$(date -d "${lastdate}" +%s)
|
||||
currentts=$(date +%s)
|
||||
|
||||
|
@ -50,13 +53,13 @@ else
|
|||
exit 3
|
||||
fi
|
||||
|
||||
message=$(echo "${file} not updated since ${delay} seconds")
|
||||
message="${file} not updated since ${delay} seconds"
|
||||
|
||||
if [ ${delay} -gt ${critical} ]
|
||||
if [ "${delay}" -gt "${critical}" ]
|
||||
then
|
||||
echo "CRITICAL: ${message}"
|
||||
exit 2
|
||||
elif [ ${delay} -gt ${warning} ]
|
||||
elif [ "${delay}" -gt "${warning}" ]
|
||||
then
|
||||
echo "WARNING: ${message}"
|
||||
exit 1
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#!/bin/sh
|
||||
|
||||
# check postgresql (streaming) replication
|
||||
# tested with postgresql 11.3 on FreeBSD 11.2
|
||||
#
|
||||
|
@ -6,15 +7,15 @@
|
|||
# warning (-w) and critical (-c) thresholds can be set in seconds
|
||||
# on a low trafic server don't hesitate to set them to a high value
|
||||
|
||||
args=`getopt hw:c: $*`
|
||||
set -- $args
|
||||
args=$(getopt hw:c: "$*")
|
||||
set -- "$args"
|
||||
|
||||
warning=600
|
||||
critical=3600
|
||||
|
||||
while :; do
|
||||
case "$1" in
|
||||
-h) echo "Usage: $0 [-h] [-w <warning> (default: $warning)] [-c <critical> (default: $critical)]"
|
||||
-h) echo "Usage $0: [-h] [-w warning (default: $warning)] [-c critical (default: $critical)]"
|
||||
shift;
|
||||
exit 2;
|
||||
;;
|
||||
|
@ -30,13 +31,13 @@ while :; do
|
|||
esac
|
||||
done
|
||||
|
||||
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 }'`
|
||||
delay=$(/usr/local/bin/psql --port=6432 --username=postgres --pset="expanded=yes" --command="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 }')
|
||||
|
||||
if [ $delay -gt $critical ]
|
||||
if [ "$delay" -gt "$critical" ]
|
||||
then
|
||||
echo "CRITICAL: $delay seconds behind master"
|
||||
exit 2
|
||||
elif [ $delay -gt $warning ]
|
||||
elif [ "$delay" -gt "$warning" ]
|
||||
then
|
||||
echo "WARNING: $delay seconds behind master"
|
||||
exit 1
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
HOSTNAME="${COLLECTD_HOSTNAME:-`hostname -f`}"
|
||||
HOSTNAME="${COLLECTD_HOSTNAME:-$(hostname -f)}"
|
||||
INTERVAL="${COLLECTD_INTERVAL:-300}"
|
||||
FILE="/home/weather/tmp/openweathermap.json"
|
||||
|
||||
|
@ -9,8 +9,8 @@ FILE="/home/weather/tmp/openweathermap.json"
|
|||
|
||||
while sleep "$INTERVAL"; do
|
||||
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
|
||||
key=`echo ${field} | sed 's/\./-/g' | sed 's/"//g'`
|
||||
echo "PUTVAL $HOSTNAME/weather/gauge-${key} interval=$INTERVAL N:`jq .${field} $FILE | sed s/null/0/g`" ;
|
||||
key=$(echo "$field" | sed 's/\./-/g' | sed 's/"//g')
|
||||
echo "PUTVAL $HOSTNAME/weather/gauge-${key} interval=$INTERVAL N:$(jq ."$field" $FILE | sed s/null/0/g)" ;
|
||||
done
|
||||
done
|
||||
|
||||
|
|
Loading…
Reference in a new issue