Subscribe to Posts by Email

Subscriber Count

    696

Disclaimer

All information is offered in good faith and in the hope that it may be of use for educational purpose and for Database community purpose, but is not guaranteed to be correct, up to date or suitable for any particular purpose. db.geeksinsight.com accepts no liability in respect of this information or its use. This site is independent of and does not represent Oracle Corporation in any way. Oracle does not officially sponsor, approve, or endorse this site or its content and if notify any such I am happy to remove. Product and company names mentioned in this website may be the trademarks of their respective owners and published here for informational purpose only. This is my personal blog. The views expressed on these pages are mine and learnt from other blogs and bloggers and to enhance and support the DBA community and this web blog does not represent the thoughts, intentions, plans or strategies of my current employer nor the Oracle and its affiliates or any other companies. And this website does not offer or take profit for providing these content and this is purely non-profit and for educational purpose only. If you see any issues with Content and copy write issues, I am happy to remove if you notify me. Contact Geek DBA Team, via geeksinsights@gmail.com

Pages

Script: Grid Control: Logs cleanup, housekeeping OMS logs in 11g and 12c

OMS (Enterprise Manager) is generating huge quatity of logs. Logs generated by the Grid Infrastructure are spread across modules.
There are logs for http Apache module, log for Infrastructure, agents logs and traces, opmn logs etc.

Here are the location of logs that use a lot of disk space:

1) Agent Log and Trace Files:
[oracle@myserver midw]$ cd $ORACLE_MIDW_HOME/agent/core/12.1.0.1.0/bin/
[oracle@myserver bin]$ ./emctl getemhome
Oracle Enterprise Manager 12c Cloud Control 12.1.0.1.0
Copyright (c) 1996, 2011 Oracle Corporation. All rights reserved.
EMHOME=/u01/products/midw/agent/agent_inst

2) log and trace files will be located at /sysman/log
[oracle@myserver bin]$ cd /u01/oracle/midw/agent/agent_inst/sysman/log/

3) For Oracle Management Service Log and Trace Files:
/em//sysman/log/
[oracle@myserver log]$ cd /u01/oracle/midw/gc_inst/em/EMGC_OMS1/sysman/log/
[oracle@myserver log]$ pwd
/u01/oracle/midw/gc_inst/em/EMGC_OMS1/sysman/log

4) Oracle HTTP Server (OHS) -//diagnostics/logs/OHS/
/u01/oracle/midw/gc_inst/WebTierIH1/diagnostics/logs/OHS/ohs1

5) OPMN//diagnostics/logs/OPMN/
/u01/oracle/midw/gc_inst/WebTierIH1/diagnostics/logs/OPMN/opmn

6) Oracle WebLogic -/user_projects/domains//servers//logs/.log
/u01/oracle/midw/gc_inst/user_projects/domains/GCDomain/servers/EMGC_OMS1/logs/EMGC_OMS1.log

Oracle maintain rotates all above logs using log sizes etc in respective configurations but it wont delete the old files. We have to manually cleanup those.
Log rotations see here:- http://docs.oracle.com/cd/E11857_01/em.111/e16790/logging.htm
Reference Oracle Support (metalink) note:1271676.1

Script for cleaning Enterprise Manager 11g - Grid Control

#!/bin/sh

#find logs older then 15 days and remove them from disk
find /u01/oracle/gc_inst/user_projects/domains/GCDomain/servers/EMGC_OMS1/logs/ -name "access.log*" -mtime +15 -print|xargs rm
find /home/oracle/oradiag_oracle/diag/clients/user_oracle/host_1387324873_11/alert  -name "log_*.xml" -mtime +15 -print|xargs rm
find /u01/oracle/gc_inst/user_projects/domains/GCDomain/servers/EMGC_OMS1/logs/ -name "EMGC_OMS1.log*" -mtime +15 -print|xargs rm
find /u01/oracle/gc_inst/user_projects/domains/GCDomain/servers/EMGC_OMS1/logs/ -name "EMGC_OMS1.out*" -mtime +15 -print|xargs rm
find /u01/oracle/gc_inst/user_projects/domains/GCDomain/servers/EMGC_OMS1/logs/ -name "EMGC_OMS1-diagnostic*.log" -mtime +15 -print|xargs rm
find /u01/oracle/gc_inst/WebTierIH1/diagnostics/logs/OHS/ohs1/  -name "access_log*" -mtime +15 -print|xargs rm
find /u01/oracle/gc_inst/WebTierIH1/diagnostics/logs/OHS/ohs1/  -name "em_upload_https_access_log*" -mtime +15 -print|xargs rm
find /u01/oracle/gc_inst/WebTierIH1/diagnostics/logs/OHS/ohs1/  -name "ohs1-*.log" -mtime +15 -print|xargs rm

#manually rotate the logs. other way is to follow metalink note:1271676.1
#how to automaticaly rotate logs in Enterprise Manager 11g

export DATE_VAR=`date '+%d%m%Y'`
#create a copy of the log with the stampdate appended to filename
cat /u01/oracle/gc_inst/WebTierIH1/diagnostics/logs/OHS/ohs1/mod_wl_ohs.log>/u01/oracle/gc_inst/WebTierIH1/diagnostics/logs/OHS/ohs1/mod_wl_ohs_$DATE_VAR.log
>/u01/oracle/gc_inst/WebTierIH1/diagnostics/logs/OHS/ohs1/mod_wl_ohs.log

add this in crontab:

0 0 * * * /home/oracle/scripts/cleanLOGSgrid.sh > /home/oracle/scripts/cleanLOGSgrid.log 2>&1

Script for cleaning Enterprise Manager 12c - Grid Control


#!/bin/sh

#find and clean Oracle 12c Agent log files older then 30 days

find /u01/oracle/midw/agent/agent_inst/sysman/log/ -name "gcagent.log.*" -mtime +30 -print|xargs rm
#find and clean Oracle 12c OMS log files older then 30 days
find /u01/oracle/midw/gc_inst/em/EMGC_OMS1/sysman/log/ -name "emoms.trc*" -mtime +30 -print|xargs rm
find /u01/oracle/midw/gc_inst/em/EMGC_OMS1/sysman/log/ -name "emctl.log.*" -mtime +30 -print|xargs rm
#find and clean Oracle 12c Oracle HTTP Server (OHS) log files older then 30 days
find /u01/oracle/midw/gc_inst/WebTierIH1/diagnostics/logs/OHS/ohs1/  -name "access_log*" -mtime +30 -print|xargs rm
find /u01/oracle/midw/gc_inst/WebTierIH1/diagnostics/logs/OHS/ohs1/  -name "em_upload_https_access_log*" -mtime +30 -print|xargs rm
find /u01/oracle/midw/gc_inst/WebTierIH1/diagnostics/logs/OHS/ohs1/  -name "ohs1-*.log" -mtime +30 -print|xargs rm
#find and clean Oracle 12c Oracle WebLogic log files older then 30 days
find /u01/oracle/midw/gc_inst/user_projects/domains/GCDomain/servers/EMGC_OMS1/logs/ -name "access.log*" -mtime +30 -print|xargs rm
find /u01/oracle/midw/gc_inst/user_projects/domains/GCDomain/servers/EMGC_OMS1/logs/ -name "EMGC_OMS1.log*" -mtime +30 -print|xargs rm
find /u01/oracle/midw/gc_inst/user_projects/domains/GCDomain/servers/EMGC_OMS1/logs/ -name "EMGC_OMS1.out*" -mtime +30 -print|xargs rm
find /u01/oracle/midw/gc_inst/user_projects/domains/GCDomain/servers/EMGC_OMS1/logs/ -name "EMGC_OMS1-diagnostic*.log" -mtime +30 -print|xargs rm
find /u01/oracle/midw/gc_inst/user_projects/domains/GCDomain/servers/EMGC_ADMINSERVER/logs -name "EMGC_ADMINSERVER.out*" -mtime +30 -print|xargs rm
find /u01/oracle/midw/gc_inst/user_projects/domains/GCDomain/servers/EMGC_ADMINSERVER/logs -name "GCDomain.log*" -mtime +30 -print|xargs rm
#find and clean Oracle 12c OPMN log files older then 30 days
/u01/oracle/midw/gc_inst/WebTierIH1/diagnostics/logs/OPMN/opmn
#find and clean Oracle 12c diagnose folder in oracle home log files older then 30 days
find /home/oracle/oradiag_oracle/diag/clients/user_oracle/host_1387324873_11/alert  -name "log_*.xml" -mtime +30 -print|xargs rm
#the next line is commented for know because on 12c I disabled the module according to metalink note:1396472.1
cat /u01/oracle/gc_inst/WebTierIH1/diagnostics/logs/OHS/ohs1/mod_wl_ohs.log>/u01/oracle/gc_inst/WebTierIH1/diagnostics/logs/OHS/ohs1/mod_wl_ohs_$DATE_VAR.log >/u01/oracle/gc_inst/WebTierIH1/diagnostics/logs/OHS/ohs1/mod_wl_ohs.log

add this in crontab:

0 0 * * * /home/oracle/scripts/cleanLOGSgrid.sh > /home/oracle/scripts/cleanLOGSgrid.log 2>&1

Hope this helps.
-Thanks
Geek DBA

Comments are closed.