From a2df1e2c4ed5350b9ea4b7073ba5fc01370ef164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Thu, 4 Jun 2020 16:39:50 +0200 Subject: [PATCH] Avoid to count pending jobs in queue state command --- cluster/disable.host.queue.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/cluster/disable.host.queue.sh b/cluster/disable.host.queue.sh index de01012..06a7298 100755 --- a/cluster/disable.host.queue.sh +++ b/cluster/disable.host.queue.sh @@ -65,9 +65,11 @@ is_queue_enable() { # {{{ local_sge_hostname="${1}" local_sge_queue_name="${2}" - ## List all available queues and filter according to both 'disable' state and the expected queue name + ## List all queues with 'disable' state and filter to the expected queue name + ### Then count the number of lines between "queuename" (from header) and the expected queue + ### To avoid to count pending jobs for this queue local_sge_queue_test=$(qstat -f -qs d -q "${local_sge_queue_name:=/dev/null}@${local_sge_hostname:=/dev/null}" \ - | wc -l) + | awk 'BEGIN {count = 0} /queuename/,/main.q/ {count++} END { print count }') case "${local_sge_queue_test}" in 0 ) ## No result so the queue is enable @@ -79,7 +81,7 @@ is_queue_enable() { # {{{ return_queue_enable="1" ;; * ) ## Unexpected result - printf '%b\n' "${RED}Not able to determine the state of ${local_sge_queue_name:=/dev/null}@${local_sge_hostname:=/dev/null} queue.${RESET}" + printf '%b\n' "${RED}Not able to determine the state of ${local_sge_queue_name:=/dev/null}@${local_sge_hostname:=/dev/null} queue (command return ${local_sge_queue_test} lines).${RESET}" exit 2 ;; esac @@ -97,9 +99,11 @@ is_queue_disable() { # {{{ local_sge_hostname="${1}" local_sge_queue_name="${2}" - ## List all available queues and filter according to both 'disable' state and the expected queue name + ## List all queues with 'disable' state and filter to the expected queue name + ### Then count the number of lines between "queuename" (from header) and the expected queue + ### To avoid to count pending jobs for this queue local_sge_queue_test=$(qstat -f -qs d -q "${local_sge_queue_name:=/dev/null}@${local_sge_hostname:=/dev/null}" \ - | wc -l) + | awk 'BEGIN {count = 0} /queuename/,/main.q/ {count++} END { print count }') case "${local_sge_queue_test}" in 0 ) ## No result so the queue is enable @@ -111,7 +115,7 @@ is_queue_disable() { # {{{ return_queue_disable="0" ;; * ) ## Unexpected result - printf '%b\n' "${RED}Not able to determine the state of ${local_sge_queue_name:=/dev/null}@${local_sge_hostname:=/dev/null} queue.${RESET}" + printf '%b\n' "${RED}Not able to determine the state of ${local_sge_queue_name:=/dev/null}@${local_sge_hostname:=/dev/null} queue (command return ${local_sge_queue_test} lines).${RESET}" exit 3 ;; esac