Shell script for Automatic Awr Report
Hi Good Morning,
I have a requirement to generate the AWR report daily between (10AM - 06PM , 10AM - 01PM , 01PM - 10PM) . I have the below script for this . But the issue is this script is working only when i run it two times and before running i have to delete snap_list.lst file. Please let me know what is the problem in this script and how to resolve it.
Script :
dt=`date +%d%m%Y`
cd /orabkp/awr_report
chmod 777 *
rm -rf snap_list.lst
touch snap_list.lst
#rm -rf snap_list.lst
#rm -rf snap_list.lst
sqlplus -s " /as sysdba " <<EOF > snap_list.lst
host sleep 10
@/oracle/scripts/cron_scripts/rpt1.sql;
@?/rdbms/admin/awrrpt.sql
HTML
1
`cat snap_list.lst | grep "10:0" | awk '{print $1}'`
`cat snap_list.lst | grep "13:0" | awk '{print $1}'`
awrrpt\_$dt\_10AM\-01PM.html
prompt 2
@?/rdbms/admin/awrrpt.sql
HTML
1
`cat snap_list.lst | grep "13:0" | awk '{print $1}'`
`cat snap_list.lst | grep "18:0" | awk '{print $1}'`
awrrpt\_$dt\_01PM\-06PM.html
@?/rdbms/admin/awrrpt.sql
HTML
1
`cat snap_list.lst | grep "10:0" | awk '{print $1}'`
`cat snap_list.lst | grep "18:0" | awk '{print $1}'`
awrrpt\_$dt\_10AM\-06PM.html
@?/rdbms/admin/addmrpt.sql
`cat snap_list.lst | grep "06:0" | awk '{print $1}'`
`cat snap_list.lst | grep "12:0" | awk '{print $1}'`
ADDM_REPORT\_$dt\_10AM\-06PM.txt
EOF
exit
cat /oracle/scripts/cron_scripts/rpt1.sql
host echo 1
host sleep 10
@?/rdbms/admin/awrrpt.sql
HTML
1
`cat snap_list.lst | grep "10:0" | awk '{print $1}'`
`cat snap_list.lst | grep "13:0" | awk '{print $1}'`
awrrpt\_$dt\_10AM\-01PM.html
Regards
Rajasekar
Hi,
Modify & Try this script used for rac awr ..
#!/bin/ksh
set -x
ORACLE_SID=DBSID
ORACLE_HOME=/u01/app/ora11g/product/11.2.0/db_1
export ORACLE_HOME
TERM=vt100
export TERM
PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/local/bin:/usr/bin/X11:/bin:/sbin:.
PATH=$ORACLE_HOME/bin:$PATH
export DT=`date '+%d_%b_%Y_%HH_%MM'`
export ORACLE_BASE ORACLE_SID ORACLE_HOME PATH DT
echo $DT
MAIL="[email protected]"
CMAIL="[email protected]"
AWRR="/u01/DBA_Scripts/AWR_REPO"
sqlplus -s "/ as sysdba"<<EOFSQL
set head off
set feed off
spool /tmp/bsnap.lst
select max(SNAP_ID)- 3 from dba_hist_snapshot;
spool off
spool /tmp/esnap.lst
select max(SNAP_ID) from dba_hist_snapshot;
spool off
spool /tmp/iname.lst
select instance_name from v\$instance;
spool off
spool /tmp/dname.lst
select database_name from v\$database;
spool off
spool /tmp/inum.lst
select instance_number from v\$instance;
spool off
spool /tmp/dbid.lst
select dbid from v\$database;
spool off
EOFSQL
BSNAP=`cat /tmp/bsnap.lst | tail -1 | awk '{ print $1}'`;export BSNAP
ESNAP=`cat /tmp/esnap.lst | tail -1 | awk '{ print $1}'`;export ESNAP
INAME=`cat /tmp/iname.lst | tail -1 | awk '{ print $1}'`;export INAME
DNAME=`cat /tmp/dname.lst | tail -1 | awk '{ print $1}'`;export DNAME
INUM=`cat /tmp/inum.lst | tail -1 | awk '{ print $1}'`;export INUM
DID=`cat /tmp/dbid.lst| tail -1 | awk '{ print $1}'`;export DID
echo "Begin Snap : $BSNAP"
echo "End Snap : $ESNAP"
#echo "InstanceName: $INAME"
echo "DB Name : $DNAME"
#echo "InstanceId : $INUM"
echo "DB ID : $DID"
sqlplus -s "/ as sysdba"<<EOFSQL
define inst_num = $INUM;
define num_days = 12;
define inst_name = 'ALL';
define db_name = '$DNAME';
define dbid = $DID;
define begin_snap = $BSNAP;
define end_snap = $ESNAP;
define report_type = 'html';
define report_name = $AWRR/Awr_report_$DT.html
@@?/rdbms/admin/awrgrpti
EOFSQL
cat /u01/DBA_Scripts/mail_body.txt | mailx -a $AWRR/Awr_report_$DT.html -c $CMAIL -s "DB Report - DB " $MAILThanks,
Ajay More
http://www.moreajays.com
Similar Messages
-
Shell Script for automatic backup
Hello Every one,
We have windows network and sun solaris sparc box. (both from Sun Box and from Windows machine I can communcate using Telnet.)
I wish to take data backup of a system having windows operating system, into
the sun solaris sparc box automatically by week end .
Can anyone help me with the shell script which does this operation.
Regards,
Dwarakfirst of all, is there nfs running? and on windoze box, do u have any nfs client program running?
you cant transfer files frm the windoze machine via telnet..
once you can settle the above, what you can do is a simple copy script and put it in your crontab. -
Shell script for batch compilation of forms 10g on AIX 5.3L AS
Hi All,
Can anybody provide me the Shell script for batch compilation of forms 10g and reports 10g on AIX 5.3L AS?
Regards,
SAMHi Alex,
I tried with the below script as well as the one you had posted.
ORACLE_HOME=/opt/oracle/OraHome_3
export ORACLE_HOME
TNS_ADMIN=$ORACLE_HOME/network/admin
export TNS_ADMIN
LIBPATH=$ORACLE_HOME/lib32:$ORACLE_HOME/jdk/jre/bin:$ORACLE_HOME/jdk/jre/bin/cla
ssic:$LIBPATH
export LIBPATH
cd ../forms
for i in `ls *.pll`
do
echo Compiling Library $i ....
$ORACLE_HOME/bin/frmcmp module=$i userid=mydbuser/mydbuser@mydb
batch=yes module_type=library
compile_all=yes window_state=minimize
done
export ORACLE_HOME=/opt/oracle/OraHome_3
export ORACLE_TERM=vt220
export LD_LIBRARY_PATH=/opt/oracle/OraHome_3/lib:/opt/oracle/OraHome_3/jdk/jre/l
ib:/opt/oracle/OraHome_3/jdk/jre/lib/i386:
cd ../forms
for i in `ls *.pll`
do
echo "Compiling Library $i ...."
/opt/oracle/OraHome_3/bin/frmcmp module_type=form userid=mydbuser/mydbuser@mydb
module=$i batch=yes compile_all=no
window_state=minimize upgrade=no
done
echo "PLL Compilation done"
But there was a same kind of error thst turning up all the time.
Compiling Library Agf.pll ....
Forms 10.1 (Form Compiler) Version 10.1.2.0.2 (Production)
Forms 10.1 (Form Compiler): Release - Production
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
PL/SQL Version 10.1.0.4.2 (Production)
Oracle Procedure Builder V10.1.2.0.2 - Production
Oracle Virtual Graphics System Version 10.1.2.0.0 (Production)
Oracle Multimedia Version 10.1.2.0.2 (Production)
Oracle Tools Integration Version 10.1.2.0.2 (Production)
Oracle Tools Common Area Version 10.1.2.0.2
Oracle CORE 10.1.0.4.0 Production
FRM-10043: Cannot open file.
Form not created
I hence updated the permissions on the pll as below
-rwxrwxrwx 1 oracle oinstall 335872 May 19 16:31 Agf.pll
But the problem is still persisting.
My environment details are as below.
I am working on Win XP machine. Connected to my AS via telnet and xmanager. I have set my DISPLAY to my local IP.
Is there any thing more that I need to do? If so then let me know.
Regards,
SAM -
Problem executing shell script for rwrun
hi..
I wrote a shell script to make a report similar to the batch file in windows.
My OS is Suse 8.0 with oracle installed in it..
I have the script like this..I used 2 lexical parameters for my rep file.
/opt/oracle/OraHome1/bin/rwrun.sh test techy/techy@simone batch=yes desname=test_3.pdf destype=file desformat=pdf atable=\'\' whereford=\'protokolle.haendlernummer=\'Ludwigsburg\' and\'
This one works fine but the one below doesn't give any output. The pdf fiel is just empty. I wonder y,,may be any problems with the spaces or escape characters.I didn't get any error when executed the scripts.
/opt/oracle/OraHome1/bin/rwrun.sh test techy/techy@simone batch=yes desname=test_3.pdf destype=file desformat=pdf atable=\'\' whereford=\'protokolle.haendlernummer like \'L%\' and\'
thanx and waiting for soem one to answer..
regards
KoviI solved it by doing the following..
opt/oracle/OraHome1/bin/rwrun.sh test techy/techy@simone batch=yes desname=test_3.pdf destype=file desformat=pdf atable=\\'\\' whereford=\\'\\ protokolle.haendlernummer\\ like\\ \\'L%\\'\\ and\\'
from the Java Program..
Important thing I discoverd is there should be a space at the beginning like whereford=' prot...' and it sok now..
thanx ...but I still has other probelm now..which is to invoke the report from a servlet which executes this shell script..Problem with DISPLAY variable..I cannot run rwrun.sh without DISPLAY variable..
Is there any way to set this variable for tomcat service. -
Want to create unix shell script for Clone procedure in 11i and r12
Want to create unix shell script for Clone procedure in 11i and r12 .Can anyone help me on this as I m new to oracle apps and scripting.
Thanks in advance .user11958935 wrote:
Thanks but I want it for application cloning ie adcfgclone and autoconfig etc .Please see old threads for similar topic/discussion.
https://forums.oracle.com/forums/search.jspa?threadID=&q=Automate+AND+Rapid+AND+Clone&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
https://forums.oracle.com/forums/search.jspa?threadID=&q=Automate+AND+AutoConfig&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
Thanks,
Hussein -
Need Help in creating Unix Shell Script for database
Would be appreciable if some one can help in creating unix shell script for the Oracle DB 10,11g.
Here is the condition which i want to implement.
1. Create shell script to create the database with 10GB TB SPACE and 3 groups of redo log file(Each 300MB).
2. Increase size of redolog file.
3. Load sample schema.
4. dump the schema.
5. Create empty db (Script should check if db already exists and drop it in this case).
6. Create backup using rman.
7. restore backup which you have backed up.This isn't much of a "code-sharing" site but a "knowledge-sharing" site. Code posted me may be from a questioner who has a problem / issue / error with his code. But we don't generally see people writing entire scripts as responses to such questions as yours. There may be other sites where you can get coding done "for free".
What you could do is to write some of the code and test it and, if and when it fails / errors, post it for members to make suggestions.
But the expectation here is for you to write your own code.
Hemant K Chitale -
Shell script for archive log transfer
hi
I dont want to reinvent the wheel.
I am looking for shell script for log shipping to provide standby db.
What I want to do is, get the last applied archived log number from alert.log
Copy the files from archive destination according to this value.
CheersIf you don't want to re-invent the wheel you use Dataguard, no scripts.
And your script should use the dictionary, instead of some bs method to read the alert.
v$archived_log has all information!
Also as far as I know, the documentation describes manual standby.
So apparently you not only don't want to reinvent the wheel, but you want the script on a silver plate on your doorstep!
Typical attitude of most DBAs here. Use OTN for a permanent vacation.
Sybrand Bakker
Senior Oracle DBA -
Shell script for below pl/sql script dbms_file_transfer
Please let me know how tt write the shell script for below pl/sql script dbms_file_transfer it is
I have trasfer the files from asm into filesystem .
it is working . but i have to put in the loop
begin
dbms_file_transfer.copy_file(
source_directory_object => 'src',
source_file_name => 'ncsn',
destination_directory_object => 'dest',
destination_file_name => 'ncsn');
end;
Edited by: user8680248 on 27/10/2009 20:55user8680248 wrote:
Please let me know how tt write the shell script for below pl/sql script dbms_file_transfer it is
I have trasfer the files from asm into filesystem .
it is working . but i have to put in the loop
begin
dbms_file_transfer.copy_file(
source_directory_object => 'src',
source_file_name => 'ncsn',
destination_directory_object => 'dest',
destination_file_name => 'ncsn');
end;What database version?
What are you trying to do exactly?
It's working but you have to put it in a loop. Fine, what's the problem you are having?
begin
loop
exit when ... whatever the exit condition is ...
dbms_file_transfer.copy_file(
source_directory_object => 'src',
source_file_name => 'ncsn',
destination_directory_object => 'dest',
destination_file_name => 'ncsn');
end loop;
end; -
Shell script for export backup in oracle 11g
Hi,
Oracle version 11.2.0..
O/S-AIX
How to write shell script for export full backup in oracle 11g and also need to remove 2 days of old backup.
Regards,
RajuHow to write shell script for export full backup in oracle 11g
Do you mean that export is your backup strategy ? is your database running in noarchivelog mode ? if so, then why ? if not so, then why not RMAN ?
need to remove 2 days of old backup.
If that mean remove files older than 2 days, you can use something like this :
$ find <absolute directory path> -mtime +2 -exec rm {} \; -
HI,
i have written some java code Database backup but there are some problems with that so now i need to write shell script for db backup.
what i was doing in java code i was running command like that
/usr/local/bin/tar cvzf /export/home/monitor/FILE_20091005.tar.gz FILES/*20091005.*which compress the all *20091005* files (myisam table files)
but after compression file doesn't extract
so i have to write shell script for that ..... can any body guide me how can i write that kind of script and put it in cron job.
thankssoundar wrote:
Hi all,
I have migrated database from 8i to 10gr2.For Backup in 8i, we used a RMAN shell script (scheduled uding cron tab) to backup the database to Tape.(VERITAS BACKUP).
I am new to 10G.I checked out the options to backup the database using Oracle Enterprise manager DB console.
http://www.oracle.com/technology/obe/10gr2_db_single/ha/rman/rman_otn.htm#t1d
I am planning to take a test backup using the steps mentioned inthe above url.Could any one suggest whcih is the best option for database backup,eiether to use Oracle Enterprise manager DB console or thru RMAN shell script for backup..?
Edited by: soundar on Mar 9, 2010 10:53 PMDear soudar
I woudn't suggest you to work with EM if you want to be a professional DBA. Start learning RMAN and use CLI instead of GUI
Those who live by the GUI, die by the GUI -
Hi,
I have written shell script for below scenarios, can you please guide me to write this as correct way, requirment is,
1. i need to connect the database which is on unix server , but before connecting the DB some of the files needs to be removed from \tmp directory.
2. once removed the script need to connect the database and call the sql file which is in \tmp directory.
3. the output files will be stored in \tmp directory start with DB name.
4. finally csv files needs to be transferred to local windows with help of FTP. please find below the script
#!/bin/sh
rm -f /tmp/dbmon/DB1*
CONNSTRING=username/PASSWORD@service
sqlplus -s $CONNSTRING @/tmp/STATS.sql << EOF
EXIT;
EOF
HOST='xxxxx'
USER='xxxxx'
PASSWD='xxxxxx'
FILE='E:\STATS\DB1.*'
cd /tmp/dbmon
ftp -n -v $HOST << EOT
user $USER $PASSWD
prompt
mput $FILE
bye
EOT
EXIT;
EOF
Thanks
Edited by: ASP on Nov 18, 2011 4:45 PMHi ASP
It's always a good idea to write entries to timestamped log file without which you will never know where the script went wrong or failed.
This is not tested but just a small example
#!/bin/sh
export LOG_DIR=/tmp/log
export LOGFILE=$LOG_DIR/`basename $0`_${TIMESTAMP}.log
if [ ! -d $LOG_DIR ]
then
mkdir $LOG_DIR
fi
echo "Removing the temporary files from /tmp/dbmon at `date +%Y%m%d_%H:%M:%S`" | tee -a $LOG_FILE
rm -f /tmp/dbmon/DB1*
CONNSTRING=username/PASSWORD@service
echo "Run SQLPlus file" | tee -a $LOG_FILE
sqlplus -s $CONNSTRING @/tmp/STATS.sql << EOF
EXIT;
EOF
echo "Now FTP the files to windows box " | tee -a $LOG_FILE
HOST='xxxxx'
USER='xxxxx'
PASSWD='xxxxxx'
cd /tmp/dbmon
ftp -vn $HOST <<EOF
quote USER $USER
quote PASS $PASSWD
ascii
cd E:\STATS
mput DB1.*
bye
EOF -
Shell Script for Startup and Shutdown the database
Hi,
i want Shell Script for Startup and Shutdown the database in Solaries.
could any one can hep me where i can get this script. or send to me to [email protected]
Thanks & Regards,
Gangi reddySHUTDOWN
SHUTDOWN ABORT]
Shuts down a currently running Oracle instance, optionally closing and dismounting a database.
Terms
Refer to the following list for a description of each term or clause:
ABORT
Proceeds with the fastest possible shutdown of the database without waiting for calls to complete or users to disconnect.
Uncommitted transactions are not rolled back. Client SQL statements currently being processed are terminated. All users currently connected to the database are implicitly disconnected and the next database startup will require instance recovery.
You must use this option if a background process terminates abnormally.
IMMEDIATE
Does not wait for current calls to complete or users to disconnect from the database.
Further connects are prohibited. The database is closed and dismounted. The instance is shutdown and no instance recovery is required on the next database startup.
NORMAL
NORMAL is the default option which waits for users to disconnect from the database.
Further connects are prohibited. The database is closed and dismounted. The instance is shutdown and no instance recovery is required on the next database startup.
TRANSACTIONAL [LOCAL]
Performs a planned shutdown of an instance while allowing active transactions to complete first. It prevents clients from losing work without requiring all users to log off.
No client can start a new transaction on this instance. Attempting to start a new transaction results in disconnection. After completion of all transactions, any client still connected to the instance is disconnected. Now the instance shuts down just as it would if a SHUTDOWN IMMEDIATE statement was submitted. The next startup of the database will not require any instance recovery procedures.
The LOCAL mode specifies a transactional shutdown on the local instance only, so that it only waits on local transactions to complete, not all transactions. This is useful, for example, for scheduled outage maintenance.
Usage
SHUTDOWN with no arguments is equivalent to SHUTDOWN NORMAL.
You must be connected to a database as SYSOPER, or SYSDBA. You cannot connect via a multi-threaded server. For more information about connecting to a database, see the CONNECT command earlier in this chapter.
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a90842/ch13.htm#1013607
Joel Pérez -
Shell scripting for sql queires
Hi All,
I have written 4 sql queires.now i want to write shell scripting for this.so please guide me in this issue..
1. select * from emp;
2. select * from dept;
3. delete from emp;
4. delete from dept;
Thank you.Hi,
Apologees for the c!=k!=b stuff. I guess it was to cryptic. It means
C shell is not equal to Korne shell and both are not equal to Bourne shell.
I can't provide you with any site for such stuff. Maybe Google might help? Or someone who is a nicer guy than me... -
About shell scripts for large-scale automation of encoding tasks
in the user menu of Compressor, it said that we can use the command line to write shell scripts for large-scale automation of encoding tasks.
I would like to have more information about the shell script for compressor, is that any document link?
ThanksYou can use a script function to set-up a more secure environment that you call at the start of every admin script. This could be your main stamp album for stuff that can be moved there.
A few more stamps to add to the collection (be sure to read up on them before use):
1) reset the command hash
hash -r
2) prevent core dumps
ulimit -H -c0
3) set the IFS
4) clear all aliases (see unalias -a)
Also you can remove the ALL from sudo and add explicit commands to the the sudoers file. There's a lot of fine tuning you can do in sudoers - inc. env variables as teekay said.
But I'm no expert so best to check all of the above. -
Pls give some shell scripting for sql/plsql
pls give some shell scripting for sql/plsql
794244 wrote:
pls give some shell scripting for sql/plsqlNeither SQL or PL/SQL are shell script languages. Both are server side languages that executes inside an Oracle database server process.
This is an important concept to understand when using SQL*Plus for example to "script" interaction with an Oracle database.
Maybe you are looking for
-
Tree item when-tree-node-selected fires differently from 6i to 10g.
In forms 6i, when you keyboard navigate between tree nodes, the wtns trigger will fire. In 10g it does not. In 10g, it will fire if you press the tab key or mouse click on a node. Anyone know if this was done on purpose? I ran into this after finally
-
How can I transfer "Pages" files from my IPad to my Mac?
How can I transfer "Pages " files from my IPad to my IMac, I cannot use ICloud because I have Mountain Lion installed on the IMac?
-
How do i get the touchpad to act like a mousewheel?
i have an HP Notebook, i believe it is the 2,000. it uses Windows 7 is there any way i can use a mousewheel feature from the touchpad without an actual mouse?
-
Partitioning of tables in oracle 1og
I want to do the partitioning of tables due to increasing their size.Can anyone guide me cn I do it? Is it possible to do it?If possible then how can i do it.plz guide mme with al qeuries. thanks.
-
i am currently using office 2010 and filesite 8.5 sp2 or sp3 and experiencing the same issue with the icon grouping in the taskbar in all the threads i have read the responses state that the solution was to upgrade to office 2010 well that might have