Welcome Guest, you are in: Login

devio dbscript ScrewTurn Wiki

RSS RSS

Navigation





Search the wiki
»

PoweredBy

public getpercentavailabilityinwindow (function)

RSS
Modified on 2011/08/27 11:44 by wikibot Categorized as Uncategorized

wikibot

Functionpublic.getpercentavailabilityinwindow

Source

CREATE OR REPLACE FUNCTION public.getpercentavailabilityinwindow(integer, character varying, integer, timestamp without time zone, timestamp without time zone)
 RETURNS double precision
 LANGUAGE plpgsql
AS $function$
   DECLARE
	nid ALIAS FOR $1;
	ipid ALIAS FOR $2;
	sid ALIAS FOR $3;
	xtime ALIAS FOR $4;
	ytime ALIAS FOR $5;
	downtime float8;
   BEGIN
	downtime := getOutageTimeInWindow(nid, ipid, sid, xtime, ytime);
	IF xtime > ytime THEN
		RETURN 100 * (1 - (downtime / (EXTRACT(EPOCH FROM (xtime - ytime))* 1000)));
	ELSE
		RETURN 100 * (1 - (downtime / (EXTRACT(EPOCH FROM (ytime - xtime))* 1000)));
	END IF;
   END;
$function$

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam.