#!/bin/ksh93 # ALTRAN_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # Copyright (C) Altran ACT S.A.S. 2017,2019,2020,2021,2022. All rights reserved. # # ALTRAN_PROLOG_END_TAG # ############################################################################### # @(#) 16365cd 43haes/usr/sbin/cluster/events/utils/clcomputeroha.sh, 61aha_r726, 2205H_aha726, Jun 16 2022 05:54 AM ############################################################################### ######################################################################### # # COMPONENT_NAME: hacmp.events # # CLASS: # # roha_compute # # DESCRIPTION: # # This file contains all atomic functions needed to perform # 'compute' step, which is the second step of the ROHA runtime # (query step, compute step, identify step, apply step). # # The compute step can be done for acquisition or for release. # The compute step is done once for memory and once for CPUs (dedicated # processing mode) or for PUs and VPs (shared processing mode). # # # FUNCTIONS: # # roha_compute_check_needed_resources # # roha_compute_mem # roha_compute_mem_to_acquire # roha_compute_mem_to_release # roha_compute_mem_report # roha_compute_mem_to_acquire_report # roha_compute_mem_to_release_report # # roha_compute_cpu # roha_compute_pvm_cpu_to_acquire # roha_compute_shd_cpu_to_acquire # roha_compute_ded_cpu_to_acquire # roha_compute_pvm_cpu_to_release # roha_compute_shd_cpu_to_release # roha_compute_ded_cpu_to_release # roha_compute_cpu_report # roha_compute_pvm_cpu_to_acquire_report # roha_compute_shd_cpu_to_acquire_report # roha_compute_ded_cpu_to_acquire_report # roha_compute_pvm_cpu_to_release_report # roha_compute_shd_cpu_to_release_report # roha_compute_ded_cpu_to_release_report # ######################################################################### #================================================ # The following, commented line enforces coding # standards when this file is edited via vim. #================================================ # vim:tabstop=4:shiftwidth=4:expandtab:smarttab #================================================ #======================================================= # R O H A _ C O M P U T E #======================================================= typeset roha_compute=( # Expected amount of resources needed by applications typeset -F4 raw_total_mem=0.00 typeset -F4 raw_total_pu=0.00 typeset -i raw_total_vp=0.00 typeset -i raw_total_cpu=0 # Expected shared processor pool size typeset -F4 raw_spp_size=0.00 # Computed amount of resources needed, and computed spp_size, # taking into account constraints as max lpar, pu/vp ratio, # and taking into account always_start_rg tunable. typeset -F4 total_availmem=0.00 typeset -F4 total_availproc=0.00 typeset -F4 total_mem=0.00 typeset -F4 total_pu=0.00 typeset -F4 total_vp=0.00 #integer, computed from floats typeset -i total_cpu=0 # Computed deltas typeset -F4 mem=0.00 typeset -F4 pu=0.00 typeset -i vp=0 typeset -i cpu=0 # Computed shared processor pool size required typeset -F4 spp_size=0 #integer, computed from floats typeset roha_type="" ) #============================================================================= # # Name: initialize_compute_globals # # Description: Initialize global vars specific to this file that may otherwise # be used unreinitialized during reassessment # # Inputs: None # # Outputs: None # # Globals: roha_compute # # Returns: RC_SUCCESS # #============================================================================= function initialize_compute_globals { [[ $VERBOSE_LOGGING == high ]] && set -x roha_compute.raw_total_mem=0.00 roha_compute.raw_total_pu=0.00 roha_compute.raw_total_vp=0 roha_compute.raw_total_cpu=0 roha_compute.raw_spp_size=0.00 roha_compute.total_availmem=0.00 roha_compute.total_availproc=0.00 roha_compute.total_mem=0.00 roha_compute.total_pu=0.00 roha_compute.total_vp=0.00 roha_compute.total_cpu=0 roha_compute.mem=0.00 roha_compute.pu=0.00 roha_compute.vp=0 roha_compute.cpu=0 roha_compute.spp_size=0 (( CONN_TYPE == 2 )) && roha_compute.roha_type=" [on Cloud]" return $RC_SUCCESS } #============================================================================= # # Name: roha_compute_check_needed_resources # # Description: Check if resources are needed. # # Inputs: None # # Outputs: None # # Globals: roha_query # roha_compute # # Returns: RC_SUCCESS # RC_FAILURE if no needed resources # #============================================================================= function roha_compute_check_needed_resources { [[ $VERBOSE_LOGGING == high ]] && set -x typeset -i rc=$RC_SUCCESS if [[ ${roha_query.lpar.cpu.proc_mode} == "pvm" ]] ; then if (( ${roha_compute.mem} == 0.00 && ${roha_compute.pu} == 0.00 )) ; then rc=$RC_FAILURE fi elif [[ ${roha_query.lpar.cpu.proc_mode} == "shared" ]] ; then if (( ${roha_compute.mem} == 0.00 && ${roha_compute.pu} == 0.00 && ${roha_compute.vp} == 0.00 )) ; then rc=$RC_FAILURE fi else # [[ ${roha_query.lpar.cpu.proc_mode} == "ded" ]] if (( ${roha_compute.mem} == 0.00 && ${roha_compute.cpu} == 0.00 )) ; then rc=$RC_FAILURE fi fi return $rc } # End of "roha_compute_check_needed_resources()" #============================================================================= # # Name: roha_compute_mem # # Description: Determine how many resources needs to be acquired or released # to reach the optimal amount of memory. # # Inputs: None # # Outputs: None # # Globals: roha_session # roha_query # # Returns: RC_SUCCESS # RC_COMPUTE_MEM_ERROR_LPAR_MAX # #============================================================================= function roha_compute_mem { [[ $VERBOSE_LOGGING == high ]] && set -x typeset -i rc=$RC_SUCCESS if [[ ${roha_session.operation} == "acquire" ]] ; then roha_compute_mem_to_acquire rc=$? else # [[ ${roha_session.operation} == "release" ]] roha_compute_mem_to_release rc=$? fi return $rc } # End of "roha_compute_mem()" #============================================================================= # # Name: roha_compute_mem_report # # Description: Displays computation results. # # Inputs: None # # Outputs: None # # Globals: roha_session # # Returns: None # #============================================================================= function roha_compute_mem_report { case ${roha_session.operation} in "acquire") roha_compute_mem_to_acquire_report ;; "release") roha_compute_mem_to_release_report ;; esac } # End of "roha_compute_mem_report()" #============================================================================= # # Name: roha_compute_mem_to_acquire # # Description: Determine how many resources needs to be acquired # to reach the optimal amount of memory. # # Inputs: None # # Outputs: None # # Globals: roha_query # roha_compute # # Returns: RC_SUCCESS # RC_COMPUTE_MEM_ERROR_LPAR_MAX # #============================================================================= function roha_compute_mem_to_acquire { [[ $VERBOSE_LOGGING == high ]] && set -x typeset -i rc=$RC_SUCCESS #======================================================= : If some ACs use profile desired value, start from : there, or else start from the minimum. #======================================================= if (( ${roha_query.optimal.use_desired_nb} > 0 || ${roha_query.running.use_desired_nb} > 0 )) ; then (( roha_compute.raw_total_mem = ${roha_query.lpar.mem.des} + ${roha_query.running.total_mem} + ${roha_query.optimal.total_mem} )) else (( roha_compute.raw_total_mem = ${roha_query.lpar.mem.min} + ${roha_query.running.total_mem} + ${roha_query.optimal.total_mem} )) fi roha_compute.total_mem=${roha_compute.raw_total_mem} if (( CONN_TYPE == 2 )); then # In Cloud ROHA, Total available resource is the sum of availabe and current value (( roha_compute.total_availmem = ${roha_query.cec.mem.available} + ${roha_query.lpar.mem.curr} )) (( roha_compute.total_availmem = $(min ${roha_query.lpar.mem.max} ${roha_compute.total_availmem}) )) else # On-Prem ROHA (HMC/NovaLink) roha_compute.total_availmem=${roha_query.lpar.mem.max} fi #============================================================ : Check if the amount of memory is limited by LPAR max, : if it is the case, adjust or not depending on : always_start_rg. #============================================================ if (( ${roha_compute.total_mem} <= ${roha_query.lpar.mem.curr} )) ; then #======================================================= : There are already enough allocated resources. Do not : acquire any. #======================================================= (( roha_compute.mem = 0.00 )) (( roha_compute.total_mem = ${roha_query.lpar.mem.curr} )) elif (( ${roha_compute.total_mem} <= ${roha_compute.total_availmem} )) ; then #======================================================= : Try to acquire additional memory to fit optimal amount. #======================================================= (( roha_compute.mem = ${roha_compute.total_mem} - ${roha_query.lpar.mem.curr} )) elif [[ $(roha_session_read_odm_rohaparam "always_start_rg") == 1 ]] ; then #======================================================= : Optimal memory will exceed LPAR maximum. But : cluster is configured to always start RGs. Try to : acquire additional resources up to the maximum. #======================================================= (( roha_compute.mem = ${roha_compute.total_availmem} - ${roha_query.lpar.mem.curr} )) (( roha_compute.total_mem = ${roha_compute.total_availmem} )) else # [[ $always_start_rg == 0 ]] #======================================================= : Optimal memory will exceed LPAR maximum. And : cluster is not configured to always start RGs. : Notify user. #======================================================= roha_session_log "$(dspmsg -s $ROHA_SET $ROHA_MSGS 111 \ "%1\$s: ERROR: %2\$d GB of memory needed will exceed LPAR maximum of %3\$d GB.\n" \ "$PROGNAME" "${roha_compute.total_mem}" "${roha_compute.total_availmem}")" #======================================================= : Do not acquire any. #======================================================= (( roha_compute.mem = 0.00 )) (( roha_compute.total_mem = ${roha_query.lpar.mem.curr} )) rc=$RC_COMPUTE_MEM_ERROR_LPAR_MAX fi return $rc } # End of "roha_compute_mem_to_acquire()" #============================================================================= # # Name: roha_compute_mem_to_acquire_report # # Description: Displays computation results. # # Inputs: None # # Outputs: None # # Globals: roha_query # roha_compute # # Returns: None # #============================================================================= function roha_compute_mem_to_acquire_report { roha_session_log "$(printf "============ Compute ROHA%s Memory ============" "${roha_compute.roha_type}")" roha_session_log "$(printf "== Status Reminder ==")" roha_session_log "$(printf "Current resources : % 7.4f GB" ${roha_query.lpar.mem.curr})" roha_session_log "$(printf "== Raw computation from AC settings ==")" if (( ${roha_query.optimal.use_desired_nb} > 0 || ${roha_query.running.use_desired_nb} > 0 )) ; then roha_session_log "$(printf "LPAR profile desired : % 7.4f GB" ${roha_query.lpar.mem.des})" else roha_session_log "$(printf "LPAR profile minimum : % 7.4f GB" ${roha_query.lpar.mem.min})" fi roha_session_log "$(printf "APPs running : % 7.4f GB" ${roha_query.running.total_mem})" roha_session_log "$(printf "APPs to start (optimal) : % 7.4f GB" ${roha_query.optimal.total_mem})" roha_session_log "$(printf "Total raw : % 7.4f GB" ${roha_compute.raw_total_mem})" roha_session_log "$(printf "Delta acquisition raw : % 7.4f GB" ${roha_compute.raw_total_mem}-${roha_query.lpar.mem.curr})" roha_session_log "$(printf "== Maximum limits (fit into if exceeding and always_start_rg=1, otherwise fail).")" roha_session_log "$(printf "LPAR profile maximum : % 7.4f GB" ${roha_query.lpar.mem.max})" roha_session_log "$(printf "== Minimum limits (adjust if under) ==")" roha_session_log "$(printf "Delta minimum : 0.00 GB")" roha_session_log "$(printf "== Final computation, limits considered ==")" roha_session_log "$(printf "Total : % 7.4f GB" ${roha_compute.total_mem})" roha_session_log "$(printf "Delta acquisition : % 7.4f GB" ${roha_compute.mem})" roha_session_log "$(printf "=================== End =====================")" } # End of "roha_compute_mem_to_acquire_report()" #============================================================================= # # Name: roha_compute_mem_to_release # # Description: Determine how many resources need to be released to fit # remaining RGs. # # Inputs: None # # Outputs: None # # Globals: roha_query # roha_compute # # Returns: RC_SUCCESS # #============================================================================= function roha_compute_mem_to_release { [[ $VERBOSE_LOGGING == high ]] && set -x typeset -i rc=$RC_SUCCESS #======================================================= : If some ACs use profile desired value, start from : there, or else start from the minimum. #======================================================= if (( ${roha_query.running.use_desired_nb} > 0 )) ; then (( roha_compute.raw_total_mem = ${roha_query.lpar.mem.des} + ${roha_query.running.total_mem})) else (( roha_compute.raw_total_mem = ${roha_query.lpar.mem.min} + ${roha_query.running.total_mem} )) fi roha_compute.total_mem=${roha_compute.raw_total_mem} if (( ${roha_compute.total_mem} < ${roha_query.lpar.mem.curr} )) ; then #======================================================= : Release the difference between current and needed #======================================================= (( roha_compute.mem = ${roha_query.lpar.mem.curr} - ${roha_compute.total_mem} )) #======================================================= : Do not release more than previously acquired. #======================================================= (( roha_compute.mem = $(min ${roha_compute.mem} $(roha_session_read_odm_dynresop "DLPAR_MEM")) )) else #======================================================= : There are not enough resources. Do not release any. #======================================================= (( roha_compute.mem = 0.00 )) fi (( roha_compute.total_mem = ${roha_query.lpar.mem.curr} - ${roha_compute.mem} )) return $rc } # End of "roha_compute_mem_to_release()" #============================================================================= # # Name: roha_compute_mem_to_release_report # # Description: Displays computation results. # # Inputs: None # # Outputs: None # # Globals: roha_query # roha_compute # # Returns: None # #============================================================================= function roha_compute_mem_to_release_report { roha_session_log "$(printf "============ Compute ROHA%s Memory ============" "${roha_compute.roha_type}")" roha_session_log "$(printf "== Status Reminder ==")" roha_session_log "$(printf "Current resources : % 7.4f GB" ${roha_query.lpar.mem.curr})" roha_session_log "$(printf "== Raw computation from AC settings ==")" if (( ${roha_query.running.use_desired_nb} > 0 )) ; then roha_session_log "$(printf "LPAR profile desired : % 7.4f GB" ${roha_query.lpar.mem.des})" else roha_session_log "$(printf "LPAR profile minimum : % 7.4f GB" ${roha_query.lpar.mem.min})" fi roha_session_log "$(printf "APPs running : % 7.4f GB" ${roha_query.running.total_mem})" roha_session_log "$(printf "Total raw : % 7.4f GB" ${roha_compute.raw_total_mem})" roha_session_log "$(printf "Delta release raw : % 7.4f GB" ${roha_query.lpar.mem.curr}-${roha_compute.raw_total_mem})" roha_session_log "$(printf "== Maximum limits (adjust at best) ==")" roha_session_log "$(printf "Saved ROHA delta acquire : % 7.4f GB" $(roha_session_read_odm_dynresop "DLPAR_MEM"))" roha_session_log "$(printf "== Minimum limits (adjust if under) ==")" roha_session_log "$(printf "Delta minimum : 0.00 GB")" roha_session_log "$(printf "== Final computation, limits considered ==")" roha_session_log "$(printf "Total : % 7.4f GB" ${roha_compute.total_mem})" roha_session_log "$(printf "Delta release : % 7.4f GB" ${roha_compute.mem})" roha_session_log "$(printf "=================== End =====================")" } # End of "roha_compute_mem_to_release_report()" #============================================================================= # # Name: roha_compute_cpu # # Description: Determine how many resources needs to be acquired or released # to reach the optimal amount of processors. # # Inputs: None # # Outputs: None # # Globals: roha_session # roha_query # # Returns: RC_SUCCESS # or else error code for compute step # #============================================================================= function roha_compute_cpu { [[ $VERBOSE_LOGGING == high ]] && set -x typeset -i rc=$RC_SUCCESS if [[ ${roha_query.lpar.cpu.proc_mode} == "pvm" ]] ; then if [[ ${roha_session.operation} == "acquire" ]] ; then roha_compute_pvm_cpu_to_acquire rc=$? else # [[ ${roha_session.operation} == "release" ]] roha_compute_pvm_cpu_to_release rc=$? fi elif [[ ${roha_query.lpar.cpu.proc_mode} == "shared" ]] ; then if [[ ${roha_session.operation} == "acquire" ]] ; then roha_compute_shd_cpu_to_acquire rc=$? else # [[ ${roha_session.operation} == "release" ]] roha_compute_shd_cpu_to_release rc=$? fi else # [[ ${roha_query.lpar.cpu.proc_mode} == "ded" ]] if [[ ${roha_session.operation} == "acquire" ]] ; then roha_compute_ded_cpu_to_acquire rc=$? else # [[ ${roha_session.operation} == "release" ]] roha_compute_ded_cpu_to_release rc=$? fi fi return $rc } # End of "roha_compute_cpu()" #============================================================================= # # Name: roha_compute_cpu_report # # Description: Displays computation results. # # Inputs: None # # Outputs: None # # Globals: roha_session # roha_query # # Returns: None # #============================================================================= function roha_compute_cpu_report { if [[ ${roha_query.lpar.cpu.proc_mode} == "pvm" ]] ; then if [[ ${roha_session.operation} == "acquire" ]] ; then roha_compute_pvm_cpu_to_acquire_report else # [[ ${roha_session.operation} == "release" ]] roha_compute_pvm_cpu_to_release_report fi elif [[ ${roha_query.lpar.cpu.proc_mode} == "shared" ]] ; then if [[ ${roha_session.operation} == "acquire" ]] ; then roha_compute_shd_cpu_to_acquire_report else # [[ ${roha_session.operation} == "release" ]] roha_compute_shd_cpu_to_release_report fi else # [[ ${roha_query.lpar.cpu.proc_mode} == "ded" ]] if [[ ${roha_session.operation} == "acquire" ]] ; then roha_compute_ded_cpu_to_acquire_report else # [[ ${roha_session.operation} == "release" ]] roha_compute_ded_cpu_to_release_report fi fi } # End of "roha_compute_cpu_report()" #============================================================================= # # Name: roha_compute_pvm_cpu_to_acquire # # Description: Determine how many resources needs to be acquired # to reach the optimal amount of processor. # # Inputs: None # # Outputs: None # # Globals: roha_query # roha_compute # # Returns: RC_SUCCESS # RC_COMPUTE_CPU_ERROR_LPAR_VP_MAX # RC_COMPUTE_CPU_ERROR_LPAR_PU_MAX # RC_COMPUTE_CPU_ERROR_SPP_SIZE # RC_COMPUTE_CPU_ERROR_RATIO # #============================================================================= # Function for powervs VM cpu compute function roha_compute_pvm_cpu_to_acquire { [[ $VERBOSE_LOGGING == high ]] && set -x typeset -i rc=$RC_SUCCESS (( roha_compute.pu = 0.00 )) #======================================================= : If some ACs use profile desired value, start from : there, or else start from the minimum. #======================================================= if (( ${roha_query.optimal.use_desired_nb} > 0 || ${roha_query.running.use_desired_nb} > 0 )) ; then (( roha_compute.raw_total_pu = ${roha_query.lpar.cpu.proc_units.des} + ${roha_query.running.total_pu} + ${roha_query.optimal.total_pu} )) else (( roha_compute.raw_total_pu = ${roha_query.lpar.cpu.proc_units.min} + ${roha_query.running.total_pu} + ${roha_query.optimal.total_pu} )) fi roha_compute.total_pu=${roha_compute.raw_total_pu} # Total available resource is the sum of availabe and current value (( roha_compute.total_availproc = ${roha_query.cec.cpu.available} + ${roha_query.lpar.cpu.proc_units.curr} )) (( roha_compute.total_availproc = $(min ${roha_query.lpar.cpu.proc_units.max} ${roha_compute.total_availproc}) )) #============================================================ : First check if the number of PU is limited by LPAR max, : if it is the case, adjust or not depending on : always_start_rg. #============================================================ if (( ${roha_compute.total_pu} <= ${roha_query.lpar.cpu.proc_units.curr} )) ; then #======================================================= : There are already enough allocated resources. Do not : acquire any. #======================================================= (( roha_compute.pu = 0.00 )) (( roha_compute.total_pu = ${roha_query.lpar.cpu.proc_units.curr} )) elif (( ${roha_compute.total_pu} <= ${roha_compute.total_availproc} )) ; then #======================================================= : Try to acquire additional resources to fit optimal : amount. #======================================================= (( roha_compute.pu = ${roha_compute.total_pu} - ${roha_query.lpar.cpu.proc_units.curr} )) elif [[ $(roha_session_read_odm_rohaparam "always_start_rg") == 1 ]] ; then #======================================================= : Optimal PU will exceed LPAR maximum. But : cluster is configured to always start RGs. Try to : acquire additional resources up to the maximum. #======================================================= (( roha_compute.pu = ${roha_compute.total_availproc} - ${roha_query.lpar.cpu.proc_units.curr} )) (( roha_compute.total_pu = ${roha_compute.total_availproc} )) else # [[ $always_start_rg == 0 ]] #======================================================= : Optimal PU will exceed LPAR maximum. And : cluster is not configured to always start RGs. : Notify user. #======================================================= roha_session_log "$(dspmsg -s $ROHA_SET $ROHA_MSGS 113 \ "%1\$s: ERROR: %2\$d Processing Unit(s) needed will exceed LPAR maximum of %3\$d Processing Unit(s).\n" \ "$PROGNAME" "${roha_compute.total_pu}" "${roha_compute.total_availproc}")" rc=$RC_COMPUTE_CPU_ERROR_LPAR_PU_MAX fi if (( $rc != $RC_SUCCESS )) ; then #======================================================= : An error occured, do not acquire any #======================================================= (( roha_compute.pu = 0.00 )) ((roha_compute.total_pu = ${roha_query.lpar.cpu.proc_units.curr} )) fi return $rc } # End of "roha_compute_pvm_cpu_to_acquire()" #============================================================================= # # Name: roha_compute_pvm_cpu_to_acquire_report # # Description: Displays computation results. # # Inputs: None # # Outputs: None # # Globals: roha_query # roha_compute # # Returns: None # #============================================================================= # Function to show powervs cpu report function roha_compute_pvm_cpu_to_acquire_report { roha_session_log "$(printf "========== Compute ROHA%s CPU(s) =========" "${roha_compute.roha_type}")" roha_session_log "$(printf "== Status Reminder ==")" roha_session_log "$(printf "Current resources : % 7.4f" ${roha_query.lpar.cpu.proc_units.curr})" roha_session_log "$(printf "== Raw computation from AC settings ==")" if (( ${roha_query.optimal.use_desired_nb} > 0 || ${roha_query.running.use_desired_nb} > 0 )) ; then roha_session_log "$(printf "LPAR profile desired : % 7.4f" ${roha_query.lpar.cpu.proc_units.des})" else roha_session_log "$(printf "LPAR profile minimum : % 7.4f" ${roha_query.lpar.cpu.proc_units.min})" fi roha_session_log "$(printf "APPs running : % 7.4f" ${roha_query.running.total_pu})" roha_session_log "$(printf "APPs to start (optimal) : % 7.4f" ${roha_query.optimal.total_pu})" roha_session_log "$(printf "Total raw : % 7.4f" ${roha_compute.raw_total_pu})" roha_session_log "$(printf "Delta acquisition raw : % 7.4f" ${roha_compute.raw_total_pu}-${roha_query.lpar.cpu.proc_units.curr})" roha_session_log "$(printf "== Maximum limits (fit into if exceeding and always_start_rg=1, otherwise fail).")" roha_session_log "$(printf "LPAR profile maximum : % 7.4f" ${roha_query.lpar.cpu.proc_units.max})" roha_session_log "$(printf "== Minimum limits (adjust if under) ==")" roha_session_log "$(printf "Delta minimum : 0.00")" roha_session_log "$(printf "== Final computation, limits considered ==")" roha_session_log "$(printf "Total : % 7.4f" ${roha_compute.total_pu})" roha_session_log "$(printf "Delta acquisition : % 7.4f" ${roha_compute.pu})" roha_session_log "$(printf "=================== End =====================")" } # End of "roha_compute_pvm_cpu_to_acquire_report()" #============================================================================= # # Name: roha_compute_shd_cpu_to_acquire # # Description: Determine how many resources needs to be acquired # to reach the optimal amount of memory. # # First check if the number of PU is limited by LPAR max. # Then check PU quantity toward SPP size, and adjust # one or the other depending on configuration. # Then now that PU quantity is stable, check if VP # quantity is correct regarding PU/VP ratio. # Then check if VP quantity is limited by LPAR max. # # Inputs: None # # Outputs: None # # Globals: roha_query # roha_compute # # Returns: RC_SUCCESS # RC_COMPUTE_CPU_ERROR_LPAR_VP_MAX # RC_COMPUTE_CPU_ERROR_LPAR_PU_MAX # RC_COMPUTE_CPU_ERROR_SPP_SIZE # RC_COMPUTE_CPU_ERROR_RATIO # #============================================================================= function roha_compute_shd_cpu_to_acquire { [[ $VERBOSE_LOGGING == high ]] && set -x typeset -i rc=$RC_SUCCESS typeset -F4 proc_ratio=0 typeset -i required_vp=0 (( roha_compute.vp = 0 )) (( roha_compute.pu = 0.00 )) (( roha_compute.spp_size = ${roha_query.lpar.cpu.proc_units.spp_max} )) #======================================================= : If some ACs use profile desired value, start from : there, or else start from the minimum. #======================================================= if (( ${roha_query.optimal.use_desired_nb} > 0 || ${roha_query.running.use_desired_nb} > 0 )) ; then (( roha_compute.raw_total_vp = ${roha_query.lpar.cpu.procs.des} + ${roha_query.running.total_vp} + ${roha_query.optimal.total_vp} )) (( roha_compute.raw_total_pu = ${roha_query.lpar.cpu.proc_units.des} + ${roha_query.running.total_pu} + ${roha_query.optimal.total_pu} )) else (( roha_compute.raw_total_vp = ${roha_query.lpar.cpu.procs.min} + ${roha_query.running.total_vp} + ${roha_query.optimal.total_vp} )) (( roha_compute.raw_total_pu = ${roha_query.lpar.cpu.proc_units.min} + ${roha_query.running.total_pu} + ${roha_query.optimal.total_pu} )) fi (( roha_compute.raw_spp_size = ${roha_query.lpar.cpu.proc_units.spp_max} - ${roha_query.lpar.cpu.proc_units.spp_free} + ${roha_compute.raw_total_pu} - ${roha_query.lpar.cpu.proc_units.curr} )) roha_compute.raw_spp_size=$(print ${roha_compute.raw_spp_size} | awk '{printf "%0.4f\n",int($0+0.9999)}') roha_compute.total_pu=${roha_compute.raw_total_pu} roha_compute.total_vp=${roha_compute.raw_total_vp} #============================================================ : First check if the number of PU is limited by LPAR max, : if it is the case, adjust or not depending on : always_start_rg. #============================================================ if (( ${roha_compute.total_pu} <= ${roha_query.lpar.cpu.proc_units.curr} )) ; then #======================================================= : There are already enough allocated resources. Do not : acquire any. #======================================================= (( roha_compute.pu = 0.00 )) (( roha_compute.total_pu = ${roha_query.lpar.cpu.proc_units.curr} )) elif (( ${roha_compute.total_pu} <= ${roha_query.lpar.cpu.proc_units.max} )) ; then #======================================================= : Try to acquire additional resources to fit optimal : amount. #======================================================= (( roha_compute.pu = ${roha_compute.total_pu} - ${roha_query.lpar.cpu.proc_units.curr} )) elif [[ $(roha_session_read_odm_rohaparam "always_start_rg") == 1 ]] ; then #======================================================= : Optimal PU will exceed LPAR maximum. But : cluster is configured to always start RGs. Try to : acquire additional resources up to the maximum. #======================================================= (( roha_compute.pu = ${roha_query.lpar.cpu.proc_units.max} - ${roha_query.lpar.cpu.proc_units.curr} )) (( roha_compute.total_pu = ${roha_query.lpar.cpu.proc_units.max} )) else # [[ $always_start_rg == 0 ]] #======================================================= : Optimal PU will exceed LPAR maximum. And : cluster is not configured to always start RGs. : Notify user. #======================================================= roha_session_log "$(dspmsg -s $ROHA_SET $ROHA_MSGS 113 \ "%1\$s: ERROR: %2\$d Processing Unit(s) needed will exceed LPAR maximum of %3\$d Processing Unit(s).\n" \ "$PROGNAME" "${roha_compute.total_pu}" "${roha_query.lpar.cpu.proc_units.max}")" rc=$RC_COMPUTE_CPU_ERROR_LPAR_PU_MAX fi #============================================================ : Then check if the number of PU fits SPP size #============================================================ if (( $rc == $RC_SUCCESS )) && [[ ${roha_query.lpar.cpu.proc_units.spp_name} != "DefaultPool" ]] ; then #======================================================= : Compute the new SPP size needed and check if it is : greater than the current one #======================================================= (( roha_compute.spp_size = ${roha_query.lpar.cpu.proc_units.spp_max} - ${roha_query.lpar.cpu.proc_units.spp_free} + ${roha_compute.pu} )) roha_compute.spp_size=$(print ${roha_compute.spp_size} | awk '{printf "%0.4f\n",int($0+0.9999)}') if (( ${roha_compute.spp_size} > ${roha_query.lpar.cpu.proc_units.spp_max} )) ; then #======================================================= : The SPP size needed to fit the quantity of PU is : greater than the current SPP size. Either adjust the : spp size, the number of PU or fail, depending on : configuration #======================================================= if [[ $(roha_session_read_odm_rohaparam "adjust_spp_size") == 0 ]] ; then if [[ $(roha_session_read_odm_rohaparam "always_start_rg") == 1 ]] ; then #======================================================= : Limit total number of processing units to shared : processor pool maximum size. #======================================================= (( roha_compute.pu = ${roha_query.lpar.cpu.proc_units.spp_free} )) roha_compute.total_pu=${roha_query.lpar.cpu.proc_units.curr}+${roha_compute.pu} #======================================================= : Then set spp_size to the current max #======================================================= roha_compute.spp_size=${roha_query.lpar.cpu.proc_units.spp_max} else # [[ $always_start_rg == 0 ]] #======================================================= : Notify user. #======================================================= roha_session_log "$(dspmsg -s $ROHA_SET $ROHA_MSGS 116 \ "%1\$s: ERROR: %2\$d Processing Unit(s) needed will exceed Shared Processor Pool size of %3\$d CPU(s).\n" \ "$PROGNAME" "${roha_compute.total_pu}" "${roha_query.lpar.cpu.proc_units.spp_max}")" rc=$RC_COMPUTE_CPU_ERROR_SPP_SIZE fi fi fi fi #======================================================= : check VP towards PU/VP ratio. #======================================================= if (( ${roha_compute.total_vp} <= ${roha_query.lpar.cpu.procs.curr} )) ; then #========================================================= : Check ratio with current VPs if there are already enough : allocated resources. #========================================================= (( roha_compute.total_vp = ${roha_query.lpar.cpu.procs.curr} )) fi (( proc_ratio = ${roha_compute.total_pu} / ${roha_compute.total_vp} )) if (( $rc == $RC_SUCCESS )) && (( ${proc_ratio} > 1 )) ; then required_vp=$(( ceil(${roha_compute.total_pu}) )) if [[ $(roha_session_read_odm_rohaparam "always_start_rg") == 1 ]] ; then #======================================================= : Limit total number of VP to fit the ratio. #======================================================= roha_compute.total_vp=$(print ${required_vp} | awk '{printf "%0.4f\n",int($0)}') else # [[ $always_start_rg == 0 ]] #======================================================= : Notify user. #======================================================= roha_session_log "$(dspmsg -s $ROHA_SET $ROHA_MSGS 522 \ "%1\$s: ERROR: The total number of virtual processors must be at least equal to the\nwhole number of the total number of processing units, rounded up for any fraction.\nAt least %2\$d virtual processors must be present for %3\$d processing units.\n" "$PROGNAME" "${required_vp}" "${roha_compute.total_pu}")" rc=$RC_COMPUTE_CPU_ERROR_RATIO fi fi (( proc_ratio = ${roha_query.cec.cpu.ratio} * ${roha_compute.total_vp} )) #======================================================= : Then check PU towards VP/PU ratio. #======================================================= if (( $rc == $RC_SUCCESS )) && (( ${roha_compute.total_pu} < $proc_ratio )) ; then if [[ $(roha_session_read_odm_rohaparam "always_start_rg") == 1 ]] ; then #======================================================= : Limit total number of VP to fit the ratio. : Round down to have not less than the min ratio. #======================================================= (( roha_compute.total_vp = ${roha_compute.total_pu} / ${roha_query.cec.cpu.ratio} )) roha_compute.total_vp=$(print ${roha_compute.total_vp} | awk '{printf "%0.4f\n",int($0)}') else # [[ $always_start_rg == 0 ]] #======================================================= : Notify user. #======================================================= roha_session_log "$(dspmsg -s $ROHA_SET $ROHA_MSGS 115 \ "%1\$s: ERROR: Ratio of %2\$d is not verified by needed %3\$d Virtual Processor(s) and %4\$d Processing Unit(s).\n" \ "$PROGNAME" "${roha_query.cec.cpu.ratio}" "${roha_compute.total_vp}" "${roha_compute.total_pu}")" rc=$RC_COMPUTE_CPU_ERROR_RATIO fi fi if (( $rc == $RC_SUCCESS )) ; then #============================================================ : Last check if the number of VP is limited by LPAR max, : if it is the case, adjust or not depending on : always_start_rg. #============================================================ if (( ${roha_compute.total_vp} <= ${roha_query.lpar.cpu.procs.curr} )) ; then #======================================================= : There are already enough allocated resources. Do not : acquire any. #======================================================= (( roha_compute.vp = 0 )) (( roha_compute.total_vp = ${roha_query.lpar.cpu.procs.curr} )) elif (( ${roha_compute.total_vp} <= ${roha_query.lpar.cpu.procs.max} )) ; then #======================================================= : Try to acquire additional VP to fit optimal amount. #======================================================= (( roha_compute.vp = ${roha_compute.total_vp} - ${roha_query.lpar.cpu.procs.curr} )) elif [[ $(roha_session_read_odm_rohaparam "always_start_rg") == 1 ]] ; then #======================================================= : Optimal VP will exceed LPAR maximum. But : cluster is configured to always start RGs. Try to : acquire additional resources up to the maximum. #======================================================= (( roha_compute.vp = ${roha_query.lpar.cpu.procs.max} - ${roha_query.lpar.cpu.procs.curr} )) (( roha_compute.total_vp = ${roha_query.lpar.cpu.procs.max} )) else # [[ $always_start_rg == 0 ]] #======================================================= : Optimal VP will exceed LPAR maximum. And : cluster is not configured to always start RGs. : Notify user. #======================================================= roha_session_log "$(dspmsg -s $ROHA_SET $ROHA_MSGS 114 \ "%1\$s: ERROR: %2\$d Virtual Processor(s) needed will exceed LPAR maximum of %3\$d Virtual Processor(s).\n" \ "$PROGNAME" "${roha_compute.total_vp}" "${roha_query.lpar.cpu.procs.max}")" rc=$RC_COMPUTE_CPU_ERROR_LPAR_VP_MAX fi fi if (( $rc != $RC_SUCCESS )) ; then #======================================================= : An error occured, do not acquire any #======================================================= (( roha_compute.vp = 0 )) (( roha_compute.pu = 0.00 )) (( roha_compute.spp_size = ${roha_query.lpar.cpu.proc_units.spp_max} )) ((roha_compute.total_pu = ${roha_query.lpar.cpu.proc_units.curr} )) ((roha_compute.total_vp = ${roha_query.lpar.cpu.procs.curr})) fi return $rc } # End of "roha_compute_shd_cpu_to_acquire()" #============================================================================= # # Name: roha_compute_shd_cpu_to_acquire_report # # Description: Displays computation results. # # Inputs: None # # Outputs: None # # Globals: roha_query # roha_compute # # Returns: None # #============================================================================= function roha_compute_shd_cpu_to_acquire_report { roha_session_log "$(printf "========== Compute ROHA PU(s)/VP(s) =========")" roha_session_log "$(printf "== Status Reminder ==")" roha_session_log "$(printf "Current resources : % 7.4f / %3d" ${roha_query.lpar.cpu.proc_units.curr} ${roha_query.lpar.cpu.procs.curr})" if [[ $(roha_session_read_odm_rohaparam "adjust_spp_size") == 1 ]] ; then roha_session_log "$(printf "Current SPP size : %3d" ${roha_query.lpar.cpu.proc_units.spp_max})" roha_session_log "$(printf "Current SPP free res. : % 7.4f" ${roha_query.lpar.cpu.proc_units.spp_free})" fi roha_session_log "$(printf "== Raw computation from AC settings ==")" if (( ${roha_query.optimal.use_desired_nb} > 0 || ${roha_query.running.use_desired_nb} > 0 )) ; then roha_session_log "$(printf "LPAR profile desired : % 7.4f / %3d" ${roha_query.lpar.cpu.proc_units.des} ${roha_query.lpar.cpu.procs.des})" else roha_session_log "$(printf "LPAR profile minimum : % 7.4f / %3d" ${roha_query.lpar.cpu.proc_units.min} ${roha_query.lpar.cpu.procs.min})" fi roha_session_log "$(printf "APPs running : % 7.4f / %3d" ${roha_query.running.total_pu} ${roha_query.running.total_vp})" roha_session_log "$(printf "APPs to start (optimal) : % 7.4f / %3d" ${roha_query.optimal.total_pu} ${roha_query.optimal.total_vp})" roha_session_log "$(printf "Total raw : % 7.4f / %3d" ${roha_compute.raw_total_pu} ${roha_compute.raw_total_vp})" roha_session_log "$(printf "Delta acquisition raw : % 7.4f / %3d" ${roha_compute.raw_total_pu}-${roha_query.lpar.cpu.proc_units.curr} ${roha_compute.raw_total_vp}-${roha_query.lpar.cpu.procs.curr})" roha_session_log "$(printf "PU/VP ratio raw : % 7.4f" ${roha_compute.raw_total_pu}/${roha_compute.raw_total_vp})" roha_session_log "$(printf "Minimal SPP size raw : %3d" ${roha_compute.raw_spp_size})" roha_session_log "$(printf "== Maximum limits (fit into if exceeding and always_start_rg=1, otherwise fail).")" roha_session_log "$(printf "LPAR profile maximum : % 7.4f / %3d" ${roha_query.lpar.cpu.proc_units.max} ${roha_query.lpar.cpu.procs.max})" roha_session_log "$(printf "PU/VP ratio : % 7.4f (Cannot have a lower ratio)." ${roha_query.cec.cpu.ratio})" if [[ $(roha_session_read_odm_rohaparam "adjust_spp_size") == 0 ]] ; then roha_session_log "$(printf "SPP free (for delta) : %3d" ${roha_query.lpar.cpu.proc_units.spp_free})" fi roha_session_log "$(printf "== Minimum limits (adjust if under) ==")" roha_session_log "$(printf "Delta minimum : 0.00 / 0")" roha_session_log "$(printf "== Final computation, limits considered ==")" roha_session_log "$(printf "Total : % 7.4f / %3d" ${roha_compute.total_pu} ${roha_compute.total_vp})" roha_session_log "$(printf "Delta acquisition : % 7.4f / %3d" ${roha_compute.pu} ${roha_compute.vp})" roha_session_log "$(printf "PU/VP ratio : % 7.4f" ${roha_compute.total_pu}/${roha_compute.total_vp})" if [[ $(roha_session_read_odm_rohaparam "adjust_spp_size") == 1 ]] ; then if (( ${roha_compute.spp_size%.*} > ${roha_query.lpar.cpu.proc_units.spp_max} )) ; then roha_session_log "$(printf "SPP size : %3d" ${roha_compute.spp_size})" else roha_session_log "$(printf "SPP size : %3d" ${roha_query.lpar.cpu.proc_units.spp_max})" fi fi roha_session_log "$(printf "=================== End =====================")" } # End of "roha_compute_shd_cpu_to_acquire_report()" #============================================================================= # # Name: roha_compute_ded_cpu_to_acquire # # Description: Determine how many resources needs to be acquired # to reach the optimal amount of processors. # # Inputs: None # # Outputs: None # # Globals: roha_query # roha_compute # # Returns: RC_SUCCESS # RC_COMPUTE_CPU_ERROR_LPAR_CPU_MAX # #============================================================================= function roha_compute_ded_cpu_to_acquire { [[ $VERBOSE_LOGGING == high ]] && set -x typeset -i rc=$RC_SUCCESS #======================================================= : If some ACs use profile desired value, start from : there, or else start from the minimum. #======================================================= if (( ${roha_query.optimal.use_desired_nb} > 0 || ${roha_query.running.use_desired_nb} > 0 )) ; then (( roha_compute.raw_total_cpu = ${roha_query.lpar.cpu.procs.des} + ${roha_query.running.total_cpu} + ${roha_query.optimal.total_cpu} )) else (( roha_compute.raw_total_cpu = ${roha_query.lpar.cpu.procs.min} + ${roha_query.running.total_cpu} + ${roha_query.optimal.total_cpu} )) fi roha_compute.total_cpu=${roha_compute.raw_total_cpu} #============================================================ : Check if the number of processors is limited by LPAR max, : if it is the case, adjust or not depending on : always_start_rg. #============================================================ if (( ${roha_compute.total_cpu} <= ${roha_query.lpar.cpu.procs.curr} )) ; then #======================================================= : There are already enough allocated resources. Do not : acquire any. #======================================================= (( roha_compute.cpu = 0 )) (( roha_compute.total_cpu = ${roha_query.lpar.cpu.procs.curr} )) elif (( ${roha_compute.total_cpu} <= ${roha_query.lpar.cpu.procs.max} )) ; then #======================================================= : Try to acquire additional procs to fit optimal amount. #======================================================= (( roha_compute.cpu = ${roha_compute.total_cpu} - ${roha_query.lpar.cpu.procs.curr} )) elif [[ $(roha_session_read_odm_rohaparam "always_start_rg") == 1 ]] ; then #======================================================= : Optimal processors will exceed LPAR maximum. But : cluster is configured to always start RGs. Try to : acquire additional resources up to the maximum. #======================================================= (( roha_compute.cpu = ${roha_query.lpar.cpu.procs.max} - ${roha_query.lpar.cpu.procs.curr} )) (( roha_compute.total_cpu = ${roha_query.lpar.cpu.procs.max} )) else # [[ $always_start_rg == 0 ]] #======================================================= : Optimal processors will exceed LPAR maximum. And : cluster is not configured to always start RGs. : Notify user. #======================================================= roha_session_log "$(dspmsg -s $ROHA_SET $ROHA_MSGS 112 \ "%1\$s: ERROR: %2\$d CPU(s) needed will exceed LPAR maximum of %3\$d CPU(s).\n" \ "$PROGNAME" "${roha_compute.total_cpu}" "${roha_query.lpar.cpu.procs.max}")" #======================================================= : Do not acquire any. #======================================================= (( roha_compute.cpu = 0 )) (( roha_compute.total_cpu = ${roha_query.lpar.cpu.procs.curr} )) rc=$RC_COMPUTE_CPU_ERROR_LPAR_CPU_MAX fi return $rc } # End of "roha_compute_ded_cpu_to_acquire()" #============================================================================= # # Name: roha_compute_ded_cpu_to_acquire_report # # Description: Displays computation results. # # Inputs: None # # Outputs: None # # Globals: roha_query # roha_compute # # Returns: None # #============================================================================= function roha_compute_ded_cpu_to_acquire_report { roha_session_log "$(printf "============ Compute ROHA CPU(s) ============")" roha_session_log "$(printf "== Status Reminder ==")" roha_session_log "$(printf "Current resources : % 7d" ${roha_query.lpar.cpu.procs.curr})" roha_session_log "$(printf "== Raw computation from AC settings ==")" if (( ${roha_query.optimal.use_desired_nb} > 0 || ${roha_query.running.use_desired_nb} > 0 )) ; then roha_session_log "$(printf "LPAR profile desired : % 7d" ${roha_query.lpar.cpu.procs.des})" else roha_session_log "$(printf "LPAR profile minimum : % 7d" ${roha_query.lpar.cpu.procs.min})" fi roha_session_log "$(printf "APPs running : % 7d" ${roha_query.running.total_cpu})" roha_session_log "$(printf "APPs to start (optimal) : % 7d" ${roha_query.optimal.total_cpu})" roha_session_log "$(printf "Total raw : % 7d" ${roha_compute.raw_total_cpu})" roha_session_log "$(printf "Delta acquisition raw : % 7d" ${roha_compute.raw_total_cpu}-${roha_query.lpar.cpu.procs.curr})" roha_session_log "$(printf "== Maximum limits (fit into if exceeding and always_start_rg=1, otherwise fail).")" roha_session_log "$(printf "LPAR profile maximum : % 7d" ${roha_query.lpar.cpu.procs.max})" roha_session_log "$(printf "== Minimum limits (adjust if under) ==")" roha_session_log "$(printf "Delta minimum : 0")" roha_session_log "$(printf "== Final computation, limits considered ==")" roha_session_log "$(printf "Total : % 7d" ${roha_compute.total_cpu})" roha_session_log "$(printf "Delta acquisition : % 7d" ${roha_compute.cpu})" roha_session_log "$(printf "=================== End =====================")" } # End of "roha_compute_ded_cpu_to_acquire_report()" #============================================================================= # # Name: roha_compute_pvm_cpu_to_release # # Description: Determine how many resources need to be released to fit # remaining RGs. # # Inputs: None # # Outputs: None # # Globals: roha_query # roha_compute # # Returns: RC_SUCCESS # RC_COMPUTE_CPU_ERROR_RATIO # #============================================================================= function roha_compute_pvm_cpu_to_release { [[ $VERBOSE_LOGGING == high ]] && set -x typeset -i rc=$RC_SUCCESS typeset -F4 total_pu=0.00 #======================================================= : If some ACs use profile desired value, start from : there, or else start from the minimum. #======================================================= if (( ${roha_query.running.use_desired_nb} > 0 )) ; then (( roha_compute.raw_total_pu = ${roha_query.lpar.cpu.proc_units.des} + ${roha_query.running.total_pu} )) else (( roha_compute.raw_total_pu = ${roha_query.lpar.cpu.proc_units.min} + ${roha_query.running.total_pu} )) fi roha_compute.total_pu=${roha_compute.raw_total_pu} if (( ${roha_compute.total_pu} < ${roha_query.lpar.cpu.proc_units.curr} )) ; then #======================================================= : Release the difference between current and needed #======================================================= (( roha_compute.pu = ${roha_query.lpar.cpu.proc_units.curr} - ${roha_compute.total_pu} )) #======================================================= : Do not release more than previously acquired. #======================================================= (( roha_compute.pu = $(min ${roha_compute.pu} $(roha_session_read_odm_dynresop "DLPAR_PROC_UNITS")) )) else #======================================================= : There are not enough resources. Do not release any. #======================================================= (( roha_compute.pu = 0.00 )) fi (( roha_compute.total_pu = ${roha_query.lpar.cpu.proc_units.curr} - ${roha_compute.pu} )) return $rc } # End of "roha_compute_pvm_cpu_to_release()" #============================================================================= # # Name: roha_compute_pvm_cpu_to_release_report # # Description: Displays computation results. # # Inputs: None # # Outputs: None # # Globals: roha_query # roha_compute # # Returns: None # #============================================================================= function roha_compute_pvm_cpu_to_release_report { roha_session_log "$(printf "============ Compute ROHA%s CPU(s) ============" "${roha_compute.roha_type}")" roha_session_log "$(printf "== Status Reminder ==")" roha_session_log "$(printf "Current resources : % 7.4f" ${roha_query.lpar.cpu.proc_units.curr})" roha_session_log "$(printf "== Raw computation from AC settings ==")" if (( ${roha_query.running.use_desired_nb} > 0 )) ; then roha_session_log "$(printf "LPAR profile desired : % 7.4f" ${roha_query.lpar.cpu.proc_units.des})" else roha_session_log "$(printf "LPAR profile minimum : % 7.4f" ${roha_query.lpar.cpu.proc_units.min})" fi roha_session_log "$(printf "APPs running : % 7.4f" ${roha_query.running.total_pu})" roha_session_log "$(printf "Total raw : % 7.4f" ${roha_compute.raw_total_pu})" roha_session_log "$(printf "Delta release raw : % 7.4f" ${roha_query.lpar.cpu.proc_units.curr}-${roha_compute.raw_total_pu})" roha_session_log "$(printf "== Maximum limits (adjust at best -except for ratio-).")" roha_session_log "$(printf "Saved ROHA delta acquire : % 7.4f" $(roha_session_read_odm_dynresop "DLPAR_PROC_UNITS"))" roha_session_log "$(printf "== Minimum limits (adjust if under) ==")" roha_session_log "$(printf "Delta minimum : 0.00")" roha_session_log "$(printf "== Final computation, limits considered ==")" roha_session_log "$(printf "Total : % 7.4f" ${roha_compute.total_pu})" roha_session_log "$(printf "Delta release : % 7.4f" ${roha_compute.pu})" roha_session_log "$(printf "=================== End =====================")" } # End of "roha_compute_pvm_cpu_to_release_report()" #============================================================================= # # Name: roha_compute_shd_cpu_to_release # # Description: Determine how many resources need to be released to fit # remaining RGs. # # Inputs: None # # Outputs: None # # Globals: roha_query # roha_compute # # Returns: RC_SUCCESS # RC_COMPUTE_CPU_ERROR_RATIO # #============================================================================= function roha_compute_shd_cpu_to_release { [[ $VERBOSE_LOGGING == high ]] && set -x typeset -i rc=$RC_SUCCESS typeset -F4 total_pu=0.00 typeset -F4 proc_ratio=0.00 #======================================================= : If some ACs use profile desired value, start from : there, or else start from the minimum. #======================================================= if (( ${roha_query.running.use_desired_nb} > 0 )) ; then (( roha_compute.raw_total_vp = ${roha_query.lpar.cpu.procs.des} + ${roha_query.running.total_vp} )) (( roha_compute.raw_total_pu = ${roha_query.lpar.cpu.proc_units.des} + ${roha_query.running.total_pu} )) else (( roha_compute.raw_total_vp = ${roha_query.lpar.cpu.procs.min} + ${roha_query.running.total_vp} )) (( roha_compute.raw_total_pu = ${roha_query.lpar.cpu.proc_units.min} + ${roha_query.running.total_pu} )) fi roha_compute.total_pu=${roha_compute.raw_total_pu} roha_compute.total_vp=${roha_compute.raw_total_vp} if (( ${roha_compute.total_vp} < ${roha_query.lpar.cpu.procs.curr} )) ; then #======================================================= : Release the difference between current and needed #======================================================= (( roha_compute.vp = ${roha_query.lpar.cpu.procs.curr} - ${roha_compute.total_vp} )) #======================================================= : Do not release more than previously acquired. #======================================================= (( roha_compute.vp = $(min ${roha_compute.vp} $(roha_session_read_odm_dynresop "DLPAR_PROCS")) )) else #======================================================= : There are not enough resources. Do not release any. #======================================================= (( roha_compute.vp = 0 )) fi (( roha_compute.total_vp = ${roha_query.lpar.cpu.procs.curr} - ${roha_compute.vp} )) if (( ${roha_compute.total_pu} < ${roha_query.lpar.cpu.proc_units.curr} )) ; then #======================================================= : Release the difference between current and needed #======================================================= (( roha_compute.pu = ${roha_query.lpar.cpu.proc_units.curr} - ${roha_compute.total_pu} )) #======================================================= : Do not release more than previously acquired. #======================================================= (( roha_compute.pu = $(min ${roha_compute.pu} $(roha_session_read_odm_dynresop "DLPAR_PROC_UNITS")) )) else #======================================================= : There are not enough resources. Do not release any. #======================================================= (( roha_compute.pu = 0.00 )) fi (( roha_compute.total_pu = ${roha_query.lpar.cpu.proc_units.curr} - ${roha_compute.pu} )) (( proc_ratio = ${roha_compute.total_pu} / ${roha_compute.total_vp} )) (( total_pu = ${roha_query.cec.cpu.ratio}*${roha_compute.total_vp})) if (( ${roha_compute.total_pu} < $total_pu )) ; then #======================================================= : Notify user. #======================================================= roha_session_log "$(dspmsg -s $ROHA_SET $ROHA_MSGS 115 \ "%1\$s: ERROR: Ratio of %2\$d is not verified by needed %3\$d Virtual Processor(s) and %4\$d Processing Units(s).\n" \ "$PROGNAME" "${roha_query.cec.cpu.ratio}" "${roha_compute.total_vp}" "${roha_compute.total_pu}")" #======================================================= : Optimal resources does not fit the ratio. Do not : release any. #======================================================= (( roha_compute.vp = 0 )) (( roha_compute.pu = 0.00 )) ((roha_compute.total_pu = ${roha_query.lpar.cpu.proc_units.curr} )) ((roha_compute.total_vp = ${roha_query.lpar.cpu.procs.curr})) rc=$RC_COMPUTE_CPU_ERROR_RATIO elif (( ${proc_ratio} > 1.0 )) ; then roha_session_log "$(dspmsg -s $ROHA_SET $ROHA_MSGS 522 \ "%1\$s: ERROR: The total number of virtual processors must be at least equal to the\nwhole number of the total number of processing units, rounded up for any fraction.\nAt least %2\$d virtual processors must be present for %3\$d processing units.\n" "$PROGNAME" "${required_vp}" "${roha_compute.total_pu}")" #======================================================= : Optimal resources does not fit the ratio. Do not : release any. #======================================================= (( roha_compute.vp = 0 )) (( roha_compute.pu = 0.00 )) ((roha_compute.total_pu = ${roha_query.lpar.cpu.proc_units.curr} )) ((roha_compute.total_vp = ${roha_query.lpar.cpu.procs.curr})) rc=$RC_COMPUTE_CPU_ERROR_RATIO fi return $rc } # End of "roha_compute_shd_cpu_to_release()" #============================================================================= # # Name: roha_compute_shd_cpu_to_release_report # # Description: Displays computation results. # # Inputs: None # # Outputs: None # # Globals: roha_query # roha_compute # # Returns: None # #============================================================================= function roha_compute_shd_cpu_to_release_report { roha_session_log "$(printf "========== Compute ROHA PU(s)/VP(s) =========")" roha_session_log "$(printf "== Status Reminder ==")" roha_session_log "$(printf "Current resources : % 7.4f / %3d" ${roha_query.lpar.cpu.proc_units.curr} ${roha_query.lpar.cpu.procs.curr})" roha_session_log "$(printf "== Raw computation from AC settings ==")" if (( ${roha_query.running.use_desired_nb} > 0 )) ; then roha_session_log "$(printf "LPAR profile desired : % 7.4f / %3d" ${roha_query.lpar.cpu.proc_units.des} ${roha_query.lpar.cpu.procs.des})" else roha_session_log "$(printf "LPAR profile minimum : % 7.4f / %3d" ${roha_query.lpar.cpu.proc_units.min} ${roha_query.lpar.cpu.procs.min})" fi roha_session_log "$(printf "APPs running : % 7.4f / %3d" ${roha_query.running.total_pu} ${roha_query.running.total_vp})" roha_session_log "$(printf "Total raw : % 7.4f / %3d" ${roha_compute.raw_total_pu} ${roha_compute.raw_total_vp})" roha_session_log "$(printf "Delta release raw : % 7.4f / %3d" ${roha_query.lpar.cpu.proc_units.curr}-${roha_compute.raw_total_pu} ${roha_query.lpar.cpu.procs.curr}-${roha_compute.raw_total_vp})" roha_session_log "$(printf "Raw PU/VP ratio : % 7.4f" ${roha_compute.raw_total_pu}/${roha_compute.raw_total_vp})" roha_session_log "$(printf "== Maximum limits (adjust at best -except for ratio-).")" roha_session_log "$(printf "Saved ROHA delta acquire : % 7.4f / %3d" $(roha_session_read_odm_dynresop "DLPAR_PROC_UNITS") $(roha_session_read_odm_dynresop "DLPAR_PROCS"))" roha_session_log "$(printf "PU/VP ratio : % 7.4f (ratio cannot be lower, checked after other limits)." ${roha_query.cec.cpu.ratio})" roha_session_log "$(printf "== Minimum limits (adjust if under) ==")" roha_session_log "$(printf "Delta minimum : 0.00 / 0")" roha_session_log "$(printf "== Final computation, limits considered ==")" roha_session_log "$(printf "Total : % 7.4f / %3d" ${roha_compute.total_pu} ${roha_compute.total_vp})" roha_session_log "$(printf "Delta release : % 7.4f / %3d" ${roha_compute.pu} ${roha_compute.vp})" roha_session_log "$(printf "PU/VP ratio : % 7.4f" ${roha_compute.total_pu}/${roha_compute.total_vp})" roha_session_log "$(printf "=================== End =====================")" } # End of "roha_compute_shd_cpu_to_release_report()" #============================================================================= # # Name: roha_compute_ded_cpu_to_release # # Description: Determine how many resources need to be released to fit # remaining RGs. # # Inputs: None # # Outputs: None # # Globals: roha_query # roha_compute # # Returns: RC_SUCCESS # #============================================================================= function roha_compute_ded_cpu_to_release { [[ $VERBOSE_LOGGING == high ]] && set -x typeset -i rc=$RC_SUCCESS #======================================================= : If some ACs use profile desired value, start from : there, or else start from the minimum. #======================================================= if (( ${roha_query.running.use_desired_nb} > 0 )) ; then (( roha_compute.raw_total_cpu = ${roha_query.lpar.cpu.procs.des} + ${roha_query.running.total_cpu} )) else (( roha_compute.raw_total_cpu = ${roha_query.lpar.cpu.procs.min} + ${roha_query.running.total_cpu} )) fi roha_compute.total_cpu=${roha_compute.raw_total_cpu} if (( ${roha_compute.total_cpu} < ${roha_query.lpar.cpu.procs.curr} )) ; then #======================================================= : Release the difference between current and needed #======================================================= (( roha_compute.cpu = ${roha_query.lpar.cpu.procs.curr} - ${roha_compute.total_cpu} )) #======================================================= : Do not release more than previously acquired. #======================================================= (( roha_compute.cpu = $(min ${roha_compute.cpu} $(roha_session_read_odm_dynresop "DLPAR_PROCS")) )) else #======================================================= : There are not enough resources. Do not release any. #======================================================= (( roha_compute.cpu = 0 )) fi (( roha_compute.total_cpu = ${roha_query.lpar.cpu.procs.curr} - ${roha_compute.cpu} )) return $rc } # End of "roha_compute_ded_cpu_to_release()" #============================================================================= # # Name: roha_compute_ded_cpu_to_release_report # # Description: Displays computation results. # # Inputs: None # # Outputs: None # # Globals: roha_query # roha_compute # # Returns: None # #============================================================================= function roha_compute_ded_cpu_to_release_report { roha_session_log "$(printf "============ Compute ROHA CPU(s) ============")" roha_session_log "$(printf "== Status Reminder ==")" roha_session_log "$(printf "Current resources : % 7d" ${roha_query.lpar.cpu.procs.curr})" roha_session_log "$(printf "== Raw computation from AC settings ==")" if (( ${roha_query.running.use_desired_nb} > 0 )) ; then roha_session_log "$(printf "LPAR profile desired : % 7d" ${roha_query.lpar.cpu.procs.des})" else roha_session_log "$(printf "LPAR profile minimum : % 7d" ${roha_query.lpar.cpu.procs.min})" fi roha_session_log "$(printf "APPs running : % 7d" ${roha_query.running.total_cpu})" roha_session_log "$(printf "Total raw : % 7d" ${roha_compute.raw_total_cpu})" roha_session_log "$(printf "Delta release raw : % 7d" ${roha_query.lpar.cpu.procs.curr}-${roha_compute.raw_total_cpu})" roha_session_log "$(printf "== Maximum limits (adjust at best) ==")" roha_session_log "$(printf "Saved ROHA delta acquire : % 7d" $(roha_session_read_odm_dynresop "DLPAR_PROCS"))" roha_session_log "$(printf "== Minimum limits (adjust if under) ==")" roha_session_log "$(printf "Delta minimum : 0")" roha_session_log "$(printf "== Final computation, limits considered ==")" roha_session_log "$(printf "Total : % 7d" ${roha_compute.total_cpu})" roha_session_log "$(printf "Delta release : % 7d" ${roha_compute.cpu})" roha_session_log "$(printf "=================== End =====================")" } # End of "roha_compute_ded_cpu_to_release_report()"