ADRCI: Auto Purge Those Old Alerts

Abstract:

Use shell scripts to apply purge policies to multiple ADR Homes.

Below is a listing of the scripts found on the interwebs used in this article. We’ll be using them in examples below. Useful if you have many ADR Homes set and/or many databases to control.
I have one server with 34 ADR Homes and am too lazy to check them all individually. If you cut and paste the scripts remember to chmod u+x so they will execute.

These examples run on Linux_x64 and Oracle 12.1.0.2

The Scripts:

adrci_show_control.sh

for f in $( adrci exec=”show homes” | grep -v “ADR Homes:” );
do
echo “SHOW CONTROL ${f}:”;
adrci exec=”set home $f; show control;” ;
done

adrci_set_control.sh

for f in $( adrci exec=”show homes” | grep -v “ADR Homes:” );
do
echo “set control ${f}:”;
adrci exec=”set home $f; set control \(SHORTP_POLICY=720, LONGP_POLICY=8760\);” ;
done

adrci_purge.sh

for f in $( adrci exec=”show homes” | grep -v “ADR Homes:” );
do
echo “purge ${f}:”;
adrci exec=”set home $f; show control; purge” ;
done

adrci_purge_man.sh

for f in $( adrci exec=”show homes” | grep -v “ADR Homes:” );
do
echo “purge ${f}:”;
adrci exec=”set home $f; show control; purge” ;
done

Steps:

The first script adrci_show_control.sh will show the current settings for short and long term retention for all the ADR Homes.

Which policy controls what directory? Doc ID 975448.1 –

LONGP_POLICY is used to purge information that have long life. Default value is 365 days.

This policy is used by :

ALERT
INCIDENT
SWEEP
STAGE
HM

SHORTP_POLICY is used to purge the information that have short life. Default value is 30 days.

This policy is used by :

TRACE
CDUMP
UTSCDMP
IPS

We can also see the last time auto or manual purge has been run.

Example of output from adrci_show_control.sh:

oracle>./adrci_show_control.sh

SHOW CONTROL diag/rdbms/db1/db1:

ADR Home = /u01/app/oracle/diag/rdbms/db1/db1:
*************************************************************************
ADRID SHORTP_POLICY LONGP_POLICY LAST_MOD_TIME LAST_AUTOPRG_TIME LAST_MANUPRG_TIME ADRDIR_VERSION ADRSCHM_VERSION ADRSCHMV_SUMMARY ADRALERT_VERSION CREATE_TIME
——————– ——————– ——————– —————————————- —————————————- —————————————- ——————– ——————– ——————– ——————– —————————————-
1081481004 720 8760 2017-03-27 09:47:28.802731 -07:00 2017-04-25 07:30:02.538228 -07:00 1 2 82 1 2017-03-27 09:47:28.802731 -07:00
1 rows fetched

This monitored directory still has the defaults of SHORTP_POLICY at 720 hours (30 days) and LONGP_POLICY at 8760 hours( 1 year). now one year is a bit long for my purposes so I’ll change it to 4320 hours (180 days). This will only effect the regular trace files. Incidents are kept for 1 year via the LONGP_POLICY.

The second script adrci_set_control.sh can set the policies for regular trace file retention for all the ADR homes. I’ll keep the short term policy at 720 hours and shorten the long term to 180 days. Modify the line:

From:

adrci exec=”set home $f; set control \(SHORTP_POLICY=720, LONGP_POLICY=8760\);” ;

To:

adrci exec=”set home $f; set control \(SHORTP_POLICY=720, LONGP_POLICY=4320\);” ;

Then execute the script adrci_set_control.sh:

oracle>./adrci_set_control.sh

set control diag/tnslsnr/server1/listener_db1:
set control diag/rdbms/db1/db1:

Let’s now verify the setting are correct, execute adrci_show_control.sh:

ADR Home = /u01/app/oracle/diag/rdbms/db1/db1:
*************************************************************************
ADRID SHORTP_POLICY LONGP_POLICY LAST_MOD_TIME LAST_AUTOPRG_TIME LAST_MANUPRG_TIME ADRDIR_VERSION ADRSCHM_VERSION ADRSCHMV_SUMMARY ADRALERT_VERSION CREATE_TIME
——————– ——————– ——————– —————————————- —————————————- —————————————- ——————– ——————– ——————– ——————– —————————————-
3448104258 720 4320 2017-04-26 08:02:28.898193 -07:00 2017-04-25 07:28:00.743201 -07:00 1 2 82 1 2017-03-27 10:46:21.921133 -07:00
1 rows fetched

We can see the long term policy is now set to 4320 hours (180 days).

The third script adrci_purge.sh lets run a purge using our existing settings anytime
we want. This might become necessary as sometimes MMON doesn’t do it’s thing via
autopurge. Check OWS bug notes for your version of Oracle.

oracle>./adrci_purge.sh

purge diag/rdbms/db1/db1:

ADR Home = /u01/app/oracle/diag/rdbms/db1/db1:
*************************************************************************
ADRID SHORTP_POLICY LONGP_POLICY LAST_MOD_TIME LAST_AUTOPRG_TIME LAST_MANUPRG_TIME ADRDIR_VERSION ADRSCHM_VERSION ADRSCHMV_SUMMARY ADRALERT_VERSION CREATE_TIME
——————– ——————– ——————– —————————————- —————————————- —————————————- ——————– ——————– ——————– ——————– —————————————-
3448104258 720 4320 2017-04-26 08:02:28.898193 -07:00 2017-04-25 07:28:00.743201 -07:00 1 2 82 1 2017-03-27 10:46:21.921133 -07:00
1 rows fetched
We’ve now gone through the full cycle of checking, setting and purging based on the policies settings. A great method of updating controls for all Oracle ADR homes on a server. I hope this helps your efficiency in establishing your organizations controls and retention policies for maintaining metadata.

Cheers,

https://theoracleguy.blog

One thought on “ADRCI: Auto Purge Those Old Alerts

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s