Difference between revisions of "Public.getmanagepercentavailintfwindow (function)"
| Line 2: | Line 2: | ||
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" | {| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" | ||
| − | |- | + | |- valign="top" |
| '''Function | | '''Function | ||
| public.getmanagepercentavailintfwindow | | public.getmanagepercentavailintfwindow | ||
| − | |||
|} | |} | ||
| − | |||
=== Source === | === Source === | ||
| Line 55: | Line 53: | ||
| '''Referenced Object | | '''Referenced Object | ||
| − | |- | + | |- valign="top" |
| Execute | | Execute | ||
| Function | | Function | ||
| [[public.getmanagedoutageforintfinwindow_(function)|public.getmanagedoutageforintfinwindow]] | | [[public.getmanagedoutageforintfinwindow_(function)|public.getmanagedoutageforintfinwindow]] | ||
| − | |- | + | |- valign="top" |
| Execute | | Execute | ||
| Function | | Function | ||
Revision as of 23:38, 24 June 2010
wikibot
| Function | public.getmanagepercentavailintfwindow |
Source
CREATE OR REPLACE FUNCTION public.getmanagepercentavailintfwindow(integer, character varying, timestamp without time zone, timestamp without time zone)
RETURNS double precision
LANGUAGE plpgsql
AS $function$
DECLARE
nid ALIAS FOR $1;
ipid ALIAS FOR $2;
xtime ALIAS FOR $3;
ytime ALIAS FOR $4;
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 := getManagedOutageForIntfInWindow(nid, ipid, ytime, xtime)/1000;
ELSE
rollingWindow := EXTRACT (EPOCH FROM (xtime - ytime));
downtime := getManagedOutageForIntfInWindow(nid, ipid, xtime, ytime)/1000;
END IF;
count := getManagedServiceCountForIntf(nid, ipid);
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.getmanagedoutageforintfinwindow |
| Execute | Function | public.getmanagedservicecountforintf |