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
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
2831string gnuplotok;
@@ -32,52 +35,44 @@ if system("type gnuplot 2>/dev/null", gnuplotok) then
3235end if;
3336
3437integer maxsessions := 0;
35- $useroption:maxsessions:"--maxsessions=<N> - Highest number of sessions to show in y-axis"
36-
3738integer dbid;
38- $useroption:dbid:"--dbid=<N> - query dba_hist_active_sess_history in stead of gv$"
39-
4039integer instance;
41- $useroption:instance:"--instance=<N> - only include sessions in this instance"
42-
4340string mintime, fromtime;
44- $useroption:fromtime:"--fromtime=YYYY.MM.DDTHH24:MI - first timestamp to include in graph"
45-
4641string maxtime, totime;
47- $useroption:totime:"--totime=YYYY.MM.DDTHH24:MI - last timestamp to include in graph"
48-
4942string(1000) ashplot_tempdir;
50- $useroption:ashplot-tempdir # not documented
51-
5243integer ashplot_debug := 0;
53- $userswitch:ashplot-debug # Not documented
54-
5544integer output_X := 0;
56- $userswitch:output-X:"--output-X - generate output as X11 image"
57-
5845string(1000) output_png;
59- $useroption:output-png:"--output-png=<file.svg> - create image file as PNG"
60-
6146string(1000) output_svg;
62- $useroption:output-svg:"--output-svg=<file.svg> - create image files as SVG"
63-
6447integer svgmouse := 0;
65- $userswitch:svgmouse:"--svgmouse - embed mouse javascript code in svg file"
66-
6748integer boxwidth := 0;
68- $useroption:boxwidth:"--boxwidth=N - set boxwidth"
69-
7049string(1000) output_image;
71- $useroption:output-image:"--output-image=<file> - create image files named file.svg and file.png"
72-
7350integer include_sys := 0;
74- $userswitch:include-sys:"--include-sys - Include sessions from SYS, default is to exclude SYS"
75-
7651integer w_pixels := 640;
77- $useroption:w-pixels:"--w-pixels - set the width in pixels"
78-
7952integer 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
8277string(1000) title;
8378
@@ -160,7 +155,7 @@ sql execute
160155end;
161156
162157if mintime = "" or maxtime = "" then
163- writeline stderr, "No data available between " fromtime " and " totime ;
158+ writeline stderr, "No data available in " tablename ;
164159else
165160 writeline stderr, "Data available between " mintime " and " maxtime;
166161end if;
@@ -223,12 +218,12 @@ string(4000) csvheader := "#YYYYMM.DD.HH24:MI:SS 'CPU' ";
223218string event;
224219integer 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
233228integer totalevs, maxevents := 0;
234229double 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
272271for
273272 select event, ecount from (
277276 &constraints.
278277 group by event
279278 order by count(*) desc )
280- where rownum <= 6
279+ where rownum <= 8
281280 /
282281loop
283282 lc += 1;
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 ";
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";
309310end 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