From d79c9fe833257540361979cd638bc510fead7b44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Fri, 25 Sep 2020 11:36:12 +0200 Subject: [PATCH] Disable SGE queue if used slots is EMPTY --- cluster/apt.check.update.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/cluster/apt.check.update.sh b/cluster/apt.check.update.sh index 8f6b853..5150fbd 100755 --- a/cluster/apt.check.update.sh +++ b/cluster/apt.check.update.sh @@ -150,6 +150,28 @@ Used slots did not reach ${local_percentage}% of total slots: ${RED}${local_sge_ return "${return_sge_slots_percentage}" +} +# }}} +is_sge_slots_empty() { # {{{ + + ## Get the number of SGE used slots + local_sge_slots_used=$(qhost -h "${sge_hostname:=/dev/null}" -q -xml \ + | grep --max-count=1 -- "'slots_used'" \ + | sed 's;.*\(.*\);\1;') + + if [ "${local_sge_slots_used}" -eq "0" ]; then + ## Used slots is null + return_sge_slots_empty="0" + else + return_sge_slots_empty="1" + fi + + ## Simple debug message to valid current variable + debug_message "is_sge_slots_empty − \ +SGE slots currently in use: ${RED}${local_sge_slots_used:=/dev/null}${COLOR_DEBUG}." + + return "${return_sge_slots_empty}" + } # }}} is_pending_job_empty() { # {{{ @@ -202,6 +224,17 @@ main() { # {{{ && exit 0 ## }}} + ## If SGE used slots is NULL AND {{{ + ## APT package upgrade is available + ### Create a temp file + ### Disable SGE queue + is_sge_slots_empty \ + && is_apt_upgrade_present \ + && touch "${APT_TMP_FILE}" && echo "APT upgrade is available." >> "${APT_TMP_FILE}" \ + && sh "${sge_disable_host_queue_script}" \ + && exit 0 + ## }}} + ## If pending job list is empty AND {{{ ## APT package upgrade is available ### Create a temp file