SQL monitoring scripts

Hi Gurus,
I need a whole bunch of SQL monitoring SQLs in other words some data dictionary SQL scripts to monitor SQLs like following
--Top 5 worst sqls
select c.*
from (select disk_reads, buffer_gets, rows_processed, executions,
-- address,
-- hash_value,
first_load_time, sql_text
from v$sqlarea
where parsing_user_id !=0
order by buffer_gets/decode(executions,null,1,0,1,executions) desc ) c
where rownum <= 5
order by disk_reads desc;
Thanks
Amitava.

Just look at the AWR data / run an AWR report.
See DBA_HIST_SQLSTAT.

Similar Messages

  • Oracle 9i database monitoring scripts

    Hi Friends,
    I am asked by my boss to submit weekly reports about the database status.
    She wanted something in excel format.
    Can you suggest me what reports do I submit?
    I found the following monitoring scripts from google:
    Are these scripts still relevant ,or applicable, or obsolete?
    PURPOSE
    This article contains a few ready-made queries on V$SQLAREA
    for identifying the top 10 most resource-consuming SQL statements
    with a variety of criteria.
    The thresholds used are the same as used by default in Statspack:
    Buffer Gets : 10,000
    Physical Reads : 1,000
    Executions : 100
    Parse Calls : 1,000
    Sharable Memory : 1,048576
    Version Count : 20
    Top 10 by Buffer Gets:
    set linesize 100
    set pagesize 100
    SELECT * FROM
    (SELECT substr(sql_text,1,40) sql,
            buffer_gets, executions, buffer_gets/executions "Gets/Exec",
            hash_value,address
       FROM V$SQLAREA
      WHERE buffer_gets > 10000
    ORDER BY buffer_gets DESC)
    WHERE rownum <= 10
    Rem Top 10 by Physical Reads:
    set linesize 100
    set pagesize 100
    SELECT * FROM
    (SELECT substr(sql_text,1,40) sql,
            disk_reads, executions, disk_reads/executions "Reads/Exec",
            hash_value,address
       FROM V$SQLAREA
      WHERE disk_reads > 1000
    ORDER BY disk_reads DESC)
    WHERE rownum <= 10
    Rem Top 10 by Executions:
    set linesize 100
    set pagesize 100
    SELECT * FROM
    (SELECT substr(sql_text,1,40) sql,
            executions, rows_processed, rows_processed/executions "Rows/Exec",
            hash_value,address
       FROM V$SQLAREA
      WHERE executions > 100
    ORDER BY executions DESC)
    WHERE rownum <= 10
    Rem Top 10 by Parse Calls:
    set linesize 100
    set pagesize 100
    SELECT * FROM
    (SELECT substr(sql_text,1,40) sql,
            parse_calls, executions, hash_value,address
       FROM V$SQLAREA
      WHERE parse_calls > 1000
    ORDER BY parse_calls DESC)
    WHERE rownum <= 10
    Top 10 by Sharable Memory:
    set linesize 100
    set pagesize 100
    SELECT * FROM
    (SELECT substr(sql_text,1,40) sql,
            sharable_mem, executions, hash_value,address
       FROM V$SQLAREA
      WHERE sharable_mem > 1048576
    ORDER BY sharable_mem DESC)
    WHERE rownum <= 10
    Top 10 by Version Count:
    set linesize 100
    set pagesize 100
    SELECT * FROM
    (SELECT substr(sql_text,1,40) sql,
            version_count, executions, hash_value,address
       FROM V$SQLAREA
      WHERE version_count > 20
    ORDER BY version_count DESC)
    WHERE rownum <= 10
    ;I just feel the above reports not really meaningful :(
    Can you give me some other scripts that u have?
    Thanks a lot,
    MsK

    Thanks all :-*
    @sybrand
    Oracle 9i comes with Oracle Enterprise Manager. This includes a reporting website with monitoring scripts.
    Why write them yourself?My boss want a cumulative report over time, for example : what happened @ 1am,2am,3am on tuesday last week, why is the server so slow that the batch job did not complete as expected? Why was an error occured about a table that can not extend? Ora 1635. I mean you can see in the report that at this certain hour a certain tablespace was full.
    oops maybe tablespace sample is not logical :D
    say every day I can have excel reports of tablespace space status like:
    tablespace_name   used     free     date
    TS_DATA          1000K   5000k  1-Oct-2010
    TS_DATA          2000K   4000k  2-Oct-2010
    TS_DATA          3000K   3000k  3-Oct-2010
    TS_DATA          4000K   2000k  4-Oct-2010
    TS_DATA          5000K   1000k  5-Oct-2010
    TS_DATA          5000K      0k  6-Oct-2010Does Statspack can hold historical data for analysis? say for the last 24 hrs?
    Thanks a lot

  • Monitoring scripts for AlwaysOn Availability Group

    Does anyone have any any monitoring scripts for AlwaysOn AG using Transact SQL or stored procedures?   I'm not a strong coder and don't know Powershell at all.  But if there are some Powershell scripts we may be able to use them.  I've
    seen the dashboard but that's only good if you're logged onto it.
    I'm looking for things like monitoring when a database is suspended, send an alert to us but also tries to do the resume.
    Thanks for any info.

    Start with this list
    http://technet.microsoft.com/en-us/library/ff877954.aspx
    Automating the issue resolution has to conform to your operational standards. For example, if you use a file share witness for your quorum configuration and your monitoring tells you that it is offline, do you automate bringing it online or do you escalate
    to your infrastructure team so that they can look into it? If the database is suspended or the Availability Group in offline state, do you just bring it online or do you check other dependencies like the quorum configuration and instead perform a forced quorum?
    I'm a big fan of automation but make sure you define your process first so that you don't cause more issues as a result.
    Edwin Sarmiento SQL Server MVP | Microsoft Certified Master
    Blog |
    Twitter | LinkedIn
    SQL Server High Availability and Disaster Recover Deep Dive Course

  • SQL MP script failed to run

    Hi! I have installed the SQL MP 6.5.1.0 for SQL2005,SQL2008,SQL2012 and SQL2014. I know that I need to use one SQL RunAsAccount and add that account in the SQL RunAsProfiles to have the correct access to run the SCOM SQL scripts and get the correct
    monitoring. We have give this SQL RunAsAccount the "Local Administrator" and "sysadmin" rights on all instances through a group. This SQL servers also use UAC, then we tested to add this SQL RunAsAccount directly with sysadmin
    rights on one SQL servers instances instead through a group. But still the same problem... I haven't test the new SQL MP version 6.5.4.0 yet and I know that there is one fix for "Fixed
    Timeout error in CPU utilization monitoring scenario"
    The SQL RunAsAccount use "More Secure" and we are running the SQL RunAsProfiles target type against a Group with "Windows Computers" for all the SQL servers that we want to run this RunAsAccount against. We have the same problem
    when we tested to change the target type to "SQL Computers" 
    At most of our customer it works fine but at one customer we still get all this SQL monitor related errors:
    Power Shell Script failed to run (timeout 200 sec)
            - scriptname=CPUUsagePercentDataSource.ps1
            - workflow=Microsoft.SQLServer.2008DBEngine.ThreadsCountMonitor
    Operations Manager failed to start a process
           - command=GetSQL2008DBWinServStat.js
           - workflow=Microsoft.SQLServer.2008.Database.ServiceMonitor
    Operations Manager failed to start a process due to lack of Resources
           - command=GetSQL2012DBFreeSpace.vbs
    Operations Manager failed to run a WMI Query
             - workflow=Microsoft.SQLServer.2012.Database.ServiceMonitor
    Someone with any idea what's the problem can be?

    Hi,
    >At most of our customer it works fine but at one customer we still get all this SQL monitor related errors
    Do you mean only one SQL server has this error message poped out? If that is the case, then you may check whether the runas account configured has proper permissions on that server. You may add the account to local admin group.
    Please also go through the link below:
    http://blogs.technet.com/b/kevinholman/archive/2013/10/24/opsmgr-sql-mp-version-6-4-1-0-capabilities-and-configuration.aspx
    Regards,
    Yan Li
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]

  • Monitoring scripts

    Hello, I am looking for some good monitoring scripts with good instructions on how to use them and what to look for. I would especially like one for monitoring Library cache.
    Thank you,
    David

    I would especially like one for monitoring
    Library cache.--Check GETHITRATIO in V$LIBRARYCACHE:
    --This ratio should be in the high 90s. If not, there is probably room to improve the efficiency of your applicationcode.
    SQL> col gethitratio form 90.999
    SQL> select gethitratio,
    2 case
    3 when gethitratio<0.9 then 'improve applicationcode!!(>=0.9)'
    4 else null
    5 end as "     ****** Advice ****** "
    6 from v$librarycache where namespace = 'SQL AREA' ;
    GETHITRATIO ****** Advice ******
    0.984
    1 row selected.

  • Creating SQL-Loader script for more than one table at a time

    Hi,
    I am using OMWB 2.0.2.0.0 with Oracle 8.1.7 and Sybase 11.9.
    It looks like I can create SQL-Loader scripts for all the tables
    or for one table at a time. If I want to create SQL-Loader
    scripts for 5-6 tables, I have to either create script for all
    the tables and then delete the unwanted tables or create the
    scripts for one table at a time and then merge them.
    Is there a simple way to create migration scripts for more than
    one but not all tables at a time?
    Thanks,
    Prashant Rane

    No there is no multi-select for creating SQL-Loader scripts.
    You can either create them separately or create them all and
    then discard the one you do not need.

  • An error occcurred on line 105 while executing script 'MOM Backward Compatibility Service State Monitoring Script"

    We've been getting the following error for some time now.
    An error occurred on line 105 while executing script 'MOM Backward Compatibility Service State Monitoring Script'
    Source: Microsoft VBScript runtime error
    Description: The remote server machine does not exist or is unavailable: 'GetObject'
    One or more workflows were affected by this.
    Workflow name: System.Mom.BackwardCompatibility.ServiceStateMonitoring
    Instance name: server.domain.local
    Instance ID: {INSTANCE}
    Management group: GROUP
    Unfortunately the instance in question has since been decommissioned and simply does not exist any more. 
    We're currently on a repeat count of over 350,000 and I would REALLY like to get it stopped. I've had a look at adding an override but that points to the management server rather than the instance itself.
    Does anyone have any suggestions?
    thanks in advance!

    Hi Steven,
    There are for option for us to override a monitor ot rule:
    For all objects of class:             
    Class            
    When you select this option for your override, the override settings apply to all objects in the class at which the rule or monitor is targeted.
    For a group            
    When you select this option for your override, the override settings apply only to members of the group. The rule or monitor without the override settings continues to apply to all objects in the targeted class except for those objects that are also members
    of the group used for the override.
    When you create a group, you save it to an unsealed management pack. However, an element in an unsealed management pack, such as an override, cannot reference an element in a different unsealed management pack, such as a group. If you are going to use a group
    to limit the application of an override, you must either save the group to the same unsealed management pack as the override, or you must seal the management pack that contains the group.
    For a specific object of class:             
    Class            
    When you select this option for your override, the override settings apply only to the specified object. The rule or monitor without the override settings continues to apply to all other objects in the targeted class.
    For all objects of another class            
    When you select this option for your override, the override settings apply only to objects of a class other than the targeted class. The rule or monitor without the override settings continues to apply to all objects in the targeted class.
    Did you try to override it for a specific object of class?
    Regards,
    Yan Li
    Regards, Yan Li

  • Error while running new OEM 11.1.0.7 feature: SQL Monitoring

    I am running OEM Database control with the new 11g version, Oracle 11.1.0.7. I am trying to work with the new feature SQL Monitoring, but I am getting the following error:
    Loading data error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032"]
    Did someone saw that feature actually working? I only saw it in the OOW Demo.
    I am getting the error both in Windows and Linux installations. Any idea why this error happen and how to overcome it?
    Best,
    Merav

    Check for additonal (related) errors in the EM and Agent log files under $ORACLE_HOME/sysman

  • Error while runing SQL Monitoring new OEM 11.1.0.7 feature

    I am running OEM Database control with the new 11g version, Oracle 11.1.0.7. I am trying to work with the new feature SQL Monitoring, but I am getting the following error:
    Loading data error:
    Did someone saw that feature actually working? I only saw it in the OOW Demo.
    I am getting the error both in Windows and Linux installations. Any idea why this error happen and how to overcome it?
    Best,
    Merav

    Hi Merav
    select version from v$timezone_file;
    VERSION
    4
    If you get 4 from that query use MetaLink Note 568125.1.
    Have you installed Database Vault ? that might be related to your issue.
    Can you please send us more details on the error?
    Would you please investigate also :
    -STATISTICS_LEVEL initialization parameter is either set to ALL or TYPICAL (the default value)
    -CONTROL_MANAGEMENT_PACK_ACCESS parameter must be set to DIAGNOSTIC+TUNING (the default value)
    Control also that :
    select /*+MONITOR*/ * from dba_objects;
    Please read that also:
    http://structureddata.org/2008/01/06/oracle-11g-real-time-sql-monitoring-using-dbms_sqltunereport_sql_monitor/
    Thanks
    Edited by: Hub on Nov 20, 2008 10:59 AM
    Edited by: Hub on Nov 20, 2008 11:01 AM

  • How to Eliminate Special Character in SQL LOADER Script

    How to eliminate special character from SQL LOADER script file which suppose not to insert in TABLE
    example.CSV lile like this
    <ABC/ , 7747>
    <DEF/ , 7763>
    <NEW/ , 7779>
    <OLD/, 7795>
    I have to remove < > and / character at the time of loading into table. How It could be done. It is not possible to remove < , > , / character manually from CSV file

    On Unix/Linux that's very easy, on Windows... I don't know...
    $ cat myfile.csv
    <ABC/ , 7747>
    <DEF/ , 7763>
    <NEW/ , 7779>
    <OLD/, 7795>
    $ tr -d "\057\074\076" <myfile.csv >outfile.csv
    $ cat outfile.csv
    ABC , 7747
    DEF , 7763
    NEW , 7779
    OLD, 7795
    $

  • How to detect client OS from SQL*Plus script

    Sometimes in a SQL*Plus script I need to execute OS commands e.g.
    host rm tempfile.bufHowever of course Windows has no "rm" command by default, so I have to edit the script to use
    host del tempfile.bufNow if I could define &DELETE (for example, "cat"/"type" is another) as a substitution variable, I could just use
    host &DELETE tempfile.bufMaybe I need more coffee but all I could come up with was something like this:
    def rm=rm
    def cat=cat
    spool sqlplus_windows_defs.cmd
    prompt echo def rm=del
    prompt echo def cat=type
    spool off
    host .\sqlplus_windows_defs > sqlplus_windows_defs.sql
    @sqlplus_windows_defs.sql
    host &rm sqlplus_windows_defs.cmd
    host &rm sqlplus_windows_defs.sqlthe idea being that you first define the variables for nix ("rm" and "cat"), then attempt to create and execute a Windows command file containing DOS versions ("dele" and "type"), which does not run under nix. Unfortunately the OS failure message (".sqlplus_windows_defs: not found" in Unix) appears on the screen despite SET TERM OFF, so I'm back where I started.
    I know there are various ways to get the server OS, and you can get the SQL*Plus version with &_SQLPLUS_RELEASE and so on, but I can't see a way to determine the client OS. Any suggestions?

    Thanks guys. This seems to work in Windows XP - will try on Unix when I get a chance:
    col DELETE_COMMAND new_value DELETE_COMMAND
    col LIST_COMMAND new_value LIST_COMMAND
    def list_command = TYPE
    def delete_command = DEL
    SELECT DECODE(os,'MSWIN','TYPE','cat') AS list_command
         , DECODE(os,'MSWIN','DEL','rm')   AS delete_command
    FROM   ( SELECT CASE WHEN UPPER(program) LIKE '%.EXE' THEN 'MSWIN' END AS os
             FROM   v$session
             WHERE  audsid = SYS_CONTEXT('userenv','sessionid') );
    host &LIST_COMMAND xplan_errors.lst
    host &DELETE_COMMAND xplan_errors.lstIf the user doesn't have access to v$session it will just default to the Windows commands.
    http://www.williamrobertson.net/code/xplan.sql

  • Oracle 9i monitoring scripts in HACMP 5.4

    Hi,
    I have installed Oracle 9.2.0.8 on AIX 5.3 (HACMP 5.4) in active passive cluster.
    I have made startup and shutdown scripts for Oracle.
    Can anyone please guide me or point me to some link for the monitoring scripts for Oracle in HACMP so that failover can happen automaticaly.
    Regards,
    Amit E

    Have you tried changing the /etc/redhat-release file? Change the "release 5" to "release 4" and see what happens. Make sure you change it back after the install.
    Tom

  • ORA-00936 error from SQL expression in SQL*Loader script

    I am getting the above error on the following line in my SQL*Loader script:
    DIA_CLM_RES_OID DECIMAL EXTERNAL
    "SELECT N_ORG_ENTY_ID FROM TESTG4.ORG_ENTITY
    WHERE N_USER_ID =
    (SELECT UNIQUE WSR_NT_ID FROM CONV_CLM_RESOURCE
    WHERE CLM_RES_OID = :DIA_CLM_RES_OID)",
    What I am basically trying to do is a 2-table lookup of a value:
    1. Find a row in table CONV_CLM_RESOURCE where the value in column CLM_RES_OID matches the value in the input file in field DIA_CLM_RES_OID.
    2. Take the value of field WSR_NT_ID from that row and use it to find a row in table TESTG4.ORG_ENTITY.
    3. Take the value of field WSR_NT_ID from that row and set it in the target table in field DIA_CLM_RES_OID.
    In other words, I am essentially trying to translate the input value by using two other tables to lookup the value to translate to. However, no matter how I arrange it, I keep getting the "ORA-00936: missing expression" error on this statement.
    Can anyone see what I am doing wrong, or perhaps suggest a better way of accomplishing a two-table translation of a value?
    Thanks!

    Still not sure why this doesn't work, but I was able to create and use a function to do this instead, which is probably a better approach anyway.

  • INSERT Script stored as "SQL Statement Script" not firing on Oracle Alert

    We are using Alert Manager to run Alerts based on absence information in EBS R12.1.3 HR tables.
    Application: Human Resources
    Period/Event: Periodic
    Frequency: Every Day
    The Alert has 2 actions.
    One is to email a supervisor based on the Alert SQL finding staff who have had x number of absences over a set period of time.
    That is working fine.
    The other action is defined as an "SQL Statement Script".
    The SQL script inserts the variables defined in the SQL from the main Alert definition SQL, into a custom table.
    When the Alert fires, we are getting the email generated, but the INSERT statement isn't firing.
    However, when we look at the result of the Alert when it has run, and look at the steps which were fired, we can see the email step and the SQL step. When we look at the SQL in the SQL step which was generated, we can copy and paste it direct into TOAD and it works fine.
    We have tried a simple SQL INSERT statement which even just does:
    INSERT INTO xx_tmp (VALUE1_DATE, VALUE2) VALUES (SYSDATE, 'this');
    But even that does not work.
    We wonder if the issue is that we cannot do a direct INSERT from an alert type of "SQL Statement Script"?
    We have found another Alert which does a direct UPDATE on a table, but the SQL Statement Script definition has "Purchasing" as the Application, because it's updating a PO table.
    In our case, we're trying to insert into a custom table held in our in-house XX schema.
    Could the problem be that we don't have the "Application" set? If that's the case, we don't have a corresponding application anyway.
    Or can we not do a direct INSERT like this - do we need to use a package instead, and call that?
    Any advice much appreciated.
    Thanks

    Hi Brian,
    Alert issue - Custom SQL fix
    1. Define actions via "Actions" button on Alert Definition
    2. Create an action for e.g. "Send Message to Supervisor"
       Action type: message
       Action - sends email to people
    3. Create another action called e.g. "Insert Record"
       Action type: SQL Statement Script
       Fill in SQL in the "Text" section, no need to add a begin or end bit, just a simple INSERT INTO X etc ending with a semi colon
    4. Back on the main alert definition window, go to "Action Sets" button
       Here, need one SEQ for the Message / Email (e.g. Seq 1), and then click on "Action Set Details" and click on "Members" tab and select the "Send Message to Supervisor" Action
       Then close the "Action Set Details" window, and return to the "Action Sets" window
       click into 2nd line, add e.g. Seq 2, and call it e.g. "Insert Record", click on "Action Set Details" > Members tab and select the "Insert Record" The problem was that in the first instance, we had a single Action Set, and under "Members" had selected the "Send Message to Supervisor" and "Insert Record" at the same time.
    Short answer: each Action needs to be defined as a separate line in the Action Sets definition.
    I can send screenshots if you need them, and don't mind putting your email address on this forum.
    You can always edit the thread after I've emailed you, to remove your email address.

  • SQL Monitoring using SQL Queries

    Hi
    I am using Oracle 10 g DB. I have an application which has Oracle as DB. Its a multiuser application. During the testing of one of the page we found that saving couple of records takes huge time (50-60 seconds). I dont have access to the logic written in application code to know which all queries gets executed when user click on save button.
    I know that there is SQL Monitoring available in OEM why which you can find out the queries which got executed and also the execution time for those queries.
    However I dont have OEM access.
    Can you please let me know teh set of queries which probably will use few of teh V$ data dictionary views and provide me the same details as generated in the Monitoting report generated by OEM ?
    I want to see all the queries which got executed in last defined time (say 10 mins, 1 hr etc) , same way as it is done in OEM and not just the last sql.
    TIA
    Regards
    Arun

    Hi,
    I recommend you to install STATSPACK - it's a free tool that can be used instead of the Automatic Workload Repository (that is used in OEM).
    This tool creates snapshots of V$ views in defined time period, so it enables you to see long runing queries in history.
    If I were you I would run SQL trace just before the problematic part and then stop it just as it has finished. It would be better to run trace only for the problematic session or module - not for the whole database. SQL trace generates a file with all the executed queries, explain plans, stats, ...
    In extreme case just create copy of v$sql before and after the problematic part and compare them (new sql_id, elapsed_time delta, ...)

Maybe you are looking for

  • Cant see the SAP component in BPR

    Ok, Here is the background, I created an implementation project in solman. in the 'system landscape' i chose R/3 4.7 which is there in the SMSY. Then when i go to SOLAR01 and select the scenario, (structure tab) in the BPR search help window (under s

  • OSX 10.5.8 Mail App 3.6 - sent mails are gone

    After 16 years of using Eudora, I migrated to Mail 3.6 on 10.5.8. That was yesterday. Today I sent some emails with Mail 3.6 as reply to emails I received a few minutes before. The mails were sent correctly, as people told me so by phone. But, the se

  • Need SQL query for PO that do NOT have 3-way match.

    The question is -- have any PO"s been generated with other then 3-way match selected - which means they overrode the set-ups in purchasing , to see if there are an PO that do NOT have 3-way match. Thanks Mohan.

  • Share garage band 10 project

    I want to share my Garage Band 10 project with another musician. How do I go about exporting it? Can I just e-mail the project file (is everything really just embedded in a single file?) or is their a process to exporting the project? A link to a kno

  • Why can't I import to TB exported LiveMail files?

    Just installed TB b/c LiveMail quit working (was in constant send mode). Set up TB and can get & send mail from server. Rebooted. LiveMail now working... Exported "Everything." Back in TB I cannot import. Process seems to be stuck after choosing "Eve