Skip to content

Commit b830ec7

Browse files
committed
Add oltprunnumber
1 parent 6159924 commit b830ec7

File tree

4 files changed

+140
-7
lines changed

4 files changed

+140
-7
lines changed

bin/oltprunnumber

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
# Copyright (c) 2021 Oracle Corporation
3+
# Licensed under the Universal Permissive License v 1.0
4+
# as shown at https://oss.oracle.com/licenses/upl/
5+
6+
. oltp-setup-env
7+
8+
# This shell script will return an awr or results directory
9+
# and is useful to do e.g.
10+
# cd `oltpdirectory`
11+
# to change directory to the results directory where
12+
# you will find the rNNN and hence rNNN/NNNNNN subdirectories
13+
# which should show that the key isn't found.
14+
15+
# history
16+
#
17+
# 20-nov-2023 bengsig - Creation
18+
19+
help=no
20+
mykey="$RWLOLTP_NAME"
21+
22+
usage="Usage: $commandname [-h|-H|--help] [-k|--key key] [-a|--all] [--hostname hostname]"
23+
options='ahHk: -l key:,all,help,hostname:'
24+
25+
# Get directory names from parameters.rwl
26+
27+
eval `rwloadsim -q parameters2shell.rwl`
28+
29+
getopt -Q -o $options -- "$@" || exit 1
30+
set -- `getopt -u -n $commandname -o $options -- "$@"`
31+
32+
arguments=''
33+
34+
while test $1 != '--'
35+
do
36+
case $1 in
37+
--hostname) arguments="$arguments --myhostname=$2"; shift; shift;
38+
;;
39+
-k|--key) mykey=$2; shift; shift;
40+
;;
41+
-a|--all) arguments="$arguments --showall"; shift;
42+
;;
43+
--help|-h|-H) help=yes; shift;
44+
;;
45+
esac
46+
done
47+
48+
shift # removes --
49+
50+
if test $# -ge 1 -o x$help = xyes
51+
then
52+
echo $usage 1>&2
53+
exit 1
54+
fi
55+
56+
rwloadsim --mykey=$mykey $arguments latest.rwl

man/man2rwl/oltp.2rwl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,4 @@ Copyright \(co 2023 Oracle Corporation
159159
Licensed under the Universal Permissive License v 1.0
160160
as shown at https://oss.oracle.com/licenses/upl
161161
.SH "SEE ALSO"
162-
oltpcheckkey(2rwl), oltpcore(2rwl), oltpcreate(2rwl), oltpday(2rwl), oltpdrop(2rwl), oltpfilloe(2rwl), oltpforever(2rwl), oltpforever2(2rwl), oltpparams(2rwl), oltpplot(2rwl), oltprun(2rwl), oltpscale(2rwl), oltpscalereport(2rwl), oltpsetup(2rwl), oltpverify(2rwl), oltpplus(2rwl), rwloadsim(1rwl)
162+
oltpcheckkey(2rwl), oltpcore(2rwl), oltpcreate(2rwl), oltpday(2rwl), oltpdrop(2rwl), oltpfilloe(2rwl), oltpforever(2rwl), oltpforever2(2rwl), oltpparams(2rwl), oltpplot(2rwl), oltprun(2rwl), oltpscale(2rwl), oltpscalereport(2rwl), oltpsetup(2rwl), oltpverify(2rwl), oltpplus(2rwl), rwloadsim(1rwl), oltpdirectory(2rwl), oltprunnumber(2rwl)

man/man2rwl/oltprunnumber.2rwl

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
.TH oltpdirecotry "2rwl" "November 2023" "RWP*Load Simulator" "Workload Syntax"
2+
.SH NAME
3+
oltprunnumber \- Print a runnumber of list of runnumbers
4+
.SH SYNOPSIS
5+
\fBoltprunnumber [-h|-H|--help] [-k|--key key] [-a|--all] [--hostname hostname]\fR
6+
.P
7+
.SH OPTIONS
8+
.B -k|--key
9+
.RS 4
10+
By default, the latest runnumber with the key mentioned in the RWLOLTP_NAME environment
11+
is printed to stdout.
12+
A different key can be provided using this option.
13+
.RE
14+
.P
15+
.B -a|--all
16+
.RS 4
17+
Rather than printing the latest, print all runnumbers sorted by increasing run dates, each on a separate line.
18+
.RE
19+
.P
20+
.B --hostname hostname
21+
.RS 4
22+
Rather than the current hostname, provide a different one.
23+
Either the actul or the one provided will be looked up as the HOSTNAME column
24+
of the RWLRUN table.
25+
.RE
26+
.P
27+
.B -h|-H|--help
28+
.RS 4
29+
Only output a short help.
30+
.RE
31+
.P
32+
.SH USAGE
33+
The
34+
.B oltprunnumber
35+
command is primarily used if you want to do some extra processing of data from some runnumber.
36+
In such a case, you can use the $(oltprunnumber) syntax in your shell to get the latest runnumber.
37+
If used after running oltpscale, you may want to do some extra processing of data from all
38+
runs in that oltpscalerun.
39+
In such a case, you can use something like
40+
.P
41+
.nf
42+
for rno in $(oltprunnumber -a -k yourscalekey)
43+
do
44+
# do something
45+
done
46+
.fi
47+
.P
48+
When the \fb-a\fR option is not used, and if no rownumber matching the key and hostname is found, a single 0 will still be output,
49+
which may be useful to allow your shell script to continue.
50+
Additionally, an error is printed to stderr.
51+
.SH COPYRIGHT
52+
Copyright \(co 2023 Oracle Corporation
53+
.br
54+
Licensed under the Universal Permissive License v 1.0
55+
as shown at https://oss.oracle.com/licenses/upl
56+
.SH "SEE ALSO"
57+
oltpparams(2rwl), oltpdirectory(2rwl)

oltp/latest.rwl

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Licensed under the Universal Permissive License v 1.0
33
# as shown at https://oss.oracle.com/licenses/upl/
44

5-
# Return the latest runnumber for some host/key
5+
# Return the latest or all runnumber for some host/key
66
#
77

88
$include:"parameters.rwl"
@@ -12,26 +12,46 @@ $longoption:quiet
1212
string(100) mykey := $RWLOLTP_NAME;
1313
$useroption:mykey
1414

15+
string(1000) myhostname := hostname;
16+
$useroption:myhostname
17+
18+
integer showall:=0;
19+
$userswitch:showall
20+
21+
string orderby:="desc";
22+
string onlyone:="where rownum=1";
23+
24+
if showall then
25+
orderby:="asc";
26+
onlyone:=" ";
27+
end if;
28+
29+
1530
integer rno;
1631

32+
$ampersand:on
1733
execute at rwloadsim
1834
for
1935
select runnumber rno from
2036
(
2137
select runnumber
2238
from rwlrun
2339
where key=:mykey
24-
and hostname=:hostname
25-
order by rdate desc
40+
and hostname=:myhostname
41+
order by rdate &orderby.
2642
)
27-
where rownum=1
43+
&onlyone.
2844
/
2945
loop
3046
printline rno;
3147
end loop;
3248
if rno is null then
33-
printline 0;
34-
fprintf stderr,"No run found for key=%s, hostname=%s\n", mykey, hostname;
49+
if showall then
50+
fprintf stderr,"No runs found for key=%s, hostname=%s\n", mykey, myhostname;
51+
else
52+
printline 0;
53+
fprintf stderr,"No run found for key=%s, hostname=%s\n", mykey, myhostname;
54+
end if;
3555
exit 1;
3656
end if;
3757
end;

0 commit comments

Comments
 (0)