From 69528790a5815220068463f9b7848df1158e9a03 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Thu, 28 Jul 2016 13:25:31 -0700 Subject: [PATCH] check_worker_memory: Fix handling of no queue workers running. --- .../zulip_app_frontend/check_worker_memory | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_worker_memory b/puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_worker_memory index d5e1057429..a10335d34d 100755 --- a/puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_worker_memory +++ b/puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_worker_memory @@ -1,7 +1,15 @@ #!/bin/bash # Checks for any Zulip queue workers that are leaking memory and thus have a high vsize datafile=$(mktemp) -ps -o vsize,size,pid,user,command --sort -vsize $(pgrep -f '^python.* /home/zulip/deployments/current/manage.py process_queue') > "$datafile" + +# We expect other Nagios checks to monitor for whether no queue +# workers are running, so we give that condition a pass +processes=$(pgrep -f '^python.* /home/zulip/deployments/current/manage.py process_queue') +if [ -z "$processes" ]; then + echo "No workers running" + exit 0 +fi +ps -o vsize,size,pid,user,command --sort -vsize $processes > "$datafile" cat "$datafile" top_worker=$(cat "$datafile" | head -n2 | tail -n1) top_worker_memory_usage=$(echo "$top_worker" | cut -f1 -d" ")