-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
1,074 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
echo Creating database objects... | ||
|
||
--fintrack schema | ||
|
||
\echo fintrack:tables | ||
|
||
\i fincfg/tables/queueactions.sql | ||
\i fincfg/tables/tracestatus.sql | ||
\i fincfg/tables/routingschemaanalysis.sql | ||
\i fincfg/tables/routingjobstmpstop.sql | ||
\i fincfg/tables/routingjobstmpstart.sql | ||
\i fincfg/tables/routingjobsstmint.sql | ||
\i fincfg/tables/overallperformance.sql | ||
\i fincfg/tables/liveperformance.sql | ||
\i fincfg/tables/componentperformance.sql | ||
|
||
|
||
|
||
\echo fintrack:functions | ||
|
||
\i fincfg/functions/stoptrace.sql | ||
\i fincfg/functions/starttrace.sql | ||
\i fincfg/functions/collectrsdata.sql | ||
\i fincfg/functions/collectrjliveperformance.sql | ||
\i fincfg/functions/collectoverallperformance.sql | ||
\i fincfg/functions/collectcomponentperformance.sql |
147 changes: 147 additions & 0 deletions
147
database/fintrack/functions/collectcomponentperformance.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
-- FUNCTION: fintrack.collectcomponentperformance(integer) | ||
|
||
-- DROP FUNCTION fintrack.collectcomponentperformance(integer); | ||
|
||
CREATE OR REPLACE FUNCTION fintrack.collectcomponentperformance( | ||
inuserid integer) | ||
RETURNS text | ||
LANGUAGE 'plpgsql' | ||
|
||
COST 100 | ||
VOLATILE | ||
AS $BODY$ | ||
|
||
DECLARE | ||
|
||
/* | ||
* FinTP - Financial Transactions Processing Application | ||
* Copyright (C) 2013 Business Information Systems (Allevo) S.R.L. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
* or contact Allevo at : 031281 Bucuresti, 23C Calea Vitan, Romania, | ||
* phone +40212554577, office@allevo.ro <office@allevo.ro>, www.allevo.ro. | ||
*/ | ||
/************************************************ | ||
Change history: | ||
Created: 01.Feb.2019 - DanielC - 13036 | ||
Description: Component performance report | ||
Parameters: inuserid - the user who required the report | ||
Returns: n/a | ||
Used: FinTP/BASE/RE | ||
***********************************************/ | ||
v_processingtime integer; | ||
v_totalprocmsg integer; | ||
v_timenow timestamp without time zone; | ||
v_cmpthread character varying; | ||
v_cmpname character varying; | ||
v_cmpcategory character varying; | ||
v_noofevents integer; | ||
v_nooferrevents integer; | ||
v_noofmngevents integer; | ||
v_idletime integer; | ||
v_procrate numeric(8,2); | ||
v_prechour text; | ||
v_precnosec double precision; | ||
v_intervals text default ''; | ||
rec fintrack.service_class_pair; | ||
xdate fintrack.date_secno_pair; | ||
|
||
|
||
BEGIN | ||
v_timenow := current_timestamp::timestamp(0); | ||
v_cmpthread := null; | ||
|
||
--iterate trough unique pairs of service-class | ||
for rec in select distinct service, class from findata.status where service in (select id from fincfg.servicemaps) | ||
loop | ||
-- calculate processingtime and the total number or processed messages | ||
select count(distinct(date_part('second', insertdate))), count(distinct(correlationid)) | ||
into v_processingtime, v_totalprocmsg | ||
from findata.status | ||
where trim(type) = 'Info' and insertdate::date = v_timenow::date and service = rec.service and class = rec.class; | ||
|
||
-- find component name and component category | ||
select name, partner into v_cmpname, v_cmpcategory from fincfg.servicemaps | ||
where id = rec.service; | ||
|
||
-- find component thread | ||
if (rec.class = 'Transaction.Fetch') then | ||
v_cmpthread := 'Fetch'; | ||
elsif (rec.class = 'Transaction.Publish') then | ||
v_cmpthread := 'Publish'; | ||
end if; | ||
|
||
-- calculate number of events for Info/Error/Management | ||
select coalesce(sum(case when trim(type) = 'Info' then 1 else 0 end), 0), | ||
coalesce(sum(case when trim(type) = 'Error' or trim(type) = 'Warning' then 1 else 0 end), 0), | ||
coalesce(sum(case when trim(type) = 'Management' then 1 else 0 end), 0) | ||
into v_noofevents, v_nooferrevents, v_noofmngevents | ||
from findata.status | ||
where insertdate::date = v_timenow::date and service = rec.service and class = rec.class; | ||
|
||
-- calculate idletime and processing rate | ||
v_idletime := 24 * 60 * 60 - v_processingtime; | ||
if (v_totalprocmsg = 0) then | ||
v_procrate := 0; | ||
else | ||
v_procrate := (v_totalprocmsg::numeric) / (v_processingtime::numeric); | ||
end if; | ||
|
||
--calculate intervals | ||
v_intervals := ''; | ||
v_precnosec := 0; | ||
v_prechour := ''; | ||
|
||
for xdate in select substring(cast(insertdate as character varying), 12, 8) as insdate, | ||
extract(hour from insertdate)*60*60 + extract(minute from insertdate)*60 + trunc(extract(second from insertdate)) as conv | ||
from findata.status | ||
where insertdate::date = v_timenow::date and service = rec.service and class = rec.class and trim(type) = 'Info' | ||
order by conv | ||
loop | ||
if (xdate.conv - v_precnosec > 1) then | ||
if (v_precnosec = 0) then | ||
v_intervals := v_intervals || xdate.insdate || '-'; | ||
else | ||
v_intervals := v_intervals || v_prechour || '; '; | ||
v_intervals := v_intervals || xdate.insdate || '-'; | ||
end if; | ||
end if; | ||
|
||
v_prechour := xdate.insdate; | ||
v_precnosec := xdate.conv; | ||
end loop; | ||
|
||
v_intervals := v_intervals || v_prechour || '; '; | ||
|
||
-- insert results | ||
insert into fintrack.componentperformance | ||
values (v_timenow::date, to_char(v_timenow::time, 'HH:MI:SS'),v_cmpname, v_cmpthread, v_cmpcategory, | ||
v_idletime, v_processingtime, v_procrate, v_noofevents, v_nooferrevents, v_noofmngevents, v_intervals, inuserid); | ||
end loop; | ||
|
||
-- stop trace | ||
v_idletime := fintrack.stoptrace(inuserid); | ||
|
||
RETURN to_char(v_timenow, 'YYYY-MM-DD HH24:MI:SS'); | ||
|
||
EXCEPTION | ||
WHEN OTHERS THEN | ||
RAISE EXCEPTION 'Unexpected error occured while configuring queue: %', SQLERRM; | ||
END; | ||
|
||
$BODY$; | ||
|
||
ALTER FUNCTION fintrack.collectcomponentperformance(integer) | ||
OWNER TO fintrack; | ||
|
134 changes: 134 additions & 0 deletions
134
database/fintrack/functions/collectoverallperformance.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
-- FUNCTION: fintrack.collectoverallperformance(integer) | ||
|
||
-- DROP FUNCTION fintrack.collectoverallperformance(integer); | ||
|
||
CREATE OR REPLACE FUNCTION fintrack.collectoverallperformance( | ||
inuserid integer) | ||
RETURNS text | ||
LANGUAGE 'plpgsql' | ||
|
||
COST 100 | ||
VOLATILE | ||
AS $BODY$ | ||
|
||
DECLARE | ||
|
||
/* | ||
* FinTP - Financial Transactions Processing Application | ||
* Copyright (C) 2013 Business Information Systems (Allevo) S.R.L. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
* or contact Allevo at : 031281 Bucuresti, 23C Calea Vitan, Romania, | ||
* phone +40212554577, office@allevo.ro <office@allevo.ro>, www.allevo.ro. | ||
*/ | ||
/************************************************ | ||
Change history: | ||
Created: 01.Feb.2019 - DanielC - 13036 | ||
Description: Component performance report | ||
Parameters: inuserid - the user who required the report | ||
Returns: n/a | ||
Used: FinTP/BASE/RE | ||
***********************************************/ | ||
|
||
v_timenow timestamp without time zone; | ||
area character varying; | ||
v_processingtime integer; | ||
v_nooftrx integer; | ||
v_idletime integer; | ||
v_procrate numeric(8,2); | ||
v_nooferrevents integer; | ||
v_noofmngevents integer; | ||
v_intervals text default ''; | ||
v_prechour text; | ||
v_precnosec double precision; | ||
xdate fintrack.date_secno_pair; | ||
|
||
BEGIN | ||
|
||
v_timenow := current_timestamp::timestamp(0); | ||
|
||
for area in select distinct(findata.getbusinessareabyid(correlationid)) as businessareas from findata.status where insertdate::date = v_timenow::date | ||
loop | ||
if (area is not null) then | ||
-- calculate processingtime and the total number or processed messages | ||
select count(distinct(date_part('second', insertdate))), count(distinct(correlationid)) | ||
into v_processingtime, v_nooftrx | ||
from findata.status | ||
where trim(type) = 'Info' and insertdate::date = v_timenow::date and service != -1 and findata.getbusinessareabyid(correlationid) = area; | ||
|
||
|
||
|
||
-- calculate idletime and processing rate | ||
v_idletime := 24 * 60 * 60 - v_processingtime; | ||
if (v_nooftrx = 0) then | ||
v_procrate := 0; | ||
else | ||
v_procrate := (v_nooftrx::numeric) / (v_processingtime::numeric); | ||
end if; | ||
|
||
-- calculate number of events for Error/Management | ||
select coalesce(sum(case when trim(type) = 'Error' or trim(type) = 'Warning' then 1 else 0 end), 0), | ||
coalesce(sum(case when trim(type) = 'Management' then 1 else 0 end), 0) | ||
into v_nooferrevents, v_noofmngevents | ||
from findata.status | ||
where insertdate::date = v_timenow::date and service != -1 and findata.getbusinessareabyid(correlationid) = area; | ||
|
||
--calculate intervals | ||
v_intervals := ''; | ||
v_precnosec := 0; | ||
v_prechour := ''; | ||
|
||
for xdate in select substring(cast(insertdate as character varying), 12, 8) as insdate, | ||
extract(hour from insertdate)*60*60 + extract(minute from insertdate)*60 + trunc(extract(second from insertdate)) as conv | ||
from findata.status | ||
where insertdate::date = v_timenow::date and service != -1 and findata.getbusinessareabyid(correlationid) = area and trim(type) = 'Info' | ||
order by conv | ||
loop | ||
if (xdate.conv - v_precnosec > 1) then | ||
if (v_precnosec = 0) then | ||
v_intervals := v_intervals || xdate.insdate || '-'; | ||
else | ||
v_intervals := v_intervals || v_prechour || '; '; | ||
v_intervals := v_intervals || xdate.insdate || '-'; | ||
end if; | ||
end if; | ||
|
||
v_prechour := xdate.insdate; | ||
v_precnosec := xdate.conv; | ||
end loop; | ||
|
||
v_intervals := v_intervals || v_prechour || '; '; | ||
|
||
-- insert results | ||
insert into fintrack.overallperformance | ||
values (v_timenow::date, to_char(v_timenow::time, 'HH24:MI:SS'), area, v_idletime, v_processingtime, v_procrate, v_nooftrx, v_nooferrevents, v_noofmngevents, v_intervals, inuserid); | ||
|
||
end if; | ||
end loop; | ||
|
||
-- stop trace | ||
v_idletime := fintrack.stoptrace(inuserid); | ||
|
||
RETURN to_char(v_timenow, 'YYYY-MM-DD HH24:MI:SS'); | ||
|
||
EXCEPTION | ||
WHEN OTHERS THEN | ||
RAISE EXCEPTION 'Unexpected error occured while configuring queue: %', SQLERRM; | ||
END; | ||
|
||
$BODY$; | ||
|
||
ALTER FUNCTION fintrack.collectoverallperformance(integer) | ||
OWNER TO fintrack; | ||
|
Oops, something went wrong.