V$osstat and V$SYS_TIME_MODEL - how to get CPU time from instance

Hi there !
I have a function osstat, which take stats from the os using v$osstat (credits for the procedure to a person, I regret to say, that I cant remember his name). But since we have 9 databases on the same server (and we dont have access to the server os itself (outsourcing stinks), we often would like to know more about cpu, waits etc. And one of the procedures we use is the osstat.
I have tried to combine it with V$SYS_TIME_MODEL in oder to se how much of the OS CPU time comes from the instance I am on at the moment, but I'm not able to figure out how to do it exaclty.
This is my code:
DROP TYPE OSSTAT_RECORD;
CREATE OR REPLACE TYPE osstat_record IS OBJECT (
  date_time_from TIMESTAMP,
  date_time_to TIMESTAMP,
  idle_time NUMBER,
  user_time NUMBER,
  sys_time NUMBER,
  iowait_time NUMBER,
  nice_time NUMBER,
  instance_cpu_time NUMBER
DROP TYPE OSSTAT_TABLE;
CREATE OR REPLACE TYPE osstat_table AS TABLE OF osstat_record;
CREATE OR REPLACE FUNCTION osstat(p_interval IN NUMBER default 5, p_count IN NUMBER default 2, p_dec in number default 0)
   RETURN osstat_table
   PIPELINED
IS
  l_t1 osstat_record;
  l_t2 osstat_record;
  l_out osstat_record;
  l_num_cpus NUMBER;
  l_total NUMBER;
  l_instance NUMBER;
BEGIN
  l_t1 := osstat_record(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
  l_t2 := osstat_record(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
  SELECT value
  INTO l_num_cpus
  FROM v$osstat
  WHERE stat_name = 'NUM_CPUS';
  FOR i IN 1..p_count+1
  LOOP
    SELECT systimestamp, sum(decode(stat_name,'IDLE_TIME', value, NULL)) as idle_time,
           sum(decode(stat_name,'USER_TIME', value, NULL)) as user_time,
           sum(decode(stat_name,'SYS_TIME', value, NULL)) as sys_time,
           sum(decode(stat_name,'IOWAIT_TIME', value, NULL)) as iowait_time,
           sum(decode(stat_name,'NICE_TIME', value, NULL)) as nice_time
    INTO l_t2.date_time_to, l_t2.idle_time, l_t2.user_time, l_t2.sys_time, l_t2.iowait_time, l_t2.nice_time
    FROM v$osstat
    WHERE stat_name in ('IDLE_TIME','USER_TIME','SYS_TIME','IOWAIT_TIME','NICE_TIME');
    select value/100000
    into l_t2.instance_cpu_time
    from  V$SYS_TIME_MODEL
    where stat_name = 'DB time';
    l_out := osstat_record(l_t1.date_time_from, systimestamp,
                           (l_t2.idle_time-l_t1.idle_time)/l_num_cpus/p_interval,
                           (l_t2.user_time-l_t1.user_time)/l_num_cpus/p_interval,
                           (l_t2.sys_time-l_t1.sys_time)/l_num_cpus/p_interval,
                           (l_t2.iowait_time-l_t1.iowait_time)/l_num_cpus/p_interval,
                           (l_t2.nice_time-l_t1.nice_time)/l_num_cpus/p_interval,
                           ((l_t2.instance_cpu_time-l_t1.instance_cpu_time)/100));  --- >>  Should I divide by no of cpus here as well???  Or ???
    l_total := l_out.idle_time+l_out.user_time+l_out.sys_time+l_out.iowait_time+nvl(l_out.nice_time,0);
    if l_out.user_time > 0 then
       l_instance := (l_out.instance_cpu_time*100)/l_total;   ->> instance in percent of the total cputime
    else
       l_instance := 0;
    end if;
    if i > 1 then
    PIPE ROW(osstat_record(l_t1.date_time_to, systimestamp,
                           trunc((l_out.idle_time/l_total*100),p_dec),
                           trunc((l_out.user_time/l_total*100),p_dec),
                           trunc((l_out.sys_time/l_total*100),p_dec),
                           trunc((l_out.iowait_time/l_total*100),p_dec),
                           trunc((l_out.nice_time/l_total*100),p_dec),
                           trunc(l_instance,p_dec)));
    end if;
    l_t1 := l_t2;
    sys.dbms_lock.sleep(p_interval);
  END LOOP;
  RETURN;
END;
/I get ie a USER CPU Time of 15% fo a given interval of 5 mins - and a cputime for the instance of 50 - and others are 5% and 1%.
My brain has stopped working now .... I'm stuck
Mette

mettemusens wrote:
Hi there !Duplicate thread:
Re: v$osstat and V$SYS_TIME_MODEL question
Regards,
Randolf
Oracle related stuff blog:
http://oracle-randolf.blogspot.com/
SQLTools++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676/
http://sourceforge.net/projects/sqlt-pp/

Similar Messages

  • How to get a time from a NTP server in ActionScript 3 ?

    Dear All,
    I need your advice, how to get the time from NTP Server , I tried to do this, but I don't.
    Thanks
    Omar Mahmoud

    you must use a server-side language supported by your server.  php is a commonly supported language on most servers.
    php tutorials can be found via google or any other search engine.

  • How to get system time from cRIO?

    Hello,
    I have an NI cRIO-9076 chassis with an NI-9467 GPS module and an NI-9234 module.
    I've downloaded the FPGA Timekeeper application which synchronises the FPGA clock to the 1PPS GPS, this works well.  What I want to do is create a trigger that at a pre-defined HH:MMS the system will start to acquire and log data from the Accelerometers connected to the NI-9234 module.
    I have added the controls for the entry of the HH:MMS and calculated the time in seconds.  I would like to compare the system clock once it is locked to the entered timestamp and then trigger.
    As I only have a value that represents seconds in the day I need to calculate the offset from EPOCH to compare against the GPS time reference.  I have read that the NI system clock runs from 01/01/1904 instead of the EPOCH 01/01/1970.
    The question is how do I get the current system time so that I can compare it against the entered time?  I only need seconds in the day = (HH * 3600) + (MM * 60) + (SS)
    Thank you,
    Kind Regards,
    Simon

    You should use the Get Date/Time in Seconds VI which will return a timestamp. You can then format this timestamp using the Format Date/Time String to give you exactly the time format that you need. Then you can extract the numbers you need and do your math.
    www.movimed.com - Custom Imaging Solutions
    Attachments:
    Get Seconds in Day.vi ‏9 KB

  • How to get elapsed time from start of current day

    Hello,
    I've tried to use the DateDiff function to calculate the elapsed time, starting from 00:00:00:000 (Midnight of current day), but I'm getting hung up on how to inform the function of what date values it should use.  I could parse off the time section
    of the
    GetDate() function, but that doesn't seems a little klunky to me. 
    So, what I'm trying to capture is this (pseudo code): 
    Elapsed Time (int) =    Select DateDiff(seconds, Current Day.Midnight, CurrentDay.CurrentSecond)
    Any help is greatly appreciated.
    Cap

    Hello,
    So something like this? You can change it around, I used variables so you can see and check (and play with) the values.
    DECLARE @CurDay DATE = GETDATE()
    Declare @SecondsToDate INT
    SELECT @SecondsToDate = DATEDIFF(SECOND, @CurDay, GETDATE())
    SELECT @SecondsToDate AS SecondsPastMidnight
    -- do the check
    SELECT DATEADD(SECOND, @SecondsToDate, CAST(@CurDay AS DATETIME))
    Sean Gallardy | Blog | Microsoft Certified Master

  • How to get the value from a JavaScript and send the same to Java file?

    Hi.
    How to get the value from a JavaScript (this JS is called when an action invoked) and send the value from the JS to a Java file?
    Thanks and regards,
    Leslie V

    Yes, I am trying with web application.
    In the below code, a variable 'message' carries the needed info. I would like to send this 'message' variable with the 'request'.
    How to send this 'message' with and to the 'request'?
    Thanks for the help :-)
    The actual JS code is:
    function productdeselection()
    var i=0;
    var j=0;
    var deselectedproduct = new Array(5);
    var message = "Are you sure to delete Product ";
    mvi=document.forms[0].MVI;
    mei=document.forms[0].MEI;
    lpi=document.forms[0].LPI;
    if(null != mvi)
    ++i;
    if(null != mei )
    ++i;
    if(null != lpi)
    ++i;
    if(null != mvi && mvi.checked)
    deselectedproduct[++j]="MVI?";
    if(null != mei && mei.checked)
    deselectedproduct[++j]="GAP?";
    if(null != lpi && lpi.checked)
    deselectedproduct[++j]="LPI?";
    if( 0!=j)
    if(i!=j)
    for (x=0; x<deselectedproduct.length; x++)
    if(null != deselectedproduct[x])
    message =message+ "-" +deselectedproduct[x];
    alert(message);
    else
    //alert(" You cannot remove all products!");
    return false;
    return true;
    }

  • I have a Verizon IPhone 4 and i can't figure out how to get my ringtones from an app to my iTunes account, it doesn't have a tab for Ringtones! I have tried unplugging it and checking if would show up but it didn't, how do you enable the ringtone folder?

    I have a verizon IPhone and i can't figure out how to get my ringtones from the app to iTunes, my account doesn't have a ringtone section in the liRingtone Folder?brary, how do you enable the ringtone folder?

    Edit > Preferences.  Select the check box for Ringtones, this will add them to the listing in iTunes. 
    Not sure that really answers your question though.

  • How to get the data from mysql database which is being accessed by a PHP application and process the data locally in adobe air application and finally commit the changes back in to mysql database through the PHP application.

    How to get the data from mysql database which is being accessed by a PHP application and process the data locally in adobe air application and finally commit the changes back in to mysql database through the PHP application.

    If the data is on a remote server (for example, PHP running on a web server, talking to a MySQL server) then you do this in an AIR application the same way you would do it with any Flex application (or ajax application, if you're building your AIR app in HTML/JS).
    That's a broad answer, but in fact there are lots of ways to communicate between Flex and PHP. The most common and best in most cases is to use AMFPHP (http://amfphp.org/) or the new ZEND AMF support in the Zend Framework.
    This page is a good starting point for learning about Flex and PHP communication:
    http://www.adobe.com/devnet/flex/flex_php.html
    Also, in Flash Builder 4 they've added a lot of remote-data-connection functionality, including a lot that's designed for PHP. Take a look at the Flash Builder 4 public beta for more on that: http://labs.adobe.com/technologies/flashbuilder4/

  • Okay so my ipod got disabled, so i had to restore it and i was wondering how to get my music from itunes to my ipod?

    okay so my ipod got disabled, so i had to restore it and i was wondering how to get my music from itunes to my ipod?

    You can sync it to your iPod by:
    To sync to your iPod go to iTunes>Help>iTunes Help>Sync your iPod.... and follow the instructions.
    You can also redownlaod iTunes purchases directly to the iPod by:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store

  • I have a new iMac running iTunes 10.4 in OS 10.6.8, and a new Mac Air running iTunes 10.4 in Lion.  I was able to transfer all my music etc. from the iMac onto the Air, but cannot figure out how to get the Playlists from the iMac to the Air.  iTunes Help

    I have a new iMac running iTunes 10.4 in OS 10.6.8, and a new Mac Air running iTunes 10.4 in Lion.  I was able to transfer all my music etc. from the iMac onto the Air, but cannot figure out how to get the Playlists from the iMac to the Air.  iTunes Help says File >Library >Export playlist and choose XML, or to save a copy of all your playlists, File > Library > Export Library, "the Exported info is saved in XML format."  Then it says, "to import an iTunes playlist, File > Library > Import Playlist".  Now I am assuming I do that import part on the Air, but when I try it doesn't recognize anything that can be imported - what am I missing??? Aside from a clue...

    Thanks, Jim, for taking the time, but the reply is unfortunately vague in the exact area of my confusion!  "you need to copy that file to your new computer..."  Well, the Import/Export instructions make it seem as if the two computers should be able to communicate this file thru wifi, but that's the linkage I can't seem tocreate with Import/Export.  Should I instead email a copy to myself (thats what applecare suggested)?  Copy it to and from a thumb drive?  But then place the file where?  And the article was helpful, but should I be trying to move the Library file or the Library.xml file (as iTunes Help suggests)?  Sorry to be so clueless about it...I suppose I buy Apple in the hopes of not having to think about this stuff, which approach seems not to be serving me well. Thanks again for your time!

  • Im on the 10.6.8 software and i recently deleted my mac app store and emptied trash and dont know how to get it back now.

    Im on the 10.6.8 software and i recently deleted my mac app store and emptied trash and dont know how to get it back now.

    Download and run the 10.6.8 combo update http://support.apple.com/kb/DL1399

  • Submit a PDF as a PDF to a servlet, and how to get my PDF from servlet

    Hi all as the title above,
    i have a button typeformat as PDF and sent to a URL( which is my servlet )
    after this step how to get the PDF from my servlet.
    the PDF has sent to my servlet and stop, so is there any way to get the PDF i sent ?
    can someone help me?
    thanks

    You can use the following code:
    byte[] content = getRequestBufferAsBytes(request);
    ...then do whatever you want
    public static byte[] getRequestBufferAsBytes(HttpServletRequest request) throws IOException, ServletException
    // get the RequestBuffer
    ServletInputStream oInput = request.getInputStream();
    long nContentLength = request.getContentLength();
    String contentType = request.getContentType();
    if (nContentLength <= 0)
    return null;
    byte[] cContent = new byte[(int)nContentLength];
    // read the content in 512 bytes chunks
    // a single read does not get all the characters
    int nRead = 0;
    int nToRead = (int)nContentLength;
    int nBlkSize = 512;
    byte[] cTemp = new byte[512];
    do {
    int n = 0;
    int i = 0;
    if (nToRead - nRead < 512)
    nBlkSize = nToRead - nRead;
    n = oInput.read( cTemp,0,nBlkSize);
    for (i = 0; i < n; i++)
    cContent[i+nRead] = cTemp[i];
    nRead += i;
    } while (nRead < nToRead);
    //cContent[nRead] = (byte)'\0';
    Long nBytesRead = new Long( nRead );
    return cContent;
    Jasmin

  • So my computer crashed and i had lost all my itunes purchases and dont know how to get them back, so my computer crashed and i had lost all my itunes purchases and dont know how to get them back

    so my computer crashed and i had lost all my itunes purchases and dont know how to get them back, so my computer crashed and i had lost all my itunes purchases and dont know how to get them back

    You have a backup of your computer, or at the very least of your iTunes media, correct?
    Simply copy your backup of your iTunes media into the iTunes library on your new computer.
    Connecting and syncing your device to the new computer without first recovering your iTunes media is a really, really, really bad idea.  iDevices are designed to ONLY sync with one computer.  When you plug your device into a new computer, it will wipe all media on the device when it syncs.  The only media you may be able to salvage and transfer to the new computer would be anything bought directly on the device.
    If you do not have a backup of your iTunes media, then you will want to either look at a way (using software from a third party company)  to either extract the media from you iDevice or your old computer (assuming the hard drive is not toast).

  • I am using the window xp and firefox 6. I see many videos on youtube. How I get that videos from the catch folder and where is it?

    I am using the window xp and firefox 6.
    I watch the youtube videos online.
    How I get that video from the catch folder and where that catch folder are situated in the window xp.

    ''How can I view or retrieve a video from Firefox's cache''
    To actually view/retrieve the file from the cache and its web address you can use
    the "Cache Viewer" extension 32.8KB
    * https://addons.mozilla.org/firefox/addon/cacheviewer/
    * http://dmcritchie.mvps.org/firefox/firefox.htm#cacheviewer
    For you to be able to view the cached file you would have had to have watched the entire file.
    The latest version of the extension is 0.7b available in all versions you would have to override compatibility by any of these methods
    * checking or pick up one of the xpi versions in the reader comments for Firefox 6.0
    * extensions.checkCompatibility.6.0 set to False
    *: http://kb.mozillazine.org/Extensions.checkCompatibility
    * or with an extension "Add-on Compatibility Reporter" (84.0 KB) seems preferred in this group
    *:https://addons.mozilla.org/en-US/firefox/addon/add-on-compatibility-reporter/
    There are also extensions such as Video downloader 132.8 KB
    * Download YouTube Videos + Flash Video Downloader / Download-Helper
    *:https://addons.mozilla.org/firefox/addon/download-youtube-videos/
    <br><small>Please mark "Solved" one answer that will best help others with a similar problem after you've tried several things.</small>

  • How to get current time and date??

    How to get current time and date from my PC time and date to the java application??
    i use java.util.* package but got error, that is:
    - java.util.* and java.sql.* class are match
    - abstract class cannot be instantiated
    so what can i do, pls guide...thanks...

    There is a method in the System class that will return the current system time. You could also instantiate a Date, Time, Timestamp, or Calendar object, all of which get created with the system time by default.
    Don't import *. Import the specific classes you need.
    Next time, post the actual text of the exceptions/compile errors. If you make people guess, most just won't bother.

  • I made a new apple id and after that i cant get my updates from my iTunes on my pc. How can I do to get it back

    I made a new apple id and after that i cant get my updates from my iTunes on my pc. How can I do to get it back

    Sign out from the new Apple ID with iTunes on your computer and sign in with your old iTunes account with iTunes.

Maybe you are looking for

  • Outlook Hangs - Loading Profile / Add Account Stage - Office 365 on Windows 8.1

    I have been using outlook via the Office 365 offering for a year. Then 2 days back suddenly my outlook stopped downloading mails from my mail server. It did however send mails. I went online to check the various causes and after following lots of adv

  • Error creating a classic HFM application in Hyperion 11.1.2.2

    I am trying to create a classic hfm application in Hyperion 11.1.2.2. When i enter application name and other information and press submit it shows message 'Creating new application' but then gives an error The following exception has occurred in .()

  • Where is the extension folder for Adobe Bridge? (Mac)

    I am trying to install the output module on Adobe Bridge. I am totally new to Creative Suite and photoshop. I can't find any information on bridge extensions at all. Here's the page I found on installing the output module- http://helpx.adobe.com/brid

  • Budget Error at the time of Release of Purchase order

    Hi, We are using former budgeting and getting budget payment budget exceeding error at the time of releasing a carry forward PO. PO has been successfully carried forward to next year and we are not making any changes in the PO. While releasing the sa

  • Account Groups !!!

    Hi Everyone.. In customizing, I have found two paths regarding account groups.. 1. IMG - Financial Accounting --> Accounts Receivable and Accounts Payable --> Customer Accounts --> Master Data --> Preparations for Creating Customer Master Data --> De