Avoid to count pending jobs in queue state command

This commit is contained in:
Jeremy Gardais 2020-06-04 16:39:50 +02:00
parent 01dac009a0
commit a2df1e2c4e
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 10 additions and 6 deletions

View File

@ -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