Skip to content

Commit 63b8ee5

Browse files
committed
ashplot: top 8, nicer userhelp, script in bin
1 parent e0c3162 commit 63b8ee5

File tree

4 files changed

+73
-58
lines changed

4 files changed

+73
-58
lines changed

GENERATED.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
* of the directories in PATH. An appropriate Oracle
1212
* client environment with properly set LD_LIBRARY_PATH
1313
* is needed.
14+
*
15+
* To get help for either exeuctable, execute it with a
16+
* -h option. To show the rwl source, exeucte with a
17+
* --list-generated option.
1418
*
1519
* The full source code is available from
1620
* https://opensource.oracle.com/

bin/ashplot

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
# RWP*Load Simulator
4+
#
5+
# Copyright (c) 2021 Oracle Corporation
6+
# Licensed under the Universal Permissive License v 1.0
7+
# as shown at https://oss.oracle.com/licenses/upl/
8+
#
9+
# call rwloadsim -u ashplot.rwl
10+
11+
# bengsig 27-nov-2023 - Creation
12+
13+
rwloadsim --pretend-gen-banner='RWP*ASH Plot' -u ashplot.rwl "$@"

man/man2rwl/ashplot.2rwl

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
.TH ashplot "2rwl" "May 2022" "RWP*Load Simulator" "Utility Syntax"
22
.SH NAME
3-
ashplot.rwl \- Create a plot of ash data
3+
ashplot \- Create a plot of ash data
44
.SH SYNOPSIS
5-
\fBrwloadsim [options] -u -l u/p@c ashplot.rwl\fR
5+
\fBashplot [options] -l u/p@c ashplot.rwl\fR
66
.P
7-
\fBrwloadsim [options] -u -l u/p@c ashplot.rwl header text\fR
7+
\fBashplot [options] -l u/p@c ashplot.rwl title text\fR
88
.P
9-
The ashplot.rwl script is used to create a plot of ash data
9+
The ashplot command is used to create a plot of ash data
1010
in any of three possible formats:
1111
.TP 4
1212
1.
@@ -18,7 +18,7 @@ Create an image file in png format.
1818
3.
1919
Create an image file in svg format potentially with the svgmouse option.
2020
.P
21-
All output is generated using the gnuplot command which therefore must be installed.
21+
All output is generated using the gnuplot which therefore must be installed.
2222
.P
2323
The data used to generate the graphs is retrieved from either live data
2424
in gv$active_session_history or from the awr repository in dba_hist_active_sess_history.
@@ -29,25 +29,20 @@ option.
2929
If you do not provide one of the output options, no graph is created, but you
3030
will be shown a date interval (with minute resolution) for which data is available.
3131
If your goal is to graph data from the awr repository, you are suggested to first
32-
use awrreport.rwl to identify the databases, instances and snapshot
32+
use awrreport to identify the databases, instances and snapshot
3333
ranges available.
3434
This is particularly useful if you are working with an awr repository that
3535
contains awr imports from other databases.
3636
.P
3737
.SH OPTIONS
38-
\fB-u\fR
39-
.RS 4
40-
Compulsory option to find the ashplot.rwl script in the public directory.
41-
.RE
42-
.P
4338
.B -l u/p
4439
.br
4540
.B -l u/p@c
4641
.RS 4
4742
Compulsory option to provide the username, password, and potentially
4843
connect string for a database connection that provides access to
4944
the necessary gv$ and dba_hist views.
50-
If you omit /p, rwloadsim will prompt for the password.
45+
If you omit /p, ashplot will prompt for the password.
5146
.RE
5247
.P
5348
.B --dbid=<dbid>
@@ -133,7 +128,7 @@ This example shows how you can progressively narrow down a certain database and
133128
for which you create the ash plots.
134129
Start by listing all available databases and instances in some repository:
135130
.nf
136-
rwloadsim -ul system/{password}@tnsalias awrreport.rwl
131+
awrreport -l system/{password}@tnsalias
137132
.fi
138133
.P
139134
which may generate an output like:
@@ -152,7 +147,7 @@ Assume the last one is the interesting one,
152147
so first create a plot using X-Windows covering the whole available range:
153148
.P
154149
.nf
155-
rwloadsim --output-X --dbid=4001460110 -ul system/{password}@tnsalias ashplot.rwl
150+
ashplot --output-X --dbid=4001460110 -l system/{password}@tnsalias
156151
.fi
157152
.P
158153
which first will show the actual available range and then (potentially after some time)
@@ -164,12 +159,12 @@ Data available between 2022.03.21T00:47 and 2022.04.02T23:59
164159
.P
165160
You may then want to narrow down the actual time for which the plot it produced:
166161
.nf
167-
rwloadsim --output-X --fromtime=2022.04.01T12 --totime=2022.04.02T12 --dbid=4001460110 -ul system/{password}@tnsalias ashplot.rwl
162+
ashplot --output-X --fromtime=2022.04.01T12 --totime=2022.04.02T12 --dbid=4001460110 -l system/{password}@tnsalias
168163
.fi
169164
.P
170165
And finally, you may want to reduce it further, also create image files, and also include SYS sessions:
171166
.nf
172-
rwloadsim --svgmouse --output-image=/var/www/html/myash/myplot --include-sys --fromtime=2022.04.01T17:30 --totime=2022.04.01T20:30 --output-X --dbid=4001460110 -ul system/{password}@tnsalias ashplot.rwl
167+
ashplot --svgmouse --output-image=/var/www/html/myash/myplot --include-sys --fromtime=2022.04.01T17:30 --totime=2022.04.01T20:30 --output-X --dbid=4001460110 -l system/{password}@tnsalias
173168
.fi
174169
.P
175170
The image files will be put in the directory /var/www/html/myash,
@@ -179,7 +174,7 @@ You can see an actual sample image at https://github.com/oracle/rwloadsim/blob/m
179174
.P
180175
This final example shows how you can plot all available live data (i.e. from gv$active_session_history):
181176
.nf
182-
rwloadsim --include-sys --output-X -ul system/{password}@tnsalias ashplot.rwl
177+
ashplot --include-sys --output-X -l system/{password}@tnsalias
183178
.fi
184179
.SH BUGS
185180
If there are many ash samples, generating the data and subsequently using gnuplot takes a long time.

public/ashplot.rwl

Lines changed: 44 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# History:
1010
#
1111
# Modified Date Comments
12+
# bengsig 27-sep-2023 include top 8 (rather than 6)
1213
# bengsig 13-sep-2023 use ampersand replacement
1314
# bengsig 13-apr-2022 Created as rwl from shell script
1415
# bengsig 23-mar-2022 Add -n for node (instance) number
@@ -20,9 +21,11 @@
2021
$longoption:file-count=1
2122

2223
# If we didn't connect, don't do anything
23-
if oraerror is not null and oraerror then
24+
$if not defined(default database) $then
25+
writeline stderr, "Missing or incorrect -l option; use -h to get help";
2426
exit 1;
25-
end if;
27+
$endif
28+
2629

2730
# Check of gnuplot is available
2831
string gnuplotok;
@@ -32,52 +35,44 @@ if system("type gnuplot 2>/dev/null", gnuplotok) then
3235
end if;
3336

3437
integer maxsessions := 0;
35-
$useroption:maxsessions:"--maxsessions=<N> - Highest number of sessions to show in y-axis"
36-
3738
integer dbid;
38-
$useroption:dbid:"--dbid=<N> - query dba_hist_active_sess_history in stead of gv$"
39-
4039
integer instance;
41-
$useroption:instance:"--instance=<N> - only include sessions in this instance"
42-
4340
string mintime, fromtime;
44-
$useroption:fromtime:"--fromtime=YYYY.MM.DDTHH24:MI - first timestamp to include in graph"
45-
4641
string maxtime, totime;
47-
$useroption:totime:"--totime=YYYY.MM.DDTHH24:MI - last timestamp to include in graph"
48-
4942
string(1000) ashplot_tempdir;
50-
$useroption:ashplot-tempdir # not documented
51-
5243
integer ashplot_debug := 0;
53-
$userswitch:ashplot-debug # Not documented
54-
5544
integer output_X := 0;
56-
$userswitch:output-X:"--output-X - generate output as X11 image"
57-
5845
string(1000) output_png;
59-
$useroption:output-png:"--output-png=<file.svg> - create image file as PNG"
60-
6146
string(1000) output_svg;
62-
$useroption:output-svg:"--output-svg=<file.svg> - create image files as SVG"
63-
6447
integer svgmouse := 0;
65-
$userswitch:svgmouse:"--svgmouse - embed mouse javascript code in svg file"
66-
6748
integer boxwidth := 0;
68-
$useroption:boxwidth:"--boxwidth=N - set boxwidth"
69-
7049
string(1000) output_image;
71-
$useroption:output-image:"--output-image=<file> - create image files named file.svg and file.png"
72-
7350
integer include_sys := 0;
74-
$userswitch:include-sys:"--include-sys - Include sessions from SYS, default is to exclude SYS"
75-
7651
integer w_pixels := 640;
77-
$useroption:w-pixels:"--w-pixels - set the width in pixels"
78-
7952
integer h_pixels := 480;
80-
$useroption:h-pixels:"--h-pixels - set the height in pixels"
53+
$userhelp:"Create a plot of ash data as image file or using X-Windows"
54+
$userhelp:"-l usr/pwd@con - required option providing database credentials"
55+
$useroption:dbid:"--dbid=<N> - query dba_hist_active_sess_history in"
56+
$userhelp:" stead of gv$active_session_history"
57+
$useroption:instance:"--instance=<N> - only include sessions in this instance"
58+
$userswitch:include-sys:"--include-sys - Include sessions from SYS, default is"
59+
$userhelp:" to exclude SYS"
60+
$useroption:fromtime:"--fromtime=YYYY.MM.DDTHH24:MI - first timestamp to include in graph"
61+
$useroption:totime:"--totime=YYYY.MM.DDTHH24:MI - last timestamp to include in graph"
62+
$userswitch:output-X:"--output-X - generate output as X-Windows image"
63+
$useroption:output-png:"--output-png=<file.svg> - create image file as png"
64+
$useroption:output-svg:"--output-svg=<file.svg> - create image files as svg"
65+
$userswitch:svgmouse:"--svgmouse - embed svgmouse code in svg file"
66+
$useroption:output-image:"--output-image=<file> - create image files named file.svg"
67+
$userhelp:" and file.png"
68+
$useroption:maxsessions:"--maxsessions=<N> - Highest number of sessions to show"
69+
$userhelp:" on y-axis"
70+
$useroption:w-pixels:"--w-pixels=<N> - set the width in pixels"
71+
$useroption:h-pixels:"--h-pixels=<N> - set the height in pixels"
72+
$userhelp:"The following options are normally not used:"
73+
$useroption:boxwidth:"--boxwidth=N - set boxwidth"
74+
$useroption:ashplot-tempdir:"--ashplot-tempdir=<directory> - use directory for intermediate files"
75+
$userswitch:ashplot-debug:"--ashplot-debug - output some debug, save tempdir"
8176

8277
string(1000) title;
8378

@@ -160,7 +155,7 @@ sql execute
160155
end;
161156

162157
if mintime = "" or maxtime = "" then
163-
writeline stderr, "No data available between " fromtime " and " totime;
158+
writeline stderr, "No data available in " tablename;
164159
else
165160
writeline stderr, "Data available between " mintime " and " maxtime;
166161
end if;
@@ -223,12 +218,12 @@ string(4000) csvheader := "#YYYYMM.DD.HH24:MI:SS 'CPU' ";
223218
string event;
224219
integer ecount, d, lc := 0;
225220

226-
plotline := "plot '" tempdir "/ashdata.csv' using 1:($2+$3+$4+$5+$6+$7+$8+$9) "
221+
plotline := "plot '" tempdir "/ashdata.csv' using 1:($2+$3+$4+$5+$6+$7+$8+$9+$10+$11) "
227222
"with boxes lc rgb 'gray' title 'Other' \\\n";
228223

229-
# We want to show the top 6 events plus CPU and Other, but do
224+
# We want to show the top 8 events plus CPU and Other, but do
230225
# not know which events that are. Hence we rename them in
231-
# a decode to E1 until E6
226+
# a decode to E1 until E8
232227

233228
integer totalevs, maxevents := 0;
234229
double sinceprevious, maxprevious := 0;
@@ -245,6 +240,8 @@ csvquery :=
245240
"|| ' ' || nvl(e4,0)\n"
246241
"|| ' ' || nvl(e5,0)\n"
247242
"|| ' ' || nvl(e6,0)\n"
243+
"|| ' ' || nvl(e7,0)\n"
244+
"|| ' ' || nvl(e8,0)\n"
248245
"|| ' ' || nvl(other,0) csvline\n"
249246
", nvl(cpu,0)\n"
250247
" + nvl(e1,0)\n"
@@ -253,10 +250,12 @@ csvquery :=
253250
" + nvl(e4,0)\n"
254251
" + nvl(e5,0)\n"
255252
" + nvl(e6,0)\n"
253+
" + nvl(e7,0)\n"
254+
" + nvl(e8,0)\n"
256255
" + nvl(other,0) totalevs\n"
257256
", 86400 * (sample_time - first_value( sample_time) over (order by sample_time rows between 1 preceding and current row)) sinceprevious\n"
258257
"from ( \n"
259-
"select sample_time,CPU,E1,E2,E3,E4,E5,E6,OTHER\n"
258+
"select sample_time,CPU,E1,E2,E3,E4,E5,E6,E7,E8,OTHER\n"
260259
"from ( \n"
261260
"select sample_time\n"
262261
", event \n"
@@ -267,7 +266,7 @@ csvquery :=
267266
", decode(event ";
268267

269268
# The core of that query comes from picking the top
270-
# 6 events, that we get here with the order by
269+
# 8 events, that we get here with the order by
271270
# and rownum predicate
272271
for
273272
select event, ecount from (
@@ -277,7 +276,7 @@ for
277276
&constraints.
278277
group by event
279278
order by count(*) desc )
280-
where rownum <= 6
279+
where rownum <= 8
281280
/
282281
loop
283282
lc += 1;
@@ -287,7 +286,7 @@ loop
287286
sprintf || csvquery, "\n, '%s', 'E%d' ", event, lc;
288287
sprintf || plotline, ",'%s/ashdata.csv' using 1:($2", tempdir;
289288
# this sum deals with the bars put on top of each other
290-
for d := lc..6 loop
289+
for d := lc..8 loop
291290
sprintf || plotline, "+$%d", d+2; # :plt := :plt || '+\$'||to_char(d+2,'FM99');
292291
end loop;
293292
plotline ||= ") with boxes lc rgb ";
@@ -304,6 +303,8 @@ loop
304303
if lc=4 then plotline ||= "'blue'"; end if;
305304
if lc=5 then plotline ||= "'light-blue'"; end if;
306305
if lc=6 then plotline ||= "'salmon'"; end if;
306+
if lc=7 then plotline ||= "'gold'"; end if;
307+
if lc=8 then plotline ||= "'cyan'"; end if;
307308
end if;
308309
plotline ||= " title '" event "' \\\n";
309310
end loop;
@@ -327,6 +328,8 @@ csvquery ||= "\n, NULL, 'CPU', 'OTHER') event from\n" tablename "\n"
327328
", 'E4' as E4\n"
328329
", 'E5' as E5\n"
329330
", 'E6' as E6\n"
331+
", 'E7' as E7\n"
332+
", 'E8' as E8\n"
330333
", 'CPU' as CPU\n"
331334
", 'OTHER'as OTHER\n"
332335
")))\n"

0 commit comments

Comments
 (0)