#!/bin/Bash forXinch$ (cf a|grepstarted|TR-S" "|Cut-D" "-F1) Doins_quantity=$ (cf a|grep$x |TR-S" "|Cut-D" "-F3|Cut-D"/"-F2); App_memory=$ (cf a|grep$x |TR-S" "|Cut-D" "-F4); Echo "AppName:"$xEcho "Instance num:"${ins_quantity}; Unit_suffix=`Echo${app_memory:-1}`; if[[$unit _suffix = ="G"]]; ThenApp_memory_num=`Echo${app_memory%g*}`; elif[[$unit _suffix = ="M"]]; ThenApp_memory_num=`Echo${app_memory%m*}`; Else Echo "Erros:unit_suffix Get fail!"Exit1; fi Echo "app_memory Num:"${app_memory_num}; Echo "Unit_suffix:"${unit_suffix}; strategy_name="" Case$app _memory_numinch +) Strategy_name="m0.5c25" ;; 1) Strategy_name="M1C50" ;; 1.5) Strategy_name="m1.5c75" ;; 2) Strategy_name="m2c100" ;; 2.5) Strategy_name="m2.5c125" ;; 3) Strategy_name="m3c150" ;; 3.5) Strategy_name="m3.5c175" ;; 4) Strategy_name="m4c200" ;; Esac Echo "Strategy_name:"$strategy _nameif[[$ins _quantity-ge2&& $strategy _name! =""]]; Then Echo "ASPT bind-a"$x"- P"$strategy _name"- e true"; ASPT Bind-A $x-p $strategy _name-etrue; Else Echo "Appanme:"$x"Is isn't set auto scale! Because ins num too small!" fi; Done
Automatically match and bind auto scaling policy "shell" based on memory size