-
Notifications
You must be signed in to change notification settings - Fork 6
/
runaas.sql
219 lines (205 loc) · 5.12 KB
/
runaas.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
--
-- TOPAAS
-- Copyright: Marcin Przepiorowski - All rights reserved.
--
-- Special thanks go to Tanel Poder and Adrian Billington for idea of real time screen refresh in SQL*Plus window and PL/SQL collection based on internal Oracle package.
--
-- runtopaas is displaying Oracle Average Active Session calculated based on v$session samples. It is read only and doesn't need any objects inside database.
-- It is sampling data using v$session so it will work on Standard and Enterprise Edition without any additional packs.
-- This tool is using two scripts:
-- runtopaas.sql - is a main script to parse run attributes and specify a run environment for topaas.sql script. It is calling topaas.sql 100 times
-- topaas.sql - is sampling v$session every 1 s for time specified in refresh rate parameters and keep it in PL/SQL collection
-- At the end AAS (divided into 3 sections: CPU, Disk I/O and other) is calculated and displayed on screen.
-- In addition to that AAS results are added to bind variables together with sample time.
-- When topaas.sql is called next time it is reading data from bind variables and it allow it to have history of AAS from past and display
-- it on screen. Default configuration allow to display 100 data point
--
-- Usage:
-- Change SQL*Plus window / screen terminal to 45 characters height and 150 characters wide
-- Run in SQL*Plus window:
--
-- @runtopaas.sql aas:<refresh rate> - it will specify refresh rate (ex. 15 s) and with 100 samples it allow to keep 25 min of AAS in SQL*Plus window.
-- If script will be started again after 100 cycles or after user break in this same session it will still be able to display historical data
-- @runtopaas.sql aas:<refresh rate>:reset - like above but historical data are cleared
-- @runtopaas.sql aas:<refresh rate>:<max aas> - like above but maximum value of AAS (y axis) is set by user
-- @runtopaas.sql aas:<refresh rate>:<max aas>:reset - like above but historical data are cleared
prompt "Waiting for first refresh"
set term off
DEFINE _OLD_ONCPU = ""
DEFINE _OLD_USERIO = ""
DEFINE _OLD_OTHER = ""
DEFINE _OLD_AAS_TIME = ""
DEFINE _OLD_RUNMAX = "0"
col ifdefcpu noprint new_value _OLD_ONCPU
col ifdefio noprint new_value _OLD_USERIO
col ifdefother noprint new_value _OLD_OTHER
col ifdefaastime noprint new_value _OLD_AAS_TIME
col ifdefrunmax noprint new_value _OLD_RUNMAX
select :on_cpu ifdefcpu from dual;
select :aas_time ifdefaastime from dual;
select :user_io ifdefio from dual;
select :other ifdefother from dual;
select :runmax ifdefrunmax from dual;
var on_cpu varchar2(1000);
var aas_time varchar2(1000);
var user_io varchar2(1000);
var other varchar2(1000);
var runmax number;
var usermax number;
var refresh number;
--def refresh = 15;
declare
reset number;
procedure read_commandline is
begin
for c in (select * from (select level l, substr('&&1',instr('&&1',':',1,level)+1, decode(instr('&&1',':',1,level+1),0,length('&&1'),instr('&&1',':',1,level+1)-instr('&&1',':',1,level)-1)) conf
from dual connect by instr('&&1',':',1,level) > 0) where conf<>'aas') loop
if (lower(c.conf) like 'reset') then
reset:=1;
else
reset := 0;
case c.l
when 1 then :refresh:=to_number(c.conf);
when 2 then :usermax:=to_number(c.conf);
else null;
end case;
end if;
end loop;
end read_commandline;
begin
read_commandline;
--dbms_output.put_line(nvl(length('&&_OLD_ONCPU'),'0'));
--dbms_output.put_line('&&_OLD_ONCPU');
-- select count(*) into reset from dual where '&&1' like 'reset';
if reset = 0 then
if nvl(length('&&_OLD_ONCPU'),'0') != 0 then
:on_cpu := '&&_OLD_ONCPU' ;
:aas_time := '&&_OLD_AAS_TIME' ;
:user_io := '&&_OLD_USERIO';
:other := '&&_OLD_OTHER';
:runmax := '&&_OLD_RUNMAX';
end if;
else
:on_cpu := '';
:aas_time := '' ;
:user_io := '';
:other := '';
:runmax := '';
end if;
end;
/
set term on
set serveroutput on format wrapped
set linesize 150
set feedback off
set ver off
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas
@topaas