Database Reference
In-Depth Information
if [ `emcli get_blackouts | grep ${BO_NAME} | wc -l` -gt 0 ]; then
$ECHO "\n\nFound an existing blackout named ${BO_NAME}"
$ECHO "That blackout will be stopped and deleted prior to starting the new one\n\n"
emcli stop_blackout -name="${BO_NAME}"
emcli delete_blackout -name="${BO_NAME}"
fi
emcli create_blackout
-name="${BO_NAME}"
-add_targets="${thisTARGET}:oracle_database"
-schedule="duration::360"
-reason="Scripted blackout for maintenance or refresh"
sleep 5
echo "\n\nGetting blackout information for '${BO_NAME}' ...\n\n"
emcli get_blackout_details -name="${BO_NAME}"
There are several things to notice in this short script:
•
Each blackout name must be unique, so this script requires some portion of the name to be
passed at the command line. In this example we pass the SID.
•
User communication is important anytime, so be complete and be concise. Your echo's
statements are useful at run-time and essential in the log file.
•
This planned blackout will run six hours (
duration:360
) maximum, so you want to delete an
existing blackout of the same name to get all six hours.
•
Notice that the
stop_blackout
and
delete_blackout
verbs take the blackout name as their
only input value. You must stop a blackout before you can delete it.
•
The test for blackout status is important for the run-time log file.
In practice, this appears as a series of wrap-around entries in the crontab, like this:
25 19 * * * /scripts/oem/create_blackout.sh gold
30 19 * * * /scripts/refresh/restore_training.sh gold
30 20 * * * /scripts/oem/end_blackout.sh gold
When you start a blackout you should also plan on stopping it. This side of the scripted pair is simpler, of course,
because there is a lot less to do:
#!/bin/sh
# =====================================================
# File: end_blackout.sh
# Purpose: End an OEM blackout
# Parameters: Blackout name as BO_NAME
# =====================================================
export BO_NAME=${1}_scripted_blackout
echo "\n\nStopping blackout named '${BO_NAME}' ...\n"
if [ `emcli get_blackouts | grep ${BO_NAME} | wc -l` -gt 0 ]; then
$ECHO "\n\nFound an existing blackout named ${BO_NAME}"
emcli stop_blackout -name="${BO_NAME}"
emcli delete_blackout -name="${BO_NAME}"
fi
Search WWH ::
Custom Search