Need Help on Oracle Database

Hi ,

I need to write a Unix script that runs the AWR report ADDM report by accepting all parameters for AWR and ADDM  as run timne parameters.

I need to pass the values like DBinstance , DBID , start snap shot , end snap shot , no of days as input parameters and login into sql plus and pass the parameters to the script
@$ORACLE_HOME/rdbms/admin/awrrpt.sql

Sample code :

./runmon.sh 1233444 1 234 237 5 <Scriptname .sh DBinstaanceid DBID startsnapshot endsnapshot noofdays>

within the script

sqlplus / as sysdba >> EOF

@$ORACLE_HOME/rdbms/admin/awrrpt.sql $2 $3 $4 $5 $6
EOF

but the problem is the script that not run as per the parameters passed to the sql statement. It again prompts for the input values .

Secondly , what is the best way to display the available snapshots and then allowing the user to select it.

Thanks in Advance
sam_2012Asked:
Who is Participating?
 
sam_2012Author Commented:
Can any one suggest how we can pass values to the awr script
0
 
sam_2012Author Commented:
But I have a fresh installation , no AWR report has been generated till now.
When I view DBA_HIST_SNAPSHOT, it does not display any rows.

I need to AWR report for tge first time manually , How shall I do it?
Below is the code snippet that I have used to run the report

define  inst_num     = 1;
define  num_days     = '';
define  inst_name    = 'SAMDB';
define  db_name      = 'SAMDB';
define  dbid         = 18738870;
define  begin_snap   = 0;
define  end_snap     = 0;
define  report_type  = 'html';
define  report_name  = '$HOME/awr_1_1.html'
@@$ORACLE_HOME/rdbms/admin/awrrpti.sql

I get invalid begin and end snapshot error , it does not exists in the database.
I tried the above command for all the 3 values for num_days variable as below
num_days=0
num_days=''
num_days=1

Also , I manually created 1 snapshot by executing the procedure
DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT  function then  I ran with the below command

After running this step Iam getting row in DBA_HIST_SNAPSHOT

define  inst_num     = 1;
define  num_days     = 1;
define  inst_name    = 'SAMDB';
define  db_name      = 'SAMDB';
define  dbid         = 18738870;
define  begin_snap   = 0;
define  end_snap     = 1;
define  report_type  = 'html';
define  report_name  = '$HOME/awr_1_1.html'
@@$ORACLE_HOME/rdbms/admin/awrrpti.sql


But I get invalid begin snapshot error. Then I again I run with the below madofication

define  inst_num     = 1;
define  num_days     = 1;
define  inst_name    = 'SAMDB';
define  db_name      = 'SAMDB';
define  dbid         = 18738870;
define  begin_snap   = 1;
define  end_snap     = 1;
define  report_type  = 'html';
define  report_name  = '$HOME/awr_1_1.html'
@@$ORACLE_HOME/rdbms/admin/awrrpti.sql
Again I get invalid end snapshot , it should > begin snap shot.



Kindly guide me in this regard...
0
 
sam_2012Author Commented:
the answer helps me to understand how the script can be automated.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.