Skip to content

Commit 60c59c5

Browse files
committed
initial commit
1 parent 6e42f11 commit 60c59c5

15 files changed

+1074
-0
lines changed

database/createdbcontent.sql

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
echo Creating database objects...
2+
3+
--fintrack schema
4+
5+
\echo fintrack:tables
6+
7+
\i fincfg/tables/queueactions.sql
8+
\i fincfg/tables/tracestatus.sql
9+
\i fincfg/tables/routingschemaanalysis.sql
10+
\i fincfg/tables/routingjobstmpstop.sql
11+
\i fincfg/tables/routingjobstmpstart.sql
12+
\i fincfg/tables/routingjobsstmint.sql
13+
\i fincfg/tables/overallperformance.sql
14+
\i fincfg/tables/liveperformance.sql
15+
\i fincfg/tables/componentperformance.sql
16+
17+
18+
19+
\echo fintrack:functions
20+
21+
\i fincfg/functions/stoptrace.sql
22+
\i fincfg/functions/starttrace.sql
23+
\i fincfg/functions/collectrsdata.sql
24+
\i fincfg/functions/collectrjliveperformance.sql
25+
\i fincfg/functions/collectoverallperformance.sql
26+
\i fincfg/functions/collectcomponentperformance.sql
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
-- FUNCTION: fintrack.collectcomponentperformance(integer)
2+
3+
-- DROP FUNCTION fintrack.collectcomponentperformance(integer);
4+
5+
CREATE OR REPLACE FUNCTION fintrack.collectcomponentperformance(
6+
inuserid integer)
7+
RETURNS text
8+
LANGUAGE 'plpgsql'
9+
10+
COST 100
11+
VOLATILE
12+
AS $BODY$
13+
14+
DECLARE
15+
16+
/*
17+
* FinTP - Financial Transactions Processing Application
18+
* Copyright (C) 2013 Business Information Systems (Allevo) S.R.L.
19+
*
20+
* This program is free software: you can redistribute it and/or modify
21+
* it under the terms of the GNU General Public License as published by
22+
* the Free Software Foundation, either version 3 of the License, or
23+
* (at your option) any later version.
24+
*
25+
* This program is distributed in the hope that it will be useful,
26+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
27+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28+
* GNU General Public License for more details.
29+
*
30+
* You should have received a copy of the GNU General Public License
31+
* along with this program. If not, see <http://www.gnu.org/licenses/>
32+
* or contact Allevo at : 031281 Bucuresti, 23C Calea Vitan, Romania,
33+
* phone +40212554577, office@allevo.ro <office@allevo.ro>, www.allevo.ro.
34+
*/
35+
/************************************************
36+
Change history:
37+
Created: 01.Feb.2019 - DanielC - 13036
38+
Description: Component performance report
39+
Parameters: inuserid - the user who required the report
40+
Returns: n/a
41+
Used: FinTP/BASE/RE
42+
***********************************************/
43+
v_processingtime integer;
44+
v_totalprocmsg integer;
45+
v_timenow timestamp without time zone;
46+
v_cmpthread character varying;
47+
v_cmpname character varying;
48+
v_cmpcategory character varying;
49+
v_noofevents integer;
50+
v_nooferrevents integer;
51+
v_noofmngevents integer;
52+
v_idletime integer;
53+
v_procrate numeric(8,2);
54+
v_prechour text;
55+
v_precnosec double precision;
56+
v_intervals text default '';
57+
rec fintrack.service_class_pair;
58+
xdate fintrack.date_secno_pair;
59+
60+
61+
BEGIN
62+
v_timenow := current_timestamp::timestamp(0);
63+
v_cmpthread := null;
64+
65+
--iterate trough unique pairs of service-class
66+
for rec in select distinct service, class from findata.status where service in (select id from fincfg.servicemaps)
67+
loop
68+
-- calculate processingtime and the total number or processed messages
69+
select count(distinct(date_part('second', insertdate))), count(distinct(correlationid))
70+
into v_processingtime, v_totalprocmsg
71+
from findata.status
72+
where trim(type) = 'Info' and insertdate::date = v_timenow::date and service = rec.service and class = rec.class;
73+
74+
-- find component name and component category
75+
select name, partner into v_cmpname, v_cmpcategory from fincfg.servicemaps
76+
where id = rec.service;
77+
78+
-- find component thread
79+
if (rec.class = 'Transaction.Fetch') then
80+
v_cmpthread := 'Fetch';
81+
elsif (rec.class = 'Transaction.Publish') then
82+
v_cmpthread := 'Publish';
83+
end if;
84+
85+
-- calculate number of events for Info/Error/Management
86+
select coalesce(sum(case when trim(type) = 'Info' then 1 else 0 end), 0),
87+
coalesce(sum(case when trim(type) = 'Error' or trim(type) = 'Warning' then 1 else 0 end), 0),
88+
coalesce(sum(case when trim(type) = 'Management' then 1 else 0 end), 0)
89+
into v_noofevents, v_nooferrevents, v_noofmngevents
90+
from findata.status
91+
where insertdate::date = v_timenow::date and service = rec.service and class = rec.class;
92+
93+
-- calculate idletime and processing rate
94+
v_idletime := 24 * 60 * 60 - v_processingtime;
95+
if (v_totalprocmsg = 0) then
96+
v_procrate := 0;
97+
else
98+
v_procrate := (v_totalprocmsg::numeric) / (v_processingtime::numeric);
99+
end if;
100+
101+
--calculate intervals
102+
v_intervals := '';
103+
v_precnosec := 0;
104+
v_prechour := '';
105+
106+
for xdate in select substring(cast(insertdate as character varying), 12, 8) as insdate,
107+
extract(hour from insertdate)*60*60 + extract(minute from insertdate)*60 + trunc(extract(second from insertdate)) as conv
108+
from findata.status
109+
where insertdate::date = v_timenow::date and service = rec.service and class = rec.class and trim(type) = 'Info'
110+
order by conv
111+
loop
112+
if (xdate.conv - v_precnosec > 1) then
113+
if (v_precnosec = 0) then
114+
v_intervals := v_intervals || xdate.insdate || '-';
115+
else
116+
v_intervals := v_intervals || v_prechour || '; ';
117+
v_intervals := v_intervals || xdate.insdate || '-';
118+
end if;
119+
end if;
120+
121+
v_prechour := xdate.insdate;
122+
v_precnosec := xdate.conv;
123+
end loop;
124+
125+
v_intervals := v_intervals || v_prechour || '; ';
126+
127+
-- insert results
128+
insert into fintrack.componentperformance
129+
values (v_timenow::date, to_char(v_timenow::time, 'HH:MI:SS'),v_cmpname, v_cmpthread, v_cmpcategory,
130+
v_idletime, v_processingtime, v_procrate, v_noofevents, v_nooferrevents, v_noofmngevents, v_intervals, inuserid);
131+
end loop;
132+
133+
-- stop trace
134+
v_idletime := fintrack.stoptrace(inuserid);
135+
136+
RETURN to_char(v_timenow, 'YYYY-MM-DD HH24:MI:SS');
137+
138+
EXCEPTION
139+
WHEN OTHERS THEN
140+
RAISE EXCEPTION 'Unexpected error occured while configuring queue: %', SQLERRM;
141+
END;
142+
143+
$BODY$;
144+
145+
ALTER FUNCTION fintrack.collectcomponentperformance(integer)
146+
OWNER TO fintrack;
147+
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
-- FUNCTION: fintrack.collectoverallperformance(integer)
2+
3+
-- DROP FUNCTION fintrack.collectoverallperformance(integer);
4+
5+
CREATE OR REPLACE FUNCTION fintrack.collectoverallperformance(
6+
inuserid integer)
7+
RETURNS text
8+
LANGUAGE 'plpgsql'
9+
10+
COST 100
11+
VOLATILE
12+
AS $BODY$
13+
14+
DECLARE
15+
16+
/*
17+
* FinTP - Financial Transactions Processing Application
18+
* Copyright (C) 2013 Business Information Systems (Allevo) S.R.L.
19+
*
20+
* This program is free software: you can redistribute it and/or modify
21+
* it under the terms of the GNU General Public License as published by
22+
* the Free Software Foundation, either version 3 of the License, or
23+
* (at your option) any later version.
24+
*
25+
* This program is distributed in the hope that it will be useful,
26+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
27+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28+
* GNU General Public License for more details.
29+
*
30+
* You should have received a copy of the GNU General Public License
31+
* along with this program. If not, see <http://www.gnu.org/licenses/>
32+
* or contact Allevo at : 031281 Bucuresti, 23C Calea Vitan, Romania,
33+
* phone +40212554577, office@allevo.ro <office@allevo.ro>, www.allevo.ro.
34+
*/
35+
/************************************************
36+
Change history:
37+
Created: 01.Feb.2019 - DanielC - 13036
38+
Description: Component performance report
39+
Parameters: inuserid - the user who required the report
40+
Returns: n/a
41+
Used: FinTP/BASE/RE
42+
***********************************************/
43+
44+
v_timenow timestamp without time zone;
45+
area character varying;
46+
v_processingtime integer;
47+
v_nooftrx integer;
48+
v_idletime integer;
49+
v_procrate numeric(8,2);
50+
v_nooferrevents integer;
51+
v_noofmngevents integer;
52+
v_intervals text default '';
53+
v_prechour text;
54+
v_precnosec double precision;
55+
xdate fintrack.date_secno_pair;
56+
57+
BEGIN
58+
59+
v_timenow := current_timestamp::timestamp(0);
60+
61+
for area in select distinct(findata.getbusinessareabyid(correlationid)) as businessareas from findata.status where insertdate::date = v_timenow::date
62+
loop
63+
if (area is not null) then
64+
-- calculate processingtime and the total number or processed messages
65+
select count(distinct(date_part('second', insertdate))), count(distinct(correlationid))
66+
into v_processingtime, v_nooftrx
67+
from findata.status
68+
where trim(type) = 'Info' and insertdate::date = v_timenow::date and service != -1 and findata.getbusinessareabyid(correlationid) = area;
69+
70+
71+
72+
-- calculate idletime and processing rate
73+
v_idletime := 24 * 60 * 60 - v_processingtime;
74+
if (v_nooftrx = 0) then
75+
v_procrate := 0;
76+
else
77+
v_procrate := (v_nooftrx::numeric) / (v_processingtime::numeric);
78+
end if;
79+
80+
-- calculate number of events for Error/Management
81+
select coalesce(sum(case when trim(type) = 'Error' or trim(type) = 'Warning' then 1 else 0 end), 0),
82+
coalesce(sum(case when trim(type) = 'Management' then 1 else 0 end), 0)
83+
into v_nooferrevents, v_noofmngevents
84+
from findata.status
85+
where insertdate::date = v_timenow::date and service != -1 and findata.getbusinessareabyid(correlationid) = area;
86+
87+
--calculate intervals
88+
v_intervals := '';
89+
v_precnosec := 0;
90+
v_prechour := '';
91+
92+
for xdate in select substring(cast(insertdate as character varying), 12, 8) as insdate,
93+
extract(hour from insertdate)*60*60 + extract(minute from insertdate)*60 + trunc(extract(second from insertdate)) as conv
94+
from findata.status
95+
where insertdate::date = v_timenow::date and service != -1 and findata.getbusinessareabyid(correlationid) = area and trim(type) = 'Info'
96+
order by conv
97+
loop
98+
if (xdate.conv - v_precnosec > 1) then
99+
if (v_precnosec = 0) then
100+
v_intervals := v_intervals || xdate.insdate || '-';
101+
else
102+
v_intervals := v_intervals || v_prechour || '; ';
103+
v_intervals := v_intervals || xdate.insdate || '-';
104+
end if;
105+
end if;
106+
107+
v_prechour := xdate.insdate;
108+
v_precnosec := xdate.conv;
109+
end loop;
110+
111+
v_intervals := v_intervals || v_prechour || '; ';
112+
113+
-- insert results
114+
insert into fintrack.overallperformance
115+
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);
116+
117+
end if;
118+
end loop;
119+
120+
-- stop trace
121+
v_idletime := fintrack.stoptrace(inuserid);
122+
123+
RETURN to_char(v_timenow, 'YYYY-MM-DD HH24:MI:SS');
124+
125+
EXCEPTION
126+
WHEN OTHERS THEN
127+
RAISE EXCEPTION 'Unexpected error occured while configuring queue: %', SQLERRM;
128+
END;
129+
130+
$BODY$;
131+
132+
ALTER FUNCTION fintrack.collectoverallperformance(integer)
133+
OWNER TO fintrack;
134+

0 commit comments

Comments
 (0)