Statspack report generation shell script?

Does anyone have a shell script (unix/solaris) which does the following:
Gets the snap_ids from the 09:00 and 17:00 statspack snapshots (from today or yesterday), and runs spreport.sql, using these snapshot ids as begin_snap and end_snap.
I do not want to purge any snapshots from the database. I simply want to generate a daily "9 to 5" statspack report every day.
TIA,
Dave

Hi,
You can do the following way:
1. Write script to get the begin snap_id as:
$cat > begin_snap.sql
set head off
set echo off
set verify off
set termout off
spool begin_snap_id.log
SELECT snap_id
FROM stats$snapshot
WHERE TRUNC(snap_time) = TRUNC(SYSDATE-1)
AND TO_NUMBER(TO_CHAR(snap_time,'HH24')) =9;
spool off
2. write a script to get end snap id as same as above substituting 9 with 17 with script name as end_snap.sql and spool file name as end_snap_id.log.
3. write a script to pass arguments for spreport.sql as:
cat > statspack_report
#!/bin/ksh
ORACLE_HOME=/home/oratest
TODAY=`date '+%Y%m%d' `
REPORT=report_${TODAY}.txt
sqlplus -s perfstat/perfstat@database_name @$ORACLE_HOME/begin_snap.sql <<EOF
EOF
BEGIN_ID=`cat /home/oratest/begin_snap_id.log | sed '/^$/d' `
sqlplus -s perfstat/perfstat@database_name @$ORACLE_HOME/end_snap.sql <<EOF
EOF
END_ID=`cat /home/oratest/end_snap_id.log | sed '/^$/d' `
sqlplus -s perfstat/perfstat@database_name @$ORACLE_HOME/rdbms/admin/spreport.sql <<EOF
${BEGIN_ID}
${END_ID}
${REPORT}
EOF
you can schedule this statspack_report in a crontab.
thanks
srinivas.

Similar Messages

  • Passing flexfield from report wrapper to seeded report using shell script

    I am unable to pass flexfield values from report wrapper to seeded report using shell script
    below is the shell script that i am using to transfer GL Account High and GL Account Low to the seeded program Receipt Journal Report (ARXRJR). the flex fields get passed through the parameter v_param_12 and v_param_13. but all i am getting in the seeded report log file is the reporting level,reporting context,set_of_books,period, gl_date_low/high .
    #TEST Program for Passing GL Account High and GL Account Low
    v_user_name=`echo $3`
    v_login_pwd=`echo $FCP_LOGIN`
    v_prog_name=`echo TESTARXRJR`
    echo 'v_prog_name: '$v_prog_name
    # testing for passing the arguments from CM ...
    if [ -z "$1" ]
    then
    echo "Please pass the first argument...."
    exit 1
    fi
    v_request_id=`echo $4`
    echo 'v_request_id: '$v_request_id
    v_param_1=`echo $5`
    echo 'v_param_1: '$v_param_1
    v_param_2=`echo $6`
    echo 'v_param_2: '$v_param_2
    v_param_3=`echo $7`
    echo 'v_param_3: '$v_param_3
    v_param_4=`echo $8`
    echo 'v_param_4: '$v_param_4
    v_param_5="$9"
    echo 'v_param_5: '$v_param_5
    shift
    v_param_6=`echo $9`
    echo 'v_param_6: '$v_param_6
    shift
    v_param_7=`echo $9'`
    echo 'v_param_7: '$v_param_7
    shift
    v_param_8=`echo "$9"`
    echo 'v_param_8: '$v_param_8
    shift
    v_param_9=`echo $9`
    echo 'v_param_9: '$v_param_9
    shift
    v_param_10=`echo $9`
    echo 'v_param_10: '$v_param_10
    shift
    v_param_11=`echo $9`
    echo 'v_param_11: '$v_param_11
    shift
    v_param_12=`echo $9`
    echo 'v_param_12: '$v_param_12
    shift
    v_param_13=`echo $9`
    echo 'v_param_13: '$v_param_13
    shift
    v_param_14=`echo $9`
    echo 'v_param_14: '$v_param_14
    shift
    v_param_15=`echo $9`
    echo 'v_param_15: '$v_param_15
    shift
    v_param_16=`echo $9`
    echo 'v_param_16: '$v_param_16
    shift
    v_param_17=`echo $9`
    echo 'v_param_17: '$v_param_17
    shift
    v_param_18=`echo $9`
    echo 'v_param_18: '$v_param_18
    shift
    v_param_19=`echo $9`
    echo 'v_param_19: '$v_param_19
    shift
    v_param_20=`echo $9`
    echo 'v_param_20: '$v_param_20
    shift
    v_param_21=`echo $9`
    echo 'v_param_21: '$v_param_21
    shift
    v_param_22=`echo $9`
    echo 'v_param_22: '$v_param_22
    shift
    v_param_23=`echo $9`
    echo 'v_param_23: '$v_param_23
    echo "Executiong SQL to obtain org id and responsibility name"
    (sqlplus -s /nolog <<end_of_sql
    conn $v_login_pwd
    set heading off
    set echo off
    set feedback off
    SELECT 'ORGID:'||b.profile_option_value || ':' ||e.responsibility_name
    FROM fnd_profile_options a,
    fnd_profile_option_values b,
    fnd_concurrent_requests c,
    fnd_responsibility d,
    fnd_responsibility_tl e
    WHERE c.request_id = $v_request_id
    AND c.responsibility_id = b.level_value
    AND b.profile_option_id = a.profile_option_id
    AND a.application_id = b.application_id
    AND c.responsibility_application_id = d.application_id
    AND d.application_id = e.application_id
    AND a.profile_option_name = 'ORG_ID'
    AND c.responsibility_id = d.responsibility_id
    AND d.responsibility_id = e.responsibility_id;
    exit
    end_of_sql
    ) > a.log
    v_var=`grep -iv "ORG_ID" a.log|sed 's/Connected.//'`
    echo 'v_var: ' $v_var
    v_org=`echo $v_var| awk 'FS=":" {print $2 }'`
    v_resp_name=`echo $v_var | awk 'FS=":" {print $3}'`
    echo 'v_org :'$v_org
    echo 'v_resp_name :'$v_resp_name
    echo 'Sumitting Receipt Journal Report...'
    user_request=`CONCSUB $v_login_pwd GL "$v_resp_name" $v_user_name WAIT=Y CONCURRENT AR ARXRJR \
              \"$v_param_3\"\
              \"$v_param_4\"\
              \"$v_param_5\"\
              \"$v_param_6\"\
              \"$v_param_7\"\
              \"$v_param_8\"\
              \"$v_param_9\"\
              \"$v_param_10\"\
              \"$v_param_11\"\
              \"$v_param_12\"\
              \"$v_param_13\"\
              \"$v_param_14\"\
              \"$v_param_15\"\
              \"$v_param_16\"\
              \"$v_param_17\"\
              \"$v_param_18\"\
              \"$v_param_19\"\
              \"$v_param_20\"\
              \"$v_param_21\"\
              \"$v_param_22\"\
              \"$v_param_23\"`
    user_request=`echo $user_request|awk '{print $3}'`
    echo Request is $user_request
    trx_rep_file="$user_request"
    echo 'trx_rep_file: '$trx_rep_file
    sleep 10
    for i in 1 2 3 4 5
    do
    if test -f $APPLCSF/$APPLLOG/l$user_request.req
    then
    if test [`grep -i '"Concurrent process completed successfully"' $APPLCSF/$APPLLOG/l$user_request.req`]
    then
    if test -f $APPLCSF/$APPLOUT/o$trx_rep_file.out
    then
    echo +++++++++++++++++++++++++++++++++
                   echo 'output file found'
                   echo ++++++++++++++++++++++++++++++++++++++
    else
    echo +++++++++++++++++++++++++++++++++++++++++
              echo failure in Report listing production
              echo +++++++++++++++++++++++++++++++++++++++
    fi
    break
    else
    echo +++++++++++++++++++++++++++++++++++++++
    echo Job not Over Yet
         echo +++++++++++++++++++++++++++++++++++++++++++++
    fi
    echo +++++++++++++++++++++++++++++++++++++++
    echo File not found yet
    echo ++++++++++++++++++++++++++++++++++++++
    fi
    sleep 10
    done
    echo ----------------------------------------------------------
    echo Transaction Listing process over
    echo ---------------------------------------------------------
    echo ----------------------------------------------------------
    echo Executing SQL to derive Search Pattern
    echo ----------------------------------------------------------
    v_pattern=`sqlplus -s /nolog <<EOF1
    conn $v_login_pwd
         set heading off
         set echo off
         set feedback off
         SELECT 'SEARCH^'||meaning||'^'||attribute1||'^'||attribute2||'^'||attribute3
         FROM fnd_lookup_values
         WHERE lookup_type = '$v_param_2'
         AND lookup_code = '$v_prog_name';
    exit
         EOF1`
    echo 'v_pattern: '$v_pattern
    v_pattern_n1=`echo $v_pattern|sed 's/Connected.//'|awk 'FS="^" {print $2}'`
    echo 'v_pattern_n1: '$v_pattern_n1
    v_pattern_n2=`echo $v_pattern|sed 's/Connected.//'|awk 'FS="^" {print $3}'`
    echo 'v_pattern_n2: '$v_pattern_n2
    v_pattern_n3=`echo $v_pattern|sed 's/Connected.//'|awk 'FS="^" {print $4}'`
    echo 'v_pattern_n3: '$v_pattern_n3
    v_pattern_n4=`echo $v_pattern|sed 's/Connected.//'|awk 'FS="^" {print $4}'|sed 's/ //'`
    echo 'v_pattern_n4: '$v_pattern_n4
    echo 'v_param_12: '$v_param_12
    echo 'v_param_13: '$v_param_13
    echo -----------------------------------
    echo Deriving final output
    echo ----------------------------------
    v_var=`cat $APPLCSF/$APPLOUT/o$trx_rep_file.out | grep -i "$v_pattern_n1"|\
                   sed "s/(/-/g"|sed "s/)/ /g"|\
                   sed "s/$v_pattern_n1/$v_pattern_n2/g"|\
              sed 's/ /~/g'|\
    sed 's/~~*/~/g'|\
                   sed 's/ *//g'|\
                   sed 's/,//g'`
    echo 'v_var: '$v_var
    v_var_2=`cat $APPLCSF/$APPLOUT/o$trx_rep_file.out|grep -i "$v_pattern_n3"|\
                   uniq`
    v_out_1=`echo "$v_var"|grep -i "$v_pattern_n2"|awk 'FS="~" {print $3}'`
    echo 'v_out_1: '$v_out_1
    echo 'v_var_2: '$v_var_2
    echo ------------------------------------------------------------
    v_out_2=`echo "$v_var_2"|grep -i "$v_pattern_n3"|awk 'FS=":" {print $2}'`
    echo 'v_out_2: '$v_out_2
    echo ----------------------------------------------
    echo Process comleted
    echo ----------------------------------------------------
    echo ================================================================================
    #---------------------------------------------------------------------------------------------------

    The name of this OTN group is "Database - General"
    Your question relates to an unnamed application that might be E-Business Suite, or PeopleSoft, or Siebel, who can say.
    Please re-ask your question in the appropriate applications forum and be sure to clearly name the full product name and version. We are not mind readers and we can not look over your shoulder.

  • Automate statspack report generation.

    Hi All,
    I have a 9i db on HP-UX. It has statspack snapshot scheduled at every 10 mins.
    Is it possible to generate and mail the stats report automatically for a perticular period ? Is there any standard job or Shell script is to be used.
    Thanks in advance,
    Ashutosh

    Ashutosh wrote:
    Hi All,
    I have a 9i db on HP-UX. It has statspack snapshot scheduled at every 10 mins.
    Is it possible to generate and mail the stats report automatically for a perticular period ? Is there any standard job or Shell script is to be used.
    First thing 9i is loong time back got desupported. Please use a supported release at the moment. Second, AFAIK there is no such mechanism available by default to do so. Since you are in 9i and the only scheduling package in that was dbms_job, even writing a custom code to do so would not be a very trivial task.
    Aman....

  • How to submit "active users" standard report using shell scripting

    Hi All,
    Greetings.
    I want to submit the "Active Users" standard report in Sysadmin responsibility using a shell script.
    I also want to pass a parameter named email to this..
    can anyone help me do this?
    Thanks in Advance,
    Bhaskar

    Hi Bhaskar,
    You can achieve this by shell scripting either by scripting via CONCSUB utility (invoked from OS) or you can use the FND_SUBMIT package (through PL/SQL package), and in the script itself you can create the outputs or any hardcode messages to a file, and then mail the output to your desired mail address.
    If you use mail or mailx command using the OS utility then you can even send mail to external users which should not necessarily be a registered EBS users.
    Google, Forum Search and metalink will provide you loads of articles on how to use CONCSUB and FND_SUBMIT packages.
    Thanks &
    Best Regards,

  • Where can i get statspack report

    Hi,
    My database environment is very big,where i dont have permisson to perfstat user or even to view perfstat tables.Senior DBA runs stats pack report and will pass it to me.This time he sent in very bad format,so i am not able to read and analyze it.Now i want to get stats pack and analyze for very serious performance issue.If you go into file level where statspack report will be stored by default.If i get access to perfstat table,in which table i can see all sql related reports.DBA has to send it again or any other way to look on it.
    Thanks
    Anand

    If you have password for sys or system then you don't need password for perfstat user.
    To generate new statspack report execute spreport script (from sqlplus).
    @?/rdbms/admin/spreport

  • Problem-Report generation using shell script

    Hi
    We have the Production database and the Reporting database (copy of Production database),
    both on Oracle 9.2.0.5 and Solaris 5.8. There is a package inside the Oracle database, which extracts some data from inside the
    database, and would generate a report. A shell script has been created in Solaris which would
    send in the parameters and call the pakage to generate the report. The parameters it is sending is
    the name of report to be generated, and the location where it is to be generated, both hard-coded into
    the script. The script is scheduled to run through crontab.
    The problem we are facing is that, if we run the script for Reporting database, it successfully
    generates the report. But if we use that script for Production database, it gives the error
    "Invalid directory Path". I have tried using various other directory paths, even '/tmp'
    and '/', but it still gives the same error when executed for Production dataabse.
    Could somebody provide any ideas what might be going wrong.
    The reasons it is to be executed on Prod db and not the Reporting database are unavoidable.
    It anyway runs in off business hours and takes about 10secs to execute.
    Please do let me know if there is any other info that I missed to provide here.
    Thanks in advance...

    I will be just guessing because you didn't provide contents of script and package.
    The "Invalid directory path" as you said could be ORA-29280 due non existent directory.
    Try execute (as sys or system) select * from dba_directories; (or select * from all_directories; as user which the script is login to) on both databases and compare the results. If there is missing your important directory then create it using create directory <dirname>; (from sqlplus and don't forget to grant rights for user).
    This error could come from shell script. In that case you should find resolution yourself because you didn't provide script source.

  • Calling a report from a shell script

    We are modifying all concurrent programs to encrypt the oracle password by using the "ENCRYPT" option in the concurrent program definition for all unix based programs.
    The db user/password is derived from the FCP_LOGIN within the shell script. If I submit the concurrent prorgam and go to the root directory on which the unix shell scripts are present and execute the following command :
    ps -ef
    I can see the call to the concurrent program and since I am using the encrypt method, i cannot see the password(I could see the password before the change)
    The problem is one of the shell scripts is calling an Oracle Report by using ar25run command which needs a userid as the parameter.
    So when I issue the above ps command, i can see the password in the call to this report.
    Is there any other way of passing the oracle user/password to the report? This is required for SOX compliance.
    thanks,

    I guess it should be the same problem as if you are calling CONCSUB from unix also, because both need userid and password.
    If that's the case probably metalink note 104541.1 might help you.

  • Calling a report from unix shell script

    Hi,
    I had to call a report from unix shell script.
    May i know the procedure to accomplish this
    Thanks in Advance
    A.Gopal

    First you should not include the whole path to your report in the call ...
    Use like this:
    /ora/u01/oracle/v101/as2/bin/rwrun.sh report=an_stati destype=file desname=/ora/u01/oracle/v101/as2/test.pdf desformat=pdf
    In $ORACLE_HOME/bin/reports.sh:
    1) Verify that you have updated the REPORTS_PATH variable to include your folder where you have the report in question
    REPORTS_PATH=/ora/u20/app/qits/env1/run:$ORACLE_HOME/reports/templates:$ORACLE_HOME/reports/samples/demo: ....
    2) Verify that the REPORTS_TMP variable is pointing to a valid location and that the oracle user has access to write on it.
    After that, post the content of the tracefile located at $ORACLE_HOME/reports/logs/{in-process report server name folder}/rwserver.trc
    If no file is present then it means that you need to enable trace in your reports's conf file.... go to the $ORACLE_HOME/reports/conf folder and and locate the .conf file that correspond to your in-process reports server name (as specified in the rwservelet.properties file)... open/edit the file to enable trace logs ..
    i.e.
    Change the following line:
    <!--trace traceOpts="trace_all"/-->
    to <trace traceOpts="trace_all"/>
    Bounce the reports server and try to run the report again, this time the .trc file should be generated, post the content so that we can take a look.

  • How to call a Shell Script from Report 6i

    Hi All,
    Can anybody tell, how to call a Shell Script from Report 6i.
    Thanks in Advance,
    Bala

    try the SRW.USER_EXIT (user_exit_string CHAR);

  • Running report in concurrent manager using unix shell script to create PDF

    Hi,
    I need help urgently, we are in the process of migrating from 10.7 to 11i. My problem is we have a report created in 10.7 that is ran through concurrent manager using shell scripts(host) and the output is stored as .pdf, in 10.7, it works perfectly. Now I am also doing it in 11i but it gives some error. The shell script from 10.7 is: r25runm module=$XXX_TOP/srw/test.rdf \
    userid=$1 batch=yes \
    desformat=pdf destype=file \
    desname=$XXX_TOP/outbound/test.pdf
    I change the shell script in 11i as follows:
    ar60runb report=$XXX_TOP/reports/US/test.rdf \
    userid=$1 batch=yes \
    desformat=pdf destype=file \
    desname=$XXX_TOP/outbound/test.pdf
    I checked your metalink, and I am confused which is the right executable I should use, is it ar60runb or ar60run or rwrun60b or rwrun60c or rwrun60b, which is which? how many parameters do I have to include?, some documents are saying I have to use the 4 parameters-orauser/pwd, userid,username, request_id, others one.Which parameter/s go/es with what executable. We are using HP-UX server 64 bit. In 11i, when I run in concurrent manager it gives me an error:The executable file /chdev/fd11/u00/fd11appl/xxx/1.0/bin/test for this concurrent program cannot be executed.
    Contact your system administrator or support representative. Verify that the execution path to the executable file is co.
    I have checked Metalink and follow the directions, created a link fndcpesr, check and set the permissions, etc. Play around with the executables ar60runb or rwrun60 etc., the parameters. The ar60* or rwrun60* executable permissions are -rwxr-xr-x and $XXX_TOP/fnd/../fndcpesr is -rwxr-xr-x. Also, why is ar60* executables located in $FND_TOP/bin, whereas rwrun60* executables are in $ORACLE_HOME/bin? Please help, I need an answer urgently ,I have to complete this task before Tuesday 9/16/2003 for our migration deadline. Thank you very much.

    I have already fixed the problem, TY anyway

  • Unix shell script should execute (run) webI report.

    Hi
    i am new to BO.
    I have webI reports developed, can any one tell me how  to execute a webI reprot using unix sheel script.

    Hello Vijaya,
    Thatu2019s an interesting question.  BusinessObjects does not supply any native UNIX shell interfaces or scripts for running/executing Webi Reports. Not knowing what it is you are exactly trying to accomplish Iu2019ll give a very general answer.
    I have had several customers who had requirements to have external systems execute, refresh and export reports in BusinessObjects Enterprise before.  These external systems could execute a shell script so what they have ended up doing is creating generic Java applications that use the BusinessObjects BOE Java SDK. Once they had the Java application created their external application could execute a java directory or they created shell wrappers that were called.  So what you could do is create some Java applications that wrap the functionally you need and then execute those from the command line.
    With that said there is a lot of functionally built into BusinessObjects Enterprise.  If I was to know exactly what you were trying to achieve I might be able to point you in the direction of an existing product feature.
    Cheers,
    David.

  • FTP log file generation failed in shell script

    Hi ALL,
    I am doing FTP file transfer in shell script and able to FTP the files in to corresponding directory , But when i am trying to check the FTP status through the log files then its giving problem . please check the below code.
    for file in $FILENAME1
    do
    echo "FTP File......$file"
    echo 'FTP the file to AR1 down stream system'
    ret_val=`ftp -n> $file.log <<E
    #ret_val=`ftp -n << !
    open $ar1_server
    user $ar1_uname $ar1_pwd
    hash
    verbose
    cd /var/tmp
    put $file
    bye
    E`
    if [ -f $DATA_OUT/$file.log ]
    then
    grep -i "Transfer complete." $DATA_OUT/$file.log
    if [ $? -eq 0 ]; then
    #mv ${file.log} ${DATA_OUT}/../archive/$file.log.log_`date +"%m%d%y%H%M%S"`
    echo 'Log file archived to archive directory'
    #mv $file ${DATA_OUT}/../archive/$FILENAME1.log_`date +"%m%d%y%H%M%S"`
    echo 'Data file archived to archived directory'
    else
    echo 'FTP process is not successful'
    fi
    else
    echo 'log file generation failed'
    fi
    its giving syntax error end of file not giving the exact line number , please help me on thsi
    Regards
    Deb

    Thanks for ur reply
    Actually i did a mistake in the code i wrote the following piece of code below
    ret_val=`ftp -n> $file.log <<E
    #ret_val=`ftp -n << !
    so after the tilde symbol it as again taking the '# ' as a special character so it was giving error, so i removed the second line now its working fine.

  • Shell script to start forms and reports server on reboot

    Does anyone have on shell script to automatically start up the forms and reports server on unix after a reboot?
    thanks much

    I also recompiled the "test.fmb" that came with the 10g Forms and Server on my windows xp machine and when I downloaded it back to the Linux Forms and Server machine, it loss the functionality of the "OK" button which is suppose to perform "exit_form" when pressed.
    BTW, I am using 10G developer suite on windows xp.

  • How we can call or execute a SHELL script through Oracle forms or Reports

    How we can call or execute a SHELL script through Oracle forms or Reports.Its urgent.......

    Use HOST command.

  • Executing crystal reports through a shell script

    We are currently in the processing of building a POC using Crystal reports and was hoping to find a way to execute canned crystal reports via a shell script. The reason being we wanted to schedule the executing of the report through our scheduler where we would build in the dependencies.
    Does anyone have a simple example on how to do that.

    What sort of shell script? Can you provide more info?
    The only CR SDK is for .NET and Java.
    - Ludek
    Senior Support Engineer AGS Product Support, Global Support Center Canada
    Follow us on Twitter

Maybe you are looking for

  • Calendar, Task items created on phone no longer sy...

    After working without error for months, I find Calendar and Task items created on my Nokia E71 are no longer being synced to Outlook. I cannot figure out what's changed and I'm not sure how to troubleshoot the problem. Items created in Outlook are sy

  • Why is my macbook pro fan running so frequently and staying so hot?

    It seems like recently my MacBook Pro 5 has issues with being too hot.  Is this a result of keeping too many applications open? Thanks,

  • Ouer join in RPD

    Hi Gurus/Experts I want to apply an outer join on a fact and dimension table. I am very new to OBI and have no idea of how to go about it. i had read a few links which says creating an opaque view etc but have not got a clear picture. Quick response

  • Playlist Shuffle problem....please help?

    I have a bunch of playlists all set on shuffle on itunes. Usually when i sync the ipod it replicates the playlists and my smart playlists are also updated. However this is no longer happening and my playlists are simply showing up in song order once

  • Endpoint shutdown (FTP) on web exception. FTP error 421

    Hi, When using FTP Source in my Biztalk Services project it sometimes occurs that we receive an error 421 from the FTP server. This causes the endpoint to shutdown, which will result in a manual action to restart the endpoint again. We're looking int