SQL Server 2000 and 2005 Uptime script

  • Hi,

    Has anyone a script that does the following:

    calculate the availability in percentage per startup (or reboot) of a particalur database

    We have already a table with the last uptime, and the starttime

    Each 5 minutes the uptime table is added with the current timestamp

    We use the availabilty script to generate an uptime report of each database

    For oracle we have already a script (which uses a inline view)

  • Are you storing something besides times? (show DDL or sample)

    Here's the thing. How do you know the downtime? Once you have the two numbers, you would have to then figure out how you want to calculate this percentage. Is it of the week, day, up v down, not sure what you want.

  • We do not know what the downtime is, but we do know what the maximum is:

    1440 minutes, so we calculate only the percentage.

    We are using in oracle a table, with only 2 columns:

    Startuptime and timestamp. Every 5 minutes we insert the uptime column with a new timestamp.

    We want to convert ( or reverse engineer) the Oracle script.

    This is the oracle version of the script:

    Name Null? Type

    ----------------------------------------- -------- -------------

    UPTIME DATE

    STARTIME DATE

    HOST VARCHAR2(64)

    set pagesize 0

    set feedback off

    set verify off

    set heading off

    whenever sqlerror exit

    select lower(instance_name)||','||round(((least(heledag.minuten+(10),1440))/1440)*100 ,2)

    from (select heledag.updag

    , sum(heledag.minuten) minuten

    from (select trunc(uptime) updag

    , (max(uptime)-min(uptime))*1440 minuten

    from uptime

    where trunc(uptime) = trunc(sysdate)-1

    group by startime, trunc(uptime)) heledag

    group by heledag.updag) heledag

    , v$instance

    /

    exit

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply