Skip to content

Commit 2cd73fb

Browse files
authored
feat: Oracle script enhancements and DMA_MANUAL_ID additions (#300)
* Change collect-data.sh to use named parameters instead of positional. Add column DMA_MANUAL_ID * Add hard coded file names to prevent empty files when no rows returned. * Fixed column name spelling * Update documentation. Add help text to collect_data.sh Change collection of non-cumulative stats. * Retain ability to run locally while connecting '/ as sysdba'. * Reset version prior to merge. * Version bump * Fix header on compressbytype
1 parent da21cb4 commit 2cd73fb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+294
-148
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 4.3.20
2+
current_version = 4.3.21
33
commit = False
44
tag = False
55

docs/user_guide/oracle/collection_scripts.md

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Execute grants_wrapper.sql. You will be prompted for the name of a database user
5151
(Note that input is case-sensitive and must match the username created above) to be granted
5252
privileges on the objects required for data collection.
5353
You will also be prompted whether or not to allow access to the AWR data.
54+
Access will be granted to Statspack tables if they are present.
5455

5556
```shell
5657
SQL> @grants_wrapper.sql
@@ -60,37 +61,69 @@ SQL> Please enter Y or N to allow or disallow use of the Tuning and Diagnostic P
6061

6162
The grant_wrapper script will grant privileges required and will output a list of what has been granted.
6263

63-
Launch the collection script:
64+
Launch the collection script: (Note that the parameter names have changed from earlier versions of the collector)
6465

65-
- Pass connect string as input to this script and either UseDiagnostics or NoDiagnostics to match the permissions granted. (see below for example)
6666
- NOTE: If this is an Oracle RAC and/or PDB environment you just need to run it once per database. No need to run in each PDB or in each Oracle RAC instance.
6767
- If you are licensed for the Oracle Tuning and Diagnostics packs, pass the parameter UseDiagnostics to use the AWR data.
6868
- If you are NOT licensed for the Oracle Tuning and Diagnostics packs, pass the parameter NoDiagnostics to exclude the AWR data. The script will attempt to use STATSPACK data if available.
6969

70+
- Parameters
71+
```
72+
Connection definition must one of:
73+
{
74+
--connectionStr Oracle EasyConnect string formatted as {user}/{password}@//{db host}:{listener port}/{service name}
75+
or
76+
--hostName Database server hostname
77+
--port Listener port
78+
--databaseService Database service name
79+
--collectionUserName Database username
80+
--collectionUserPass Database password
81+
}
82+
Performance statistics source
83+
--statsSrc Required. Must be one of AWR, STATSPACK, NONE
84+
```
85+
86+
7087
To use the licensed Oracle Tuning and Diagnostics pack data:
7188

7289
```shell
73-
./collect-data.sh {user}/{password}@//{db host/scan address}/{service name} UseDiagnostics
90+
./collect-data.sh --connectionStr {user}/{password}@//{db host}:{listener port}/{service name} --statsSrc AWR
91+
or
92+
./collect-data.sh --collectionUserName {user} --collectionUserPass {password} --hostName {db host} --port {listener port} --databaseService {service name} --statsSrc AWR
93+
94+
ex:
95+
96+
./collect-data.sh --connectionStr MyUser/MyPassword@//dbhost.company.com:1521/MyDbName.company.com --statsSrc AWR
97+
or
98+
./collect-data.sh --collectionUserName MyUser --collectionUserPass MyPassword --hostName dbhost.company.com --port 1521 --databaseService MyDbName.company.com --statsSrc AWR
7499
```
75100

76101
OR
77102
To avoid using the licensed Oracle Tuning and Diagnostics pack data:
78103

79104
```shell
80-
./collect-data.sh {user}/{password}@//{db host/scan address}/{service name} NoDiagnostics
105+
./collect-data.sh --connectionStr {user}/{password}@//{db hosti}:{listener port}/{service name} --statsSrc STATSPACK
106+
or
107+
./collect-data.sh --collectionUserName {user} --collectionUserPass {password} --hostName {db host} --port {listener port} --databaseService {service name} --statsSrc STATSPACK
108+
109+
ex:
110+
111+
./collect-data.sh --connectionStr MyUser/MyPassword@//dbhost.company.com:1521/MyDbName.company.com --statsSrc STATSPACK
112+
or
113+
./collect-data.sh --collectionUserName MyUser --collectionUserPass MyPassword --hostName dbhost.company.com --port 1521 --databaseService MyDbName.company.com --statsSrc STATSPACK
81114
```
82115

83116
Collections can be run as SYS if needed by setting ORACLE_SID and running on the database host:
84117

85118
```shell
86-
./collect-data.sh '/ as sysdba' UseDiagnostics
119+
./collect-data.sh '/ as sysdba' --statsSrc AWR
87120
```
88121

89122
OR
90123
To avoid using the licensed Oracle Tuning and Diagnostics pack data:
91124

92125
```shell
93-
./collect-data.sh '/ as sysdba' NoDiagnostics
126+
./collect-data.sh '/ as sysdba' --statsSrc STATSPACK
94127
```
95128

96129
## Upload Collections

scripts/collector/oracle/collect-data.sh

Lines changed: 113 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
### Setup directories needed for execution
1818
#############################################################################
19-
OpVersion="4.3.20"
19+
OpVersion="4.3.21"
2020
dbmajor=""
2121

2222
LOCALE=$(echo $LANG | cut -d '.' -f 1)
@@ -100,6 +100,7 @@ function executeOP {
100100
connectString="$1"
101101
OpVersion=$2
102102
DiagPack=$(echo $3 | tr [[:upper:]] [[:lower:]])
103+
collectionTag="${4}"
103104

104105
if ! [ -x "$(command -v ${SQLPLUS})" ]; then
105106
echo "Could not find ${SQLPLUS} command. Source in environment and try again"
@@ -110,7 +111,7 @@ fi
110111

111112
${SQLPLUS} -s /nolog << EOF
112113
connect ${connectString}
113-
@${SQL_DIR}/op_collect.sql ${OpVersion} ${SQL_DIR} ${DiagPack} ${V_TAG} ${SQLOUTPUT_DIR}
114+
@${SQL_DIR}/op_collect.sql ${OpVersion} ${SQL_DIR} ${DiagPack} ${V_TAG} ${SQLOUTPUT_DIR} "${collectionTag}"
114115
exit;
115116
EOF
116117

@@ -250,26 +251,121 @@ fi
250251

251252
}
252253

254+
255+
function printUsage()
256+
{
257+
echo " Usage:"
258+
echo " Parameters"
259+
echo ""
260+
echo " Connection definition must one of:"
261+
echo " {"
262+
echo " --connectionStr Oracle EasyConnect string formatted as {user}/{password}@//{db host}:{listener port}/{service name}"
263+
echo " or"
264+
echo " --hostName Database server host name"
265+
echo " --port Database Listener port"
266+
echo " --databaseService Database service name"
267+
echo " --collectionUserName Database user name"
268+
echo " --collectionUserPass Database password"
269+
echo " }"
270+
echo " Performance statistics source"
271+
echo " --statsSrc Required. Must be one of AWR, STATSPACK, NONE"
272+
echo
273+
echo
274+
echo " Example:"
275+
echo
276+
echo
277+
echo " ./collect-data.sh --connectionStr {user}/{password}@//{db host}:{listener port}/{service name} --statsSrc AWR"
278+
echo " or"
279+
echo " ./collect-data.sh --collectionUserName {user} --collectionUserPass {password} --hostName {db host} --port {listener port} --databaseService {service name} --statsSrc AWR"
280+
281+
}
253282
### Validate input
254-
#############################################################################
255283

256-
if [[ $# -ne 2 || ( "$2" != "UseDiagnostics" && "$2" != "NoDiagnostics" ) ]]
284+
hostName=""
285+
port=""
286+
databaseService=""
287+
collectionUserName=""
288+
collectionUserPass=""
289+
dbType=""
290+
statsSrc=""
291+
connStr=""
292+
collectionTag=""
293+
294+
if [[ $(($# & 1)) == 1 ]] ;
257295
then
258-
echo
259-
echo "You must indicate whether or not to use the Diagnostics Pack views."
260-
echo "If this database is licensed to use the Diagnostics pack:"
261-
echo " $0 $1 UseDiagnostics"
262-
echo " "
263-
echo "If this database is NOT licensed to use the Diagnostics pack:"
264-
echo " $0 $1 NoDiagnostics"
265-
echo " "
266-
exit 1
267-
fi
296+
echo "Invalid number of parameters "
297+
printUsage
298+
exit
299+
fi
300+
301+
while (( "$#" )); do
302+
if [[ "$1" == "--hostName" ]]; then hostName="${2}"
303+
elif [[ "$1" == "--port" ]]; then port="${2}"
304+
elif [[ "$1" == "--databaseService" ]]; then databaseService="${2}"
305+
elif [[ "$1" == "--collectionUserName" ]]; then collectionUserName="${2}"
306+
elif [[ "$1" == "--collectionUserPass" ]]; then collectionUserPass="${2}"
307+
elif [[ "$1" == "--dbType" ]]; then dbType=$(echo "${2}" | tr '[:upper:]' '[:lower:]')
308+
elif [[ "$1" == "--statsSrc" ]]; then statsSrc=$(echo "${2}" | tr '[:upper:]' '[:lower:]')
309+
elif [[ "$1" == "--connectionStr" ]]; then connStr="${2}"
310+
elif [[ "$1" == "--collectionTag" ]]; then collectionTag="${2}"
311+
else
312+
echo "Unknown parameter ${1}"
313+
printUsage
314+
exit
315+
fi
316+
shift 2
317+
done
318+
319+
320+
if [[ "${dbType}" != "oracle" ]] ; then
321+
dbType="oracle"
322+
fi
323+
324+
if [[ "${statsSrc}" = "awr" ]]; then
325+
DIAGPACKACCESS="UseDiagnostics"
326+
elif [[ "${stasSrc}" = "statspack" ]] ; then
327+
DIAGPACKACCESS="NoDiagnostics"
328+
else
329+
echo No performance data will be collected.
330+
DIAGPACKACCESS="nostatspack"
331+
fi
332+
333+
if [[ "${connStr}" == "" ]] ; then
334+
if [[ "${hostName}" != "" && "${port}" != "" && "${databaseService}" != "" && "${collectionUserName}" != "" && "${collectionUserPass}" != "" ]] ; then
335+
connStr="${collectionUserName}/${collectionUserPass}@//${hostName}:${port}/${databaseService}"
336+
echo Got Connection ${connStr}
337+
else
338+
echo "Connection information incomplete"
339+
printUsage
340+
exit
341+
fi
342+
fi
343+
344+
if [[ "${collectionTag}" != "" ]]; then
345+
collectionTag=$(echo "${collectionTag}" | iconv -t ascii//TRANSLIT | sed -E -e 's/[^[:alnum:]]+/-/g' -e 's/^-+|-+$//g' | tr '[:upper:]' '[:lower:]' | cut -c 1-100)
346+
else collectionTag='NA'
347+
fi
348+
349+
350+
#############################################################################
351+
#
352+
#if [[ $# -ne 2 || ( "$2" != "UseDiagnostics" && "$2" != "NoDiagnostics" ) ]]
353+
# then
354+
# echo
355+
# echo "You must indicate whether or not to use the Diagnostics Pack views."
356+
# echo "If this database is licensed to use the Diagnostics pack:"
357+
# echo " $0 $1 UseDiagnostics"
358+
# echo " "
359+
# echo "If this database is NOT licensed to use the Diagnostics pack:"
360+
# echo " $0 $1 NoDiagnostics"
361+
# echo " "
362+
# exit 1
363+
#fi
268364

269365
# MAIN
270366
#############################################################################
271367

272-
connectString="$1"
368+
connectString="${connStr}"
273369
sqlcmd_result=$(checkVersion "${connectString}" "${OpVersion}" | $GREP DMAFILETAG | cut -d '~' -f 2)
274370
if [[ "${sqlcmd_result}" = "" ]];
275371
then
@@ -279,7 +375,7 @@ fi
279375

280376
retval=$?
281377

282-
DIAGPACKACCESS="$2"
378+
# DIAGPACKACCESS="$2"
283379

284380
extractorVersion="$(getVersion)"
285381

@@ -309,7 +405,7 @@ if [ $retval -eq 0 ]; then
309405
fi
310406
fi
311407
V_TAG="$(echo ${sqlcmd_result} | cut -d '|' -f2).csv"; export V_TAG
312-
executeOP "${connectString}" ${OpVersion} ${DIAGPACKACCESS}
408+
executeOP "${connectString}" ${OpVersion} ${DIAGPACKACCESS} "${collectionTag}"
313409
retval=$?
314410
if [ $retval -ne 0 ]; then
315411
createErrorLog $(echo ${V_TAG} | sed 's/.csv//g')

scripts/collector/oracle/sql/extracts/9i_cpucoresusage.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ limitations under the License.
1515
*/
1616
-- This file intentionally left empty
1717
spool &outputdir/opdb__cpucoresusage__&v_tag
18-
prompt PKEY|DT|CPU_COUNT|CPU_CORE_COUNT|CPU_SOCKET_COUNT|DMA_SOURCE_ID
18+
prompt PKEY|DT|CPU_COUNT|CPU_CORE_COUNT|CPU_SOCKET_COUNT|DMA_SOURCE_ID|DMA_MANUAL_ID
1919
spool off

scripts/collector/oracle/sql/extracts/9i_dbfeatures.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ limitations under the License.
1515
*/
1616
-- This file intentionally left empty
1717
spool &outputdir/opdb__dbfeatures__&v_tag
18-
prompt PKEY|CON_ID|NAME|CURRE|DETECTED_USAGES|TOTAL_SAMPLES|FIRST_USAGE|LAST_USAGE|AUX_COUNT|DMA_SOURCE_ID
18+
prompt PKEY|CON_ID|NAME|CURRE|DETECTED_USAGES|TOTAL_SAMPLES|FIRST_USAGE|LAST_USAGE|AUX_COUNT|DMA_SOURCE_ID|DMA_MANUAL_ID
1919
spool off

scripts/collector/oracle/sql/extracts/9i_dbhwmarkstatistics.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ limitations under the License.
1515
*/
1616
-- This file intentionally left empty
1717
spool &outputdir/opdb__dbhwmarkstatistics__&v_tag
18-
prompt PKEY|DESCRIPTION|HIGHWATER|LAST_VALUE|CON_ID|DMA_SOURCE_ID
18+
prompt PKEY|DESCRIPTION|HIGHWATER|LAST_VALUE|CON_ID|DMA_SOURCE_ID|DMA_MANUAL_ID
1919
spool off

scripts/collector/oracle/sql/extracts/archlogs.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616
spool &outputdir/opdb__archlogs__&v_tag
17-
17+
prompt PKEY|LOG_START_DATE|HO|THREAD_NUM|DEST_ID|CNT|MBYTES|DMA_SOURCE_ID|DMA_MANUAL_ID
1818
SELECT '&&v_host'
1919
|| '_'
2020
|| '&&v_dbname'
@@ -26,7 +26,7 @@ SELECT '&&v_host'
2626
dest_id,
2727
count(1) AS CNT,
2828
round(sum(blocks * block_size)/1024/1024) as mbytes,
29-
'&v_dma_source_id' AS DMA_SOURCE_ID
29+
'&v_dma_source_id' AS DMA_SOURCE_ID, chr(39) || '&v_collectionTag' || chr(39) AS DMA_MANUAL_ID
3030
FROM gv$archived_log
3131
WHERE first_time >= trunc(sysdate) - '&&dtrange'
3232
GROUP BY trunc(first_time), thread#, to_char(first_time, 'HH24'), dest_id

scripts/collector/oracle/sql/extracts/awr/awrhistcmdtypes.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ limitations under the License.
1515
*/
1616

1717
spool &outputdir/opdb__awrhistcmdtypes__&v_tag
18-
18+
prompt PKEY|CON_ID|HH|COMMAND_TYPE|CNT|AVG_BUFFER_GETS|AVG_ELASPED_TIME|AVG_ROWS_PROCESSED|AVG_EXECUTIONS|AVG_CPU_TIME|AVG_IOWAIT|AVG_CLWAIT|AVG_APWAIT|AVG_CCWAIT|AVG_PLSEXEC_TIME|COMMAND_NAME|DMA_SOURCE_ID|DMA_MANUAL_ID
1919
WITH vcmdtype AS(
2020
SELECT '&&v_host'
2121
|| '_'
@@ -61,6 +61,6 @@ GROUP BY '&&v_host'
6161
SELECT pkey , con_id , hh24 , command_type , cnt , avg_buffer_gets , avg_elasped_time ,
6262
avg_rows_processed , avg_executions , avg_cpu_time , avg_iowait , avg_clwait ,
6363
avg_apwait , avg_ccwait , avg_plsexec_time, command_name,
64-
'&v_dma_source_id' AS DMA_SOURCE_ID
64+
'&v_dma_source_id' AS DMA_SOURCE_ID, chr(39) || '&v_collectionTag' || chr(39) AS DMA_MANUAL_ID
6565
FROM vcmdtype;
6666
spool off

scripts/collector/oracle/sql/extracts/awr/awrhistosstat.sql

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16-
16+
set echo on
1717
spool &outputdir/opdb__awrhistosstat__&v_tag
18-
18+
prompt PKEY|DBID|INSTANCE_NUMBER|HH|STAT_NAME|HH24_TOTAL_SECS|CUMULATIVE_VALUE|AVG_VALUE|MODE_VALUE|MEDIAN_VALUE|PERC50|PERC75|PERC90|PERC95|PERC100|MIN_VALUE|MAX_VALUE|SUM_VALUE|COUNT|DMA_SOURCE_ID|DMA_MANUAL_ID
1919
WITH v_osstat_all
2020
AS (SELECT os.dbid,
2121
os.instance_number,
@@ -51,14 +51,17 @@ WITH v_osstat_all
5151
TO_CHAR(os.begin_interval_time, 'hh24'), os.stat_name) AS
5252
"PERC100"
5353
FROM (SELECT snap.begin_interval_time, snap.end_interval_time, s.*,
54-
NVL(DECODE(GREATEST(value, NVL(LAG(value)
55-
OVER (
56-
PARTITION BY s.dbid, s.instance_number, s.stat_name
57-
ORDER BY s.snap_id), 0)), value, value - LAG(value)
58-
OVER (
59-
PARTITION BY s.dbid, s.instance_number, s.stat_name
60-
ORDER BY s.snap_id),
61-
0), 0) AS delta_value
54+
CASE WHEN s.stat_name IN ('IDLE_TIME' ,'BUSY_TIME' ,'USER_TIME' ,'SYS_TIME' ,'IOWAIT_TIME' ,'NICE_TIME' ,'RSRC_MGR_CPU_WAIT_TIME' ,'VM_IN_BYTES' ,'VM_OUT_BYTES')
55+
THEN
56+
NVL(DECODE(GREATEST(value, NVL(LAG(value)
57+
OVER (
58+
PARTITION BY s.dbid, s.instance_number, s.stat_name
59+
ORDER BY s.snap_id), 0)), value, value - LAG(value)
60+
OVER (
61+
PARTITION BY s.dbid, s.instance_number, s.stat_name
62+
ORDER BY s.snap_id),
63+
0), 0)
64+
ELSE s.value END AS delta_value
6265
FROM &v_tblprefix._hist_osstat s
6366
inner join &v_tblprefix._hist_snapshot snap
6467
ON s.snap_id = snap.snap_id
@@ -103,6 +106,6 @@ GROUP BY '&&v_host'
103106
SELECT pkey , dbid , instance_number , hh24 , stat_name , hh24_total_secs ,
104107
cumulative_value , avg_value , mode_value , median_value , PERC50 , PERC75 , PERC90 , PERC95 , PERC100 ,
105108
min_value , max_value , sum_value , count,
106-
'&v_dma_source_id' AS DMA_SOURCE_ID
109+
'&v_dma_source_id' AS DMA_SOURCE_ID, chr(39) || '&v_collectionTag' || chr(39) AS DMA_MANUAL_ID
107110
FROM vossummary;
108111
spool off

scripts/collector/oracle/sql/extracts/awr/awrhistsysmetrichist.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616
spool &outputdir/opdb__awrhistsysmetrichist__&v_tag
17-
17+
prompt PKEY|DBID|INSTANCE_NUMBER|HOUR|METRIC_NAME|METRIC_UNIT|AVG_VALUE|MODE_VALUE|MEDIAN_VALUE|MIN_VALUE|MAX_VALUE|SUM_VALUE|PERC50|PERC75|PERC90|PERC95|PERC100|DMA_SOURCE_ID|DMA_MANUAL_ID
1818
WITH vsysmetric AS (
1919
SELECT '&&v_host'
2020
|| '_'
@@ -66,6 +66,6 @@ ORDER BY hsm.dbid,
6666
SELECT pkey , dbid , instance_number , hour , metric_name ,
6767
metric_unit , avg_value , mode_value , median_value , min_value , max_value ,
6868
sum_value , PERC50 , PERC75 , PERC90 , PERC95 , PERC100,
69-
'&v_dma_source_id' AS DMA_SOURCE_ID
69+
'&v_dma_source_id' AS DMA_SOURCE_ID, chr(39) || '&v_collectionTag' || chr(39) AS DMA_MANUAL_ID
7070
FROM vsysmetric;
7171
spool off

0 commit comments

Comments
 (0)