четверг, 13 августа 2015 г.

EM12c Target Lifecycle Status change script

Петя написал скрипт для смены Lifecycle Status таргетов EM 12c.




#!/bin/bash
# Modify params for you grid ###################@
export ORACLE_HOME=/opt/oracle/mw_home_oms/oms
export PATH=$ORACLE_HOME/emcli:$PATH
#################################################
read -p "Enter weblogic Unique Domain Identifier : " WL_UID
read -p "Enter New Lifecycle Status : " LStatus

#read -p "Enter sysman password : " SYSMAN_PASSWD

emcli list_active_sessions >/dev/null 2>&1
if [ "$?" == "255" ]
then
        read -s -p "Enter sysman password: " SYSMAN_PASSWD
        emcli login -username=sysman -password=$SYSMAN_PASSWD >/dev/null 2>&1
        #echo "Error: Session expired. Run emcli login to establish a session."
fi

echo -n "Generate list targets for modify... "
emcli get_targets -noheader -script|grep "$WL_UID"|sed 's/Status Pending/StatusPending/g'|sed 's/Under Blackout/UnderBlackout/g'|awk -v lstatus=$LStatus '{for(i=4;i<NF;i++)printf "%s",$i OFS; if (NF) printf "%s",$NF;print ":"$3":LifeCycle Status:"lstatus}' > ./targets.lst
if [ ! -s targets.lst ]
then
        echo "Target not found!"
        exit 1
fi
if [ "$?" = 0 ]
then
        echo "Successful."
else
        echo "Error"
        exit 1;
fi
echo -n "Import modify LifeCycle Status for $WL_UID... "
emcli set_target_property_value -property_records="REC_FILE" -input_file="REC_FILE:./targets.lst" -separator=property_records="\n"
#rm ./targets.lst
exit 0

Комментариев нет:

Отправить комментарий