-
Notifications
You must be signed in to change notification settings - Fork 8
/
check_diff_db_sec
executable file
·633 lines (589 loc) · 20.8 KB
/
check_diff_db_sec
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
#! /usr/bin/env bash
###############################################################################
# Monitor DB2 with Nagios
# Copyright 2013,2014,2015 Andres Gomez Casanova
# https://github.com/angoca/monitor-db2-with-nagios
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###############################################################################
# Checks modifications in the database security. This includes all tables with
# AUTH name.
#
# This scripts uses git. If using the default directory, then each time the sever
# is restarted the git history is lost.
#
# Based on this blog written by Ian Bjorhovde:
# http://www.idug.org/p/bl/et/blogaid=571
#
# # 'check_database_size' command definition
# define command {
# command_name check_diff_db_sec
# command_line $USER1$/check_by_ssh -H $HOSTADDRESS$ -l nagios -t 20 -C "scripts/check_diff_db_sec -i '$ARG1$' -d '$ARG2$'"
# }
# define service{
# host_name db2sever
# service_description Database security
# check_command check_diff_db_sec!/home/db2inst1!sample
# use generic-service
# }
#
# When using NRPE:
#
# In the database server:
#
# command[check_diff_db_sec]=/home/nagios/scripts/check_diff_db_sec -i /home/db2inst1 -d sample
#
# Then modify the path according to your script location, instance home dir,
# database, refresh rate and thresholds.
#
# In the Nagios server:
#
# define service{
# host_name db2server
# service_description Database security
# check_command check_nrpe_1arg!check_diff_db_sec
# use generic-service
# }
#
# Parameters:
# -d | --database : Database name.
# -D | --directory : Directory to create the history (Default is /tmp)
# -h | --help : Show the help of this script.
# -i | --instance : Home directory of the instance. Usually it is
# /home/db2inst1.
# -K | --mk : Change the output for Check_MK.
# -T | --trace : Trace mode. Writes output in /tmp.
# -v | --verbose : Execute the program in verbose mode.
# -V | --version : Show the current version of this script.
#
# In AIX, the long name options are not supported.
#
# The exit codes are the standard for Nagios.
#
# 0 The plugin was able to check the service and it appeared to be functioning
# properly.
# 1 The plugin was able to check the service, but it appeared to be above some
# "warning" threshold or did not appear to be working properly.
# 2 The plugin detected that either the service was not running or it was above
# some "critical" threshold.
# 3 Invalid command line arguments were supplied to the plugin or low-level
# failures internal to the plugin (such as unable to fork, or open a tcp
# socket) that prevent it from performing the specified operation.
# Higher-level errors (such as name resolution errors, socket timeouts, etc)
# are outside of the control of plugins and should generally NOT be reported
# as UNKNOWN states.
#
# Author: Andres Gomez Casanova
# Version: v1.0 2016-12-19
# Flag for debugging.
#set -xv
# Locale to print messages in English. Prevent language problems.
export LANG=en_US
# Version of this script.
function print_revision {
echo Andres Gomez Casanova - AngocA
echo v1.0 2016-12-19
}
# Function to show the help
function print_usage {
/bin/cat <<__EOT
Usage: ${1} { -i instanceHomeDirectory -d databaseName [-K][-D directory] | -h | -V }
[-T][-v]
__EOT
}
function print_help {
print_revision
print_usage ${1}
# Max 80 chars width.
/bin/cat <<__EOT
-------------------------------------------------------------------------------
Checks changes in the database security.
-d | --database STRING
Database name.
-D | --directory STRING
Directory where the history is created. By default is /tmp
-h | --help
Shows the current documentation.
-i | --instance STRING
Instance home directory. It is usually /home/db2inst1.
-K | --mk
Changes the output to be compatible with Check_MK.
-T | --trace
Trace mode: writes date and output in /tmp.
-v | --verbose
Executes the script in verbose mode (multiple times).
-V | --version
Shows the current version of this script.
In AIX, the long name options are not supported.
__EOT
}
# Variable to control the flow execution. Prevent Spaghetti code.
CONTINUE=true
# Nagios return codes
OK=0
WARNING=1
CRITICAL=2
UNKNOWN=3
# This is the returned code.
RETURN=${UNKNOWN}
# Nagios Output
# Text output 80 chars | Optional Perf Data Line 1
# Long text Line 1
# Long text Line 2 | Optional Perf Data Line 2
# Optional Perf Data Line 3
OUTPUT=
PERFORMANCE=
LONG_OUTPUT=
LONG_PERFORMANCE=
PERF_MK="-"
APPL_NAME=$(basename ${0})
echo "$(date +"%Y-%m-%d-%H.%M.%S") $$ Started ${APPL_NAME} $@" >> /tmp/${APPL_NAME}.log
# Checks the lock file does not exist.
# The lock file is the way the command was called with its parameters
# without spaces.
COPY_ARGS=("${@}")
LOCK_FILE=
for VALUE in "${COPY_ARGS[@]}" ; do
LOCK_FILE="${LOCK_FILE}${VALUE}"
done
LOCK_FILE=${LOCK_FILE//\//}
LOCK_FILE=${LOCK_FILE//\\/}
LOCK_FILE=${LOCK_FILE//\:/}
LOCK_FILE=${LOCK_FILE//\*/}
LOCK_FILE=${LOCK_FILE//\|/}
LOCK_FILE="/tmp/${APPL_NAME}${LOCK_FILE}.lock"
if [[ ! -r ${LOCK_FILE} ]] ; then
echo $$ > ${LOCK_FILE}
LOCKED=true
else
# If it exist, then check if the process is running.
EXIST=$(ps -ef | grep $(cat ${LOCK_FILE}) | grep ${APPL_NAME})
# If process is not running, delete it.
if [[ ${EXIST} == "" ]] ; then
rm ${LOCK_FILE}
if [[ ! -r ${LOCK_FILE} ]] ; then
echo $$ > ${LOCK_FILE}
LOCKED=true
else
OUTPUT="The lock file cannot be replaced: ${LOCK_FILE}"
CONTINUE=false
RETURN=${UNKNOWN}
fi
else
OUTPUT="An instance of the script with the same parameters is already running."
CONTINUE=false
RETURN=${UNKNOWN}
fi
fi
if [[ ${#} -eq 0 ]] ; then
print_usage ${APPL_NAME}
RETURN=${UNKNOWN}
CONTINUE=false
fi
# Checks the operating system. geopt works different in AIX than in Linux.
OS=$(uname)
if [[ "${OS:0:5}" == "Linux" ]] ; then
# The following requires GNU getopt. See the following discussion.
# http://stackoverflow.com/questions/402377
TEMP=$(getopt -o c:d:D:hi:KTvVw: --long critical:,database:,directory:,help,instance:,mk,trace,verbose,version,warning: \
-n ${APPL_NAME} -- "${@}")
elif [[ "${OS:0:3}" == "AIX" ]] ; then
set -- $(getopt c:d:D:hi:KTvVw: ${*})
elif [[ "${OS:0:6}" == "Darwin" || "${OS:0:5}" == "SunOS" || "${OS:0:5}" == "HP-UX" ]] ; then
echo "This plugin is not yet supported in your platform."
echo "Please create a ticket in GitHub if you want to enable your current platform."
echo "https://github.com/angoca/monitor-db2-with-nagios/issues"
RETURN=${UNKNOWN}
CONTINUE=false
elif [[ "${OS:0:6}" == "CYGWIN" ]] ; then
echo "This plugin is not supported in Cygwin"
RETURN=${UNKNOWN}
CONTINUE=false
else
echo "The platform is unknown: ${OS}"
echo "Please create a ticket in GitHub: https://github.com/angoca/monitor-db2-with-nagios/issues"
RETURN=${UNKNOWN}
CONTINUE=false
fi
if [[ ${?} -ne 0 ]] ; then
print_usage ${APPL_NAME}
RETURN=${UNKNOWN}
CONTINUE=false
fi
if [[ ${CONTINUE} == true ]] ; then
if [[ "${OS}" == "Linux" ]] ; then
# Note the quotes around ${TEMP}: they are essential!
eval set -- "${TEMP}"
fi
HELP=false
VERSION=false
CHECK_MK=false
# Verbosity level
VERBOSE=0
# Trace activated
TRACE=false
LOG=/tmp/${APPL_NAME}.log
INSTANCE_HOME=
DATABASE_NAME=
HISTORY_DIRECTORY=/tmp
WARNING_THRES=1
CRITICAL_THRES=2
if [[ "${OS:0:5}" == "Linux" ]] ; then
while true; do
case "${1}" in
-c | --critical ) CRITICAL_THRES=$(echo ${2} | cut -d' ' -f1) ; shift 2 ;;
-d | --database ) DATABASE_NAME=$(echo ${2} | cut -d' ' -f1) ; shift 2 ;;
-D | --directory ) HISTORY_DIRECTORY=$(echo ${2} | cut -d' ' -f1) ; shift 2 ;;
-h | --help ) HELP=true ; shift ;;
-i | --instance ) INSTANCE_HOME=$(echo ${2} | cut -d' ' -f1) ; shift 2 ;;
-K | --mk ) CHECK_MK=true ; shift ;;
-T | --trace ) TRACE=true ; shift ;;
-v | --verbose ) VERBOSE=$(( ${VERBOSE} + 1 )) ; shift ;;
-V | --version ) VERSION=true ; shift ;;
-w | --warning ) WARNING_THRES=$(echo ${2} | cut -d' ' -f1) ; shift 2 ;;
-- ) shift ; break ;;
* ) break ;;
esac
done
elif [[ "${OS:0:3}" = "AIX" ]] ; then
while [[ $1 != -- ]] ; do
case "${1}" in
-c) CRITICAL_THRES=$(echo ${2} | cut -d' ' -f1) ; shift 2 ;;
-d) DATABASE_NAME=$(echo ${2} | cut -d' ' -f1) ; shift 2 ;;
-D) HISTORY_DIRECTORY=$(echo ${2} | cut -d' ' -f1) ; shift 2 ;;
-h) HELP=true ; shift ;;
-i) INSTANCE_HOME=$(echo ${2} | cut -d' ' -f1) ; shift 2 ;;
-K) CHECK_MK=true ; shift ;;
-T) TRACE=true ; shift ;;
-v) VERBOSE=$(( ${VERBOSE} + 1 )) ; shift ;;
-V) VERSION=true ; shift ;;
-w) WARNING_THRES=$(echo ${2} | cut -d' ' -f1) ; shift 2 ;;
* ) break ;;
esac
done
fi
fi
if [[ ${TRACE} == true ]] ; then
echo ">>>>>" >> ${LOG}
date >> ${LOG}
echo "Instance at ${INSTANCE_HOME}" >> ${LOG}
echo "PID ${$}" >> ${LOG}
fi
ECHO="help:${HELP}, version:${VERSION}, verbose:${VERBOSE}"
ECHO="${ECHO}, directory:${INSTANCE_HOME}, database:${DATABASE_NAME}"
ECHO="${ECHO}, warning:${WARNING_THRES}, critical:${CRITICAL_THRES}"
ECHO="${ECHO}, check_mk:${CHECK_MK}"
if [[ ${VERBOSE} -ge 2 ]] ; then
echo ${ECHO}
fi
if [[ ${TRACE} == true ]] ; then
echo "PARAMS:${ECHO}" >> ${LOG}
fi
if [[ ${CONTINUE} == true && ${HELP} == true ]] ; then
print_help ${APPL_NAME}
RETURN=${UNKNOWN}
CONTINUE=false
fi
if [[ ${CONTINUE} == true && ${VERSION} == true ]] ; then
print_revision ${APPL_NAME}
RETURN=${UNKNOWN}
CONTINUE=false
fi
if [[ ${CONTINUE} == true && ${INSTANCE_HOME} == "" ]] ; then
print_usage ${APPL_NAME}
RETURN=${UNKNOWN}
CONTINUE=false
fi
if [[ ${CONTINUE} == true && ${DATABASE_NAME} == "" ]] ; then
print_usage ${APPL_NAME}
RETURN=${UNKNOWN}
CONTINUE=false
fi
if [[ ${CONTINUE} == true
&& ( ${WARNING_THRES} == "" || ${CRITICAL_THRES} == ""
|| ! ${WARNING_THRES} =~ ^[0-9]+$ || ! ${CRITICAL_THRES} =~ ^[0-9]+$
|| ${WARNING_THRES} -le 0 || ${CRITICAL_THRES} -le 0
|| ${WARNING_THRES} -ge ${CRITICAL_THRES} ) ]] ; then
print_usage ${APPL_NAME}
echo "Warning threshold should be less than critical threshold."
echo "Threshold should be greater than 0."
RETURN=${UNKNOWN}
CONTINUE=false
fi
if [[ ${CONTINUE} == true ]] ; then
if [[ -d ${INSTANCE_HOME} && -e ${INSTANCE_HOME}/sqllib/db2profile ]] ; then
# Load the DB2 profile.
. ${INSTANCE_HOME}/sqllib/db2profile
INSTANCE_NAME=$(db2 get instance | awk '/instance/ {print $7}')
else
OUTPUT="Instance directory is invalid."
RETURN=${UNKNOWN}
CONTINUE=false
fi
fi
if [[ ${CONTINUE} == true ]] ; then
COMMAND_DATABASE="db2 list db directory"
if [[ ${VERBOSE} -ge 2 ]] ; then
echo "COMMAND: ${COMMAND_DATABASE}"
fi
DATABASE=$(${COMMAND_DATABASE})
if [[ ${TRACE} == true ]] ; then
echo "RESULT:'${DATABASE}'" >> ${LOG}
fi
DATABASE=$(printf '%s\n' "${DATABASE}" | awk '/Database alias/ {print $4}' | grep -iw ${DATABASE_NAME})
if [[ ${VERBOSE} -ge 3 ]] ; then
echo "RESULT:'${DATABASE}'"
fi
if [[ ${DATABASE} == "" ]] ; then
OUTPUT="The database ${DATABASE_NAME} is not catalogued."
RETURN=${UNKNOWN}
CONTINUE=false
fi
fi
if [[ ${CONTINUE} == true ]] ; then
# Defines the directory and files that have the configuration.
DIR=${HISTORY_DIRECTORY}/${APPL_NAME}/${INSTANCE_HOME//\//}_${DATABASE_NAME}
FILE1=${DIR}/columns.log
FILE2=${DIR}/db.log
FILE3=${DIR}/index.log
FILE4=${DIR}/module.log
FILE5=${DIR}/package.log
FILE6=${DIR}/role.log
FILE7=${DIR}/routine.log
FILE8=${DIR}/schema.log
FILE9=${DIR}/sequence.log
FILE10=${DIR}/table.log
FILE11=${DIR}/tablespace.log
FILE12=${DIR}/variable.log
FILE13=${DIR}/workload.log
FILE14=${DIR}/xsrobject.log
# Creates directory
if [[ ! -d ${DIR} ]] ; then
if [[ ${VERBOSE} -ge 1 ]] ; then
echo "Directory ${DIR} does not exist"
fi
mkdir -p ${DIR}
cd ${DIR}
git init > /dev/null
FIRST_EXEC=true
else
if [[ ${VERBOSE} -ge 1 ]] ; then
echo "Directory does exist: ${DIR}"
fi
cd ${DIR}
fi
db2 connect to ${DATABASE_NAME} > /dev/null
if [[ ${?} -ne 0 ]] ; then
OUTPUT="Problem while connecting to the database"
RETURN=${UNKNOWN}
CONTINUE=false
fi
fi
if [[ ${CONTINUE} == true ]] ; then
# Redirects the configuration to the files
db2 "SELECT * FROM SYSCAT.COLAUTH" > ${FILE1}
db2 "SELECT * FROM SYSCAT.DBAUTH" > ${FILE2}
db2 "SELECT * FROM SYSCAT.INDEXAUTH" > ${FILE3}
db2 "SELECT * FROM SYSCAT.MODULEAUTH" > ${FILE4}
db2 "SELECT * FROM SYSCAT.PACKAGEAUTH" > ${FILE5}
db2 "SELECT * FROM SYSCAT.ROLEAUTH" > ${FILE6}
db2 "SELECT * FROM SYSCAT.ROUTINEAUTH" > ${FILE7}
db2 "SELECT * FROM SYSCAT.SCHEMAAUTH" > ${FILE8}
db2 "SELECT * FROM SYSCAT.SEQUENCEAUTH" > ${FILE9}
db2 "SELECT * FROM SYSCAT.TABAUTH" > ${FILE10}
db2 "SELECT * FROM SYSCAT.TBSPACEAUTH" > ${FILE11}
db2 "SELECT * FROM SYSCAT.VARIABLEAUTH" > ${FILE12}
db2 "SELECT * FROM SYSCAT.WORKLOADAUTH" > ${FILE13}
db2 "SELECT * FROM SYSCAT.XSROBJECTAUTH" > ${FILE14}
db2 connect > /dev/null
if [[ ${?} -ne 0 ]] ; then
OUTPUT="${OUTPUT}Problem with database connection"
RETURN=${UNKNOWN}
CONTINUE=false
fi
fi
if [[ ${CONTINUE} == true ]] ; then
if [[ -n ${FIRST_EXEC} ]] ; then
if [[ ${VERBOSE} -ge 1 ]] ; then
echo "Adding files"
fi
git add ${FILE1} ${FILE2} ${FILE3} ${FILE4} ${FILE5} ${FILE6} ${FILE7} ${FILE8} ${FILE9} ${FILE10} ${FILE11} ${FILE12} ${FILE13} ${FILE14}> /dev/null
git config user.email "${USER}@${HOSTNAME}" > /dev/null
git config user.name "Nagios User - ${USERNAME}" > /dev/null
git commit ${FILE1} ${FILE2} ${FILE3} ${FILE4} ${FILE5} ${FILE6} ${FILE7} ${FILE8} ${FILE9} ${FILE10} ${FILE11} ${FILE12} ${FILE13} ${FILE14} -m "Initial commit" > /dev/null
OUTPUT="First execution, nothing to compare"
PERFORMANCE="'Changes'=0"
RETURN=${OK}
else
if [[ ${VERBOSE} -ge 1 ]] ; then
echo "Looking for differences"
fi
# Gets and sets changes in Git
DIFF_FILE1=$(git diff ${FILE1})
DIFF_FILE2=$(git diff ${FILE2})
DIFF_FILE3=$(git diff ${FILE3})
DIFF_FILE4=$(git diff ${FILE4})
DIFF_FILE5=$(git diff ${FILE5})
DIFF_FILE6=$(git diff ${FILE6})
DIFF_FILE7=$(git diff ${FILE7})
DIFF_FILE8=$(git diff ${FILE8})
DIFF_FILE9=$(git diff ${FILE9})
DIFF_FILE10=$(git diff ${FILE10})
DIFF_FILE11=$(git diff ${FILE11})
DIFF_FILE12=$(git diff ${FILE12})
DIFF_FILE13=$(git diff ${FILE13})
DIFF_FILE14=$(git diff ${FILE14})
git commit ${FILE1} -m "Changes in columns $(date +'%Y-%m-%d-%H.%M.%S')" >/dev/null
git commit ${FILE2} -m "Changes in database $(date +'%Y-%m-%d-%H.%M.%S')" > /dev/null
git commit ${FILE3} -m "Changes in index $(date +'%Y-%m-%d-%H.%M.%S')" > /dev/null
git commit ${FILE4} -m "Changes in module $(date +'%Y-%m-%d-%H.%M.%S')" >/dev/null
git commit ${FILE5} -m "Changes in package $(date +'%Y-%m-%d-%H.%M.%S')" >/dev/null
git commit ${FILE6} -m "Changes in role $(date +'%Y-%m-%d-%H.%M.%S')" >/dev/null
git commit ${FILE7} -m "Changes in routine $(date +'%Y-%m-%d-%H.%M.%S')" >/dev/null
git commit ${FILE8} -m "Changes in schema $(date +'%Y-%m-%d-%H.%M.%S')" >/dev/null
git commit ${FILE9} -m "Changes in sequence $(date +'%Y-%m-%d-%H.%M.%S')" >/dev/null
git commit ${FILE10} -m "Changes in table $(date +'%Y-%m-%d-%H.%M.%S')" >/dev/null
git commit ${FILE11} -m "Changes in tablespace $(date +'%Y-%m-%d-%H.%M.%S')" >/dev/null
git commit ${FILE12} -m "Changes in variable $(date +'%Y-%m-%d-%H.%M.%S')" >/dev/null
git commit ${FILE13} -m "Changes in workload $(date +'%Y-%m-%d-%H.%M.%S')" >/dev/null
git commit ${FILE14} -m "Changes in xsrobject $(date +'%Y-%m-%d-%H.%M.%S')" >/dev/null
if [[ "${DIFF_FILE1}" == "" && "${DIFF_FILE2}" == ""
&& "${DIFF_FILE3}" == "" && "${DIFF_FILE4}" == ""
&& "${DIFF_FILE5}" == "" && "${DIFF_FILE6}" == ""
&& "${DIFF_FILE7}" == "" && "${DIFF_FILE8}" == ""
&& "${DIFF_FILE9}" == "" && "${DIFF_FILE10}" == ""
&& "${DIFF_FILE11}" == "" && "${DIFF_FILE12}" == ""
&& "${DIFF_FILE13}" == "" && "${DIFF_FILE14}" == "" ]] ; then
OUTPUT="No changes in the configuration"
PERFORMANCE="'Changes'=1"
RETURN=${OK}
else
if [[ ${VERBOSE} -ge 1 ]] ; then
echo "There were changes in the configuration"
fi
if [[ ${VERBOSE} -ge 2 ]] ; then
echo -E ${DIFF_FILE1}
echo -E ${DIFF_FILE2}
echo -E ${DIFF_FILE3}
echo -E ${DIFF_FILE4}
echo -E ${DIFF_FILE5}
echo -E ${DIFF_FILE6}
echo -E ${DIFF_FILE7}
echo -E ${DIFF_FILE8}
echo -E ${DIFF_FILE9}
echo -E ${DIFF_FILE10}
echo -E ${DIFF_FILE11}
echo -E ${DIFF_FILE12}
echo -E ${DIFF_FILE13}
echo -E ${DIFF_FILE14}
fi
PERFORMANCE_VALUE=1
if [[ "${DIFF_FILE1}" != "" ]] ; then
OUTPUT="${OUTPUT}Changes in column - "
PERFORMANCE_VALUE="$((${PERFORMANCE_VALUE} + 1))"
RETURN=${WARNING}
fi
if [[ "${DIFF_FILE2}" != "" ]] ; then
OUTPUT="${OUTPUT}Changes in db - "
PERFORMANCE_VALUE="$((${PERFORMANCE_VALUE} + 1))"
RETURN=${WARNING}
fi
if [[ "${DIFF_FILE3}" != "" ]] ; then
OUTPUT="${OUTPUT}Changes in index - "
PERFORMANCE_VALUE="$((${PERFORMANCE_VALUE} + 1))"
RETURN=${WARNING}
fi
if [[ "${DIFF_FILE4}" != "" ]] ; then
OUTPUT="${OUTPUT}Changes in module - "
PERFORMANCE_VALUE="$((${PERFORMANCE_VALUE} + 1))"
RETURN=${WARNING}
fi
if [[ "${DIFF_FILE5}" != "" ]] ; then
OUTPUT="${OUTPUT}Changes in package - "
PERFORMANCE_VALUE="$((${PERFORMANCE_VALUE} + 1))"
RETURN=${WARNING}
fi
if [[ "${DIFF_FILE6}" != "" ]] ; then
OUTPUT="${OUTPUT}Changes in role - "
PERFORMANCE_VALUE="$((${PERFORMANCE_VALUE} + 1))"
RETURN=${WARNING}
fi
if [[ "${DIFF_FILE7}" != "" ]] ; then
OUTPUT="${OUTPUT}Changes in routine - "
PERFORMANCE_VALUE="$((${PERFORMANCE_VALUE} + 1))"
RETURN=${WARNING}
fi
if [[ "${DIFF_FILE8}" != "" ]] ; then
OUTPUT="${OUTPUT}Changes in schema - "
PERFORMANCE_VALUE="$((${PERFORMANCE_VALUE} + 1))"
RETURN=${WARNING}
fi
if [[ "${DIFF_FILE9}" != "" ]] ; then
OUTPUT="${OUTPUT}Changes in sequence - "
PERFORMANCE_VALUE="$((${PERFORMANCE_VALUE} + 1))"
RETURN=${WARNING}
fi
if [[ "${DIFF_FILE10}" != "" ]] ; then
OUTPUT="${OUTPUT}Changes in table - "
PERFORMANCE_VALUE="$((${PERFORMANCE_VALUE} + 1))"
RETURN=${WARNING}
fi
if [[ "${DIFF_FILE11}" != "" ]] ; then
OUTPUT="${OUTPUT}Changes in tablespace - "
PERFORMANCE_VALUE="$((${PERFORMANCE_VALUE} + 1))"
RETURN=${WARNING}
fi
if [[ "${DIFF_FILE12}" != "" ]] ; then
OUTPUT="${OUTPUT}Changes in variable - "
PERFORMANCE_VALUE="$((${PERFORMANCE_VALUE} + 1))"
RETURN=${WARNING}
fi
if [[ "${DIFF_FILE13}" != "" ]] ; then
OUTPUT="${OUTPUT}Changes in workload - "
PERFORMANCE_VALUE="$((${PERFORMANCE_VALUE} + 1))"
RETURN=${WARNING}
fi
if [[ "${DIFF_FILE14}" != "" ]] ; then
OUTPUT="${OUTPUT}Changes in xsrobject - "
PERFORMANCE_VALUE="$((${PERFORMANCE_VALUE} + 1))"
RETURN=${WARNING}
fi
PERFORMANCE="'Changes'=${PERFORMANCE_VALUE}"
fi
fi
PERF_MK=${PERFORMANCE}
fi
# Prints the output.
if [[ ${OUTPUT} == "" ]] ; then
OUTPUT="Note: The test was not executed."
fi
# Builds the output.
if [[ ${CHECK_MK} == true ]] ; then
echo "${RETURN} diffDBSec${TYPE}-${INSTANCE_NAME}-${DATABASE_NAME} ${PERF_MK} ${OUTPUT}"
else
echo -e "${OUTPUT}|${PERFORMANCE}\n${LONG_OUTPUT}|${LONG_PERFORMANCE}"
fi
# Returns the error code.
if [[ ${VERBOSE} -ge 2 ]] ; then
echo "Return code: ${RETURN}"
fi
if [[ ${TRACE} == true ]] ; then
echo -e "OUTPUT:${OUTPUT}\nPERF:${PERFORMANCE}\nLONG_OUT:${LONG_OUTPUT}\nLONGPERF:${LONG_PERFORMANCE}\nRET_CODE:${RETURN}" >> ${LOG}
date >> ${LOG}
echo -e "<<<<<\n" >> ${LOG}
fi
if [[ ${LOCKED} == true && -r ${LOCK_FILE} ]] ; then
rm ${LOCK_FILE}
fi
echo "$(date +"%Y-%m-%d-%H.%M.%S") $$ Ended ${APPL_NAME} ${COPY_ARGS[@]}" >> /tmp/${APPL_NAME}.log
exit ${RETURN}