• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 439
  • Last Modified:

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
0
sam_2012
Asked:
sam_2012
  • 3
1 Solution
 
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now