Tags

,

All those limited duration or one-time blackouts need to be manually cleaned after they end or are stopped.  This combination of database query and EM CLI command does the job quickly and easily.

$ECHO "\n\nGathering current-state information from OEM repository\n"
sqlplus -s ${SYSMAN_CONNECT} <<EOF
SET echo OFF
SET feedback OFF verify OFF heading OFF 
SET lines 150 pages 999

spool ${BLACKOUT_LIST}
SELECT DISTINCT 'delete_blackout -name="'
     ||a.blackout_name
     ||'" -createdby="'
     ||b.created_by
     ||'"'
FROM mgmt\$blackout_history a, 
     mgmt\$blackouts b
WHERE a.blackout_guid = b.blackout_guid
AND b.status IN ('Ended', 'Stopped')
AND schedule_type = 'One Time'
AND last_end_time < SYSDATE - 1;

spool off
exit
EOF

if [ `cat ${BLACKOUT_LIST} | wc -l` -gt 0 ]; then
 emcli login -username="SYSMAN" -password="${SYSMAN_PWD}" 2>/dev/null
 emcli sync 2>/dev/null 
 emcli argfile ${BLACKOUT_LIST}
 emcli logout
fi

[ $BLACKOUT_LIST ] && rm -f ${BLACKOUT_LIST}
unset SYSMAN_CONNECT
unset SYSMAN_PWD