Difference between revisions of "Public.getmanagepercentavailnodewindow (function)"
Line 1: | Line 1: | ||
== wikibot == | == wikibot == | ||
+ | |||
+ | {| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" | ||
+ | |- | ||
+ | | '''Function | ||
+ | | public.getmanagepercentavailnodewindow | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | |||
+ | === Source === | ||
+ | <pre> | ||
CREATE OR REPLACE FUNCTION public.getmanagepercentavailnodewindow(integer, timestamp without time zone, timestamp without time zone) | CREATE OR REPLACE FUNCTION public.getmanagepercentavailnodewindow(integer, timestamp without time zone, timestamp without time zone) | ||
RETURNS double precision | RETURNS double precision | ||
Line 34: | Line 45: | ||
END; | END; | ||
$function$ | $function$ | ||
+ | </pre> | ||
+ | |||
+ | === References === | ||
+ | {| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" | ||
+ | |- style="background:silver" | ||
+ | | '''Dependency Type | ||
+ | | '''Object Type | ||
+ | | '''Referenced Object | ||
+ | |||
|- | |- | ||
| Execute | | Execute | ||
Line 43: | Line 63: | ||
| Function | | Function | ||
| [[public.getmanagedservicecountfornode_(function)|public.getmanagedservicecountfornode]] | | [[public.getmanagedservicecountfornode_(function)|public.getmanagedservicecountfornode]] | ||
+ | |||
+ | |} |
Revision as of 08:37, 11 February 2010
wikibot
Function | public.getmanagepercentavailnodewindow |
Source
CREATE OR REPLACE FUNCTION public.getmanagepercentavailnodewindow(integer, timestamp without time zone, timestamp without time zone) RETURNS double precision LANGUAGE plpgsql AS $function$ DECLARE nid ALIAS FOR $1; xtime ALIAS FOR $2; ytime ALIAS FOR $3; downtime float8 := 0.0; count integer := 0; rollingWindow float := 0; totalServiceTime float := 0; BEGIN IF xtime < ytime THEN rollingWindow := EXTRACT (EPOCH FROM (ytime - xtime)); downtime := getManagedOutageForNodeInWindow(nid, ytime, xtime)/1000; ELSE rollingWindow := EXTRACT (EPOCH FROM (xtime - ytime)); downtime := getManagedOutageForNodeInWindow(nid, xtime, ytime)/1000; END IF; count := getManagedServiceCountForNode(nid); totalServiceTime := count * rollingWindow; IF totalServiceTime > 0 THEN RETURN 100 * (1 - (downtime / totalServiceTime)); ELSE IF totalServiceTime = 0 THEN RETURN 100; ELSE RETURN -1; END IF; END IF; END; $function$
References
Dependency Type | Object Type | Referenced Object |
Execute | Function | public.getmanagedoutagefornodeinwindow |
Execute | Function | public.getmanagedservicecountfornode |