Tablespace threshold check

Hi all,
my env..
Oracle 8i
solaris
I am trying to check tablespace threshold chek ..below query ...this query is not working in oracle 8i ...but it is working fine in oracle 10g machines ...
what is the reason I was unable to findout...
Please let me know if any one knows
select
(select INSTANCE_NAME||'_'||HOST_NAME from v$instance ) "db_name_host_name",
tablespace_name tablespace,
sum(file_cnt) "# of Files",
(sum(tp)-sum((fs + (tp-tc))))/1048576 "Used (M)",
sum(tc)/1048576 "Allocated (M)",
sum(tp)/1048576 "Max Extend (M)",
round(max(100 - (100*((fs + (tp-tc))/tp)))) " % of Max Used"
from ( select b.tablespace_name, nvl(a.free_space, 0) fs,
b.total_poss_space tp,
b.total_curr_space tc,
b.file_cnt,
b.tablespace_name ts_name
from (
select sum(bytes) free_space,
tablespace_name
from dba_free_space
group by tablespace_name
) a,
select sum(decode(autoextensible, 'YES',
maxbytes,
bytes)) total_poss_space,
sum(bytes) total_curr_space,
count(1) file_cnt,
tablespace_name
from dba_data_files
group by tablespace_name
) b
where a.tablespace_name (+) = b.tablespace_name
group by tablespace_name
having max(100 - (100*((fs + (tp-tc))/tp))) >=80
Error at line 2
ORA-00936: missing expression
Script Terminated on line 1.
Edited by: user603328 on Dec 10, 2010 7:26 AM

Thanks ur reply...
I am getting below issue....
select
(select INSTANCE_NAME||'_'||HOST_NAME from v$instance ) "db_name_host_name",
tablespace_name tablespace,
sum(file_cnt) "# of Files",
(sum(tp)-sum((fs + (tp-tc))))/1048576 "Used (M)",
sum(tc)/1048576 "Allocated (M)",
sum(tp)/1048576 "Max Extend (M)",
round(max(100 - (100*((fs + (tp-tc))/tp)))) " % of Max Used"
from ( select b.tablespace_name, nvl(a.free_space, 0) fs,
b.total_poss_space tp,
b.total_curr_space tc,
b.file_cnt,
b.tablespace_name ts_name
from (
select sum(bytes) free_space,
tablespace_name
from dba_free_space
group by tablespace_name
) a,
select sum(decode(autoextensible, 'YES',
maxbytes,
bytes)) total_poss_space,
sum(bytes) total_curr_space,
count(1) file_cnt,
tablespace_name
from dba_data_files
group by tablespace_name
) b
where a.tablespace_name (+) = b.tablespace_name
group by tablespace_name
having max(100 - (100*((fs + (tp-tc))/tp))) >=80
Error at line 2
ORA-00936: missing expression
Script Terminated on line 1.

Similar Messages

  • Tablespace threshold checking without grid control

    Hi all,
    DB oracle 10g
    solaris,
    It is new env ....we are not having grid configuration ....
    Please any one provide to me a script for monitoring threshold limits like >90% critcal alert ....
    client wants to these alerts are configure to mail when ever tablespace reaches thershold....
    please help me out if any one having any shell ,sql scripts....
    thanks,
    kk

    user603328 wrote:
    Hi all,
    DB oracle 10g
    solaris,
    It is new env ....we are not having grid configuration ....How about dbcontrol? It has all the same functionality as Grid, only for a single database instance. It can monitor and email as specified. It doesn't cost any extra. If your client has Oracle 10g, then he has, and has paid for, dbcontrol. If they don't know that, you owe it to them to show them.
    Please any one provide to me a script for monitoring threshold limits like >90% critcal alert ....
    client wants to these alerts are configure to mail when ever tablespace reaches thershold....
    please help me out if any one having any shell ,sql scripts....
    thanks,
    kk

  • Tablespace threshold alert

    Hi,
    I executed the below procedure to implement the tablespace threshold for the tablespace 'TESTING'.
    My doubt is, once the threshold reaches where will I get the message like the tablespace 'TESTING' has only 51200 KB left.
    Database:10.2.0.4
    OS: solaris 10
    BEGIN
    DBMS_SERVER_ALERT.SET_THRESHOLD(
    metrics_id => DBMS_SERVER_ALERT.TABLESPACE_BYT_FREE,
    warning_operator => DBMS_SERVER_ALERT.OPERATOR_LE,
    warning_value => '51200',
    critical_operator => DBMS_SERVER_ALERT.OPERATOR_LE,
    critical_value => '40960',
    observation_period => 1,
    consecutive_occurrences => 1,
    instance_name => NULL,
    object_type => DBMS_SERVER_ALERT.OBJECT_TYPE_TABLESPACE,
    object_name => 'TESTING');
    DBMS_SERVER_ALERT.SET_THRESHOLD(
    metrics_id => DBMS_SERVER_ALERT.TABLESPACE_PCT_FULL,
    warning_operator => DBMS_SERVER_ALERT.OPERATOR_GT,
    warning_value => '0',
    critical_operator => DBMS_SERVER_ALERT.OPERATOR_GT,
    critical_value => '0',
    observation_period => 1,
    consecutive_occurrences => 1,
    instance_name => NULL,
    object_type => DBMS_SERVER_ALERT.OBJECT_TYPE_TABLESPACE,
    object_name => 'TESTING');
    END;
    /

    Just curious, why are you setting the second threshold (TABLESPACE_PCT_FULL) limit = 0 %?
    Anyway, the view dba_outstanding_alerts does not reflect the status immediately. It may take a few minutes, even if the parameter observation_period = 1 (minute).
    -- Here we have set the database to trigger an alert if the any tablespace usage exceeds 85%
    SQL> select metrics_name, warning_operator, warning_value
      2  from dba_thresholds
      3  /
    METRICS_NAME               WARNING_OPERATOR WARNING_VALUE   
    Tablespace Space Usage     GE               85              
    SQL> CREATE TABLESPACE "TS_TEST" LOGGING DATAFILE
      2  'C:\ORADB\TRAIN10G\DATA\TS_TEST01.DBF' SIZE 400K AUTOEXTEND ON NEXT 100K MAXSIZE 800K
      3  EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT  AUTO ;
    Tablespace created
    SQL> CREATE TABLE testtab (testcol CHAR(100)) tablespace TS_TEST;
    Table created.
    -- Here we wrote a script to insert 1000 rows at a time which will be run repeatedly until we see the threshold exceeded
    DECLARE
      N INTEGER;
    BEGIN
       FOR N IN 1..1000 LOOP
          INSERT INTO testtab values('TESTTESTTEST');
       END LOOP;
       COMMIT;  
    END; 
    ... repeated a few times, checking the freespace each round with the query below until the threshold is exceeded
    SQL> SELECT  a.tablespace_name
      2         ,trunc(decode(a.autoextensible,'YES',a.maxsize-a.bytes+NVL(b.free,0),'NO',NVL(b.free,0))/1024) free_kb
      3         ,trunc(a.bytes/1024) size_kb
      4         ,trunc(a.maxsize/1024) maxsize_kb
      5         ,a.autoextensible ae
      6         ,trunc(decode(a.autoextensible,'YES',(a.maxsize-a.bytes+NVL(b.free,0))/a.maxsize*100,'NO',NVL(b.free,0)/a.maxsize*100)) free_pct
      7    FROM ( select tablespace_name
      8          ,autoextensible,sum(bytes) bytes
      9          ,sum (decode(autoextensible,'YES',maxbytes,bytes)) maxsize
    10           from dba_data_files
    11           group by tablespace_name,autoextensible) a,
    12          (select tablespace_name ,sum(bytes) free
    13           from dba_free_space
    14           group by tablespace_name) b
    15  where a.tablespace_name=b.tablespace_name(+)
    16  order by 2 asc
    17  /
    TABLESPACE_N    FREE_KB    SIZE_KB MAXSIZE_KB AE    FREE_PCT
    TS_TEST              16        784        800 YES          2
    ... SQL below was repeatedly run, and after 4 minutes we got the alert in dba_outstanding_alerts....
    SQL> select object_name, object_type, reason
      2  from dba_outstanding_alerts
      3  /
    OBJECT_NAME     OBJECT_TYPE      REASON
    TS_TEST         TABLESPACE       Tablespace [TS_TEST] is [88 percent] fullAlso, you can expand this method to include a stored procedure that is scheduled (DBMS_SCHEDULER) to check dba_outstanding_alerts every so often and compose an email message to be sent to the DBA using UTL_SMTP.

  • Script for database send mail for tablespace threshold 90%

    Dear All,
    Scripts required for send mail from database for following events
    1.Tablespace Threshold
    2. Db Shutdown & Startup
    Database Version : 10.2.0.1.0
    OS :- Linux
    Thanks & Regards,
    Praful Kawaji

    You have Database Control.
    Database Control can already do this.
    Why do you want to remain in the Stone Age and continue to use scripts?
    Why do you want to reinvent the wheel, when the functionality is already there.
    Agreed, you would have to read documentation and/or help text, and you rather don't want to do that.
    Which is the exact cause why you want to reinvent the wheel, and pay Larry for functionality you don't use.
    Sybrand Bakker
    Senior Oracle DBA

  • Tablespace threshold alerts?

    Maybe 2 silly questions...
    Say if I have a tablespace 80% full and then I set the warning threshold down to 75%, will the alert be generated immediately or delayed (how much?)
    If I don't get warning even after 1 day ( with restart database ), what was wrong?

    Hi,
    I have checked the dba_threshold view the threshold has been set correctly as I saw in EM. (warning: 75, critical: 85, while my tablespace is now 77% full )
    and there are no rows for dba_outstanding_alerts.
    I remember there was an exam question like this as well but I don't know the correct answer.

  • Temporary Tablespace: cannot check it from V$TEMP_SPACE_HEADER

    I've created the temporary tablespace but I cannot check it from V$TEMP_SPACE_HEADER, when I select the contents of it, it returns "no rows selected".
    Could someone tell me why?
    Besides, I would like to know how to check the contents in temporary table space.
    Regards,
    Jimmy

    Hi,
    I think you just did not create a TEMPORARY TABLESPACE but a PERMANENT TABLESPACE with TEMPORARY OPTION..10:43:10 TEST.SQL>CREATE TABLESPACE TS
    10:43:21   2  DATAFILE '/F1.dbf' SIZE 15M
    10:43:40   3  TEMPORARY;
    Tablespace created.
    Elapsed: 00:00:02.66
    10:43:44 TEST.SQL>SELECT * FROM V$TEMP_SPACE_HEADER;
    TABLESPACE_NAME                   FILE_ID BYTES_USED BLOCKS_USED BYTES_FREE BLOCKS_FREE RELATIVE_FNO
    TMP                                     1 2,2424E+10     2737280 3790602240      462720            1
    Elapsed: 00:00:00.01
    10:43:56 TEST.SQL>SELECT * FROM DBA_TABLESPACES WHERE TABLESPACE_NAME IN ('TMP','TS');
    TABLESPACE_NAME                BLOCK_SIZE INITIAL_EXTENT NEXT_EXTENT MIN_EXTENTS MAX_EXTENTS PCT_INCREASE MIN_EXTLEN STATUS    CONTENTS  LOGGING   FOR EXTENT_MAN ALLOCATIO PLU
    SEGMEN DEF_TAB_
    TS                                   8192          40960       40960           1                       50          0 ONLINE    TEMPORARY LOGGING   NO  DICTIONARY USER      NO
    MANUAL DISABLED
    TMP                                  8192        5242880     5242880           1                        0    5242880 ONLINE    TEMPORARY NOLOGGING NO  LOCAL      UNIFORM   NO
    MANUAL DISABLED As you can see from this sample, if you useCREATE TABLESPACE blablabla DATAFILE blabla TEMPORARYOracle creates a tablespace that looks to be a pure temporary tablespace but in fact is not actually. It can be used as a TEMP would be but has not all the characteristics of it. Heh, it's got a DATAFILE, not a TEMPFILE in it.
    If you use CREATE TEMPORARY TABLESPACE blabla TEMPFILE blabla then Oracle will create an actual TEMPORARY TABLESPACE which will be present in all temporary related views!
    You can't distinguish one from the other via standard views (DBA_TABLESPACES) once it's been created.
    To check temp space usage you can use something like:SELECT
                    RPAD(TF.TABLESPACE_NAME,20) || ':' ||
                            DECODE(EXTENT_MANAGEMENT,'LOCAL','LM-','DM-') ||
                            SUBSTR(ALLOCATION_TYPE,1,1)||'+'||
                            SUBSTR(SEGMENT_SPACE_MANAGEMENT,1,1)||'@'||
                            SUBSTR(TS.STATUS,1,2)
                                            TABLESPACE_NAME,
            TF.FILE_NAME,
            USAGE.USERNAME,
            USAGE.SEGTYPE,
            LPAD(USAGE.BLOCKS*TBLKS.BLOCKSIZE/1024/1024,5) || ' Mo' BLOCKS
    FROM
            DBA_TEMP_FILES TF,
            V$TEMPSEG_USAGE USAGE,
            (SELECT VALUE BLOCKSIZE FROM V$PARAMETER WHERE NAME='db_block_size') TBLKS,
            DBA_TABLESPACES TS
    WHERE
            USAGE.TABLESPACE=TF.TABLESPACE_NAME
    AND TS.TABLESPACE_NAME=TF.TABLESPACE_NAME
    ORDER BY TF.TABLESPACE_NAME, TF.FILE_NAME, USAGE.USERNAME;Regards,
    Yoann.

  • Setting tablespace threshold

    Hi,
    We have metrics like Tablespace Used (%) for which we have set thresholds, but they are not being collected (as confirmed by the All Metrics screen) - why?
    Agent Version (OMS) -- 10.1.0.3
    Agent Version of target -- 10.1.0.3
    No error messages are issued
    regards
    Dilip

    Go thru the monitoring configuration link at the bottom again. Also try setting the PERL trace in emd.properties to debug and look at the perl.trc file generated for clues.

  • Tablespace Threshold Metrics (exceptions)

    (I entered a SR but no answer as of yet)
    I created to overriding thresholds for Tablespace Full, one for TEMP, the other for UNDOTBS. Problem Those tablespaces still trigger alerts based on the thresholds set for the "default/other" tablespace metrics.
    Any one get this working in 10gR2? I believe it worked in 10gR1 Grid.
    I dont see it tracing problemTbsp.pl or fullTbsp.pl scripts. I cant figure out which perl script is being run such that I can debug the problem.
    Help?

    started and stopped many times, upload metrics, clearstate etc.
    I believe there is something fundamentally wrong. Has anyone else tried this functionality? Is it broke elsewhere?

  • Tablespace Threshold

    Hi
    I want to create a threshold on the tablespace when it is 80 % Used.
    I want a mail to be sent on my email address and also when user inserts data in that TBS he should receive the Alert.
    Please Advise

    Use Oracle Enterprise manager database control, go to preferences and assign a email server. Then on the home page-->manage metrics link-->Edit Threshod button-->set your metric warning/critical thresholds here and wait for notifications in email box when the threshod is reached.
    Sami.

  • How to check Tablespace in DB2 with AS400

    Hi Guru,
    Can u please tell me how to check tablespace in db2 database with ecc5.

    Hi,
    very simple:
    DB2 on iSeries just has NO tablespaces ))
    => no check necessary
    Regards
    Volker Gueldenpfennig, consolut international ag
    http://www.consolut.de - http://www.4soi.de - http://www.easymarketplace.de

  • How to capture tablespace warning and critical messages

    Hi,
    Where in the database dictionary, the tablespace threshold percent (warning and critical) defined by the user is stored.
    Requirement is to set threshold percent (warning and critical) in OEM and in a function (for User-Defined Metrics) or procedure (for scheduler) check for Tablespace PCT_FULL against the set threshold percent and display message accordingly.
    Thanks & Regards,
    Sanju.

    Sounds like this is default behaviour of the metrics for tablespace full?
    Here is the basic query for OEM metrics:
    select
    target_type,
    target_name,
    metric_column Metric,
    decode(warning_threshold,' ',null, decode(warning_operator,'Equal To','=','Not Equal','!=','Greater Than','>','Less Than','<',warning_operator) || ' ' || warning_threshold) Warning,
    decode(critical_threshold,' ', null, decode(critical_operator,'Equal To','Not Equal','!=','=','Greater Than','>','Less Than','<',critical_operator) || ' ' || critical_threshold) Critical
    from mgmt$metric_collection
    --where target_type = 'oracle_emd'
    --and  metric_column = 'HostInfovszGrowth'
    --and warning_threshold != '20'
    --where target_type = 'host'
    where-- metric_column like 'tnsPing'
    -- (warning_threshold != '80' and critical_threshold != '95')
    --and
    target_type = 'oracle_database'
    --and target_type = 'host'
    --and
    --target_type  = 'oracle_listener'
    --target_type = 'oracle_emd'
    --and metric_column like 'generic%'
    --and warning_threshold like '%ORA%'
    and target_name = 'XXXSOMEHOSTNAMExxxx'
    and metric_column = 'pctUsed'
    order by 1,3,2

  • Adding a datafile  to a tablespace?

    hi all,
    what are the prequisites of adding a datafile  to a tablespace
    & how is it performed? pls help?
    regards,
    vivek.

    Hi,
    prequisites of adding a datafile to a tablespace
    1. check for Tablespace Threshold level should be more than 90%(in db02 tcode).
    2. There shd be no backup running while adding datafile to Tablespace.
    3. check for the size of datafile should be added to Tablespace.
    Goto Brtools--->login as sidadm
    BR*Tools main menu
    1 = Instance management
    2 - Space management
    3 - Segment management
    4 - Backup and database copy
    5 - Restore and recovery
    6 - Check and verification
    7 - Database statistics
    8 - Additional functions
    9 - Exit program
    select option 2 - Space management.> Then select  1 = Extend tablespace>  3 ~ Tablespace name (tablespace) ... []-->
    5 - Size of the new file in MB (size) ..... [3500] then continuosly select  c-continue
    With this steps your datafile will be added to Tablespace.
    Thanks,
    Ramakrishna.

  • Drop Normal Tablespace Taking several hours

    Hi,
    In my 1TB database there is one tablespace size (38.5 GB / used 4 GB) which we used for objects backup purpose and i am trying to drop this tablespace using every option like bring tablespace offline and drop with DROP TABLESPACE TBS_NAME INCLUDING CONTENTS AND DATAFILES CASCADE CONSTRAINTS
    but Drop Tablespace Taking several hours (24 + hrs)
    I tried with drop objects from the tablespace but that is also taking lot of time to drop and then i tried to drop empty tablespace and again it is taking several hours.
    Database version :- 10.2.0.3 and 10.2.0.4
    Operation System Version :- Solaris 5.10
    ERP 11.5.10
    Please suggest what could be the problem.

    So, till now you have done these steps,
    1) dropped all database objects from that tablespace. Checked if any objects are there in this tablespace and there were none
    2) take tbs offline
    3) drop tablespace
    4) While drop tablespace command is hanging, monitored segments in the tbs from another session. Segments were reducing very slowly
    Out of first 3 steps, which step took longer? drop tablespace ?
    Logically, when you are able to drop objects, then there should be no issue of locks or anything like that.
    Dictionary updates should not take 24 hours!!!
    What else is going on, on the disk/file-system where this tbs is housed?
    Do you have all locally managed tablespaces?

  • How to reorganization index in new tablespace

    How to reorganization index in new tablespace? for size? for? number of extents? or both?

    What's Oracle version?
    Why you want to reorg your index?
    You could rebuild your index
    alter index <index_name> rebuild tablespace <tablespace_name>check Jonathan's note regarding index rebuild,
    http://jonathanlewis.wordpress.com/2008/02/09/index-rebuild-10g/

  • Active Sync Threshold

    Has anyone ran across a requirement to set a threshold on the number of operations (add, delete, etc) an active sync process is allowed to run before aborting the request? That is not 100% accurate. The requirement is to abort the operation that has exceeded the threshold but process the remaining operations. The threshold should also be applied prior to any of the actions actually being processed. Hence, it is an all or nothing situation.
    For instance, I want to set a threshold on the number of deletions. If during the active sync process this threshold is exceeded all deletions would be skipped but any additions or updates would still be processed. The final requirement is that an administrator would be notified of the issue and have the ability to approve/reject each of the operations.
    I have two different thoughts on how best to solve this:
    1) Use a pre-poll workflow to examine the resource and perform the threshold check. If the threshold is exceeded then a flag is set to indicate that these operations should be skipped. The active sync forms then use this flag in order to determine what to do with the request. The nice thing about this is that the administrator simply has to disable the pre-poll workflow to allow the operations to be completed. However, the solution is highly dependent on the resource type. It also requires the ability to effectively force a change on the record so that it is processed during the next active sync run.
    2) Build a workflow that defers all threshold-based operations until the end of the active sync process. Then use a post-poll workflow to perform the threshold check. If the threshold is not exceeded then the deferred tasks can be ran immediately. However, if the threshold is exceeded then a notification can be sent to an administrator. I would need to provide a server task for the administrator to either approve/reject the deferred operation.
    I think both solutions will work. I am wondering if anyone has already solved this issue or has thoughts on my two different approaches.
    Thanks,
    Pete

    What about this: keep track of the number of deletions by whatever means and set some flag when the threshold has been reached. Then, in the Delete User Workflow, check the flag and if it is set, force an approval so the operation is suspended until it is approved or rejected.

Maybe you are looking for

  • Mac book pro

    Hi my mac book pro OS X , does not open the main page and hangs up after login. A small coloured round curser apprears on a black screen. Apprently I did not back up nothing on time machine. I tried to back up by opening OS X Utilities window and I'm

  • Lightdm hangs with wrong password

    Hi, I use lightdm with lightdm-gtk3-greeter and whenever I enter a wrong password to login, it just hangs. How can I solve this problem?

  • Wireless keyboard - return key has stopped working.

    The return key on my wireless keyboard has just stopped functioning along with the backslash key to the left of it.  Any ideas as to the likely cause, or has it just packed up? I'm having to use the keyboard viewer or the old USB keyboard for these f

  • Stepper motors to move antenna

    Hello ! My name is Paul, I am from Romania. I need some ideas on how to make a project. I need to control a fake antenna (I am saying fake because it won't be attached to anything, just for display purposes) using LabView. The antenna will be very sm

  • Microsoft Lync and CM 7

    /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm