check_worker_memory: Fix shellcheck warnings.

In puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_worker_memory line 12:
ps -o vsize,size,pid,user,command --sort -vsize $processes > "$datafile"
                                                ^-- SC2086: Double quote to prevent globbing and word splitting.

In puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_worker_memory line 14:
top_worker=$(cat "$datafile" | head -n2 | tail -n1)
                 ^-- SC2002: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
Anders Kaseorg 2018-08-03 00:14:44 +00:00 committed by Tim Abbott
parent eb4855b77b
commit d5bf4eed9a
1 changed files with 3 additions and 2 deletions

View File

@ -9,9 +9,10 @@ if [ -z "$processes" ]; then
echo "No workers running"
exit 0
fi
ps -o vsize,size,pid,user,command --sort -vsize $processes > "$datafile"
mapfile -t processes <<< "$processes"
ps -o vsize,size,pid,user,command --sort -vsize "${processes[@]}" > "$datafile"
cat "$datafile"
top_worker=$(cat "$datafile" | head -n2 | tail -n1)
top_worker=$(head -n2 "$datafile" | tail -n1)
top_worker_memory_usage=$(echo "$top_worker" | cut -f1 -d" ")
rm -f "$datafile"
if [ "$top_worker_memory_usage" -gt 800000 ]; then