-
Notifications
You must be signed in to change notification settings - Fork 86
/
db2mon.sh
executable file
·63 lines (51 loc) · 1.41 KB
/
db2mon.sh
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
#!/bin/sh
dbName=$1
monitorTime=$2
scriptRoot=`dirname $0`
# Remove any user settings
export DB2OPTIONS=
if [ -z "$dbName" ]
then
echo Specify a database to connect to!
echo Usage:
echo db2mon.sh <DBNAME> [interval]
echo
echo If no interval is specified, the default delay will be used
exit 1
fi
if [ -n "$monitorTime" ]; then
if [ $monitorTime -eq $monitorTime 2> /dev/null ]; then
if [ $monitorTime -gt 0 ]; then
echo Monitoring interval set to $monitorTime seconds
else
echo Error: Monitoring interval $monitorTime is negative - only positive intervals are supported
exit -1
fi
else
echo Error: Monitoring interval $monitorTime does not appear to be a number
exit -2
fi
fi
echo Scripts should be found in $scriptRoot
db2 -v connect to $dbName
db2 -v create bufferpool db2monbp
db2 -v create user temporary tablespace db2montmptbsp bufferpool db2monbp
db2 +c -tvf $scriptRoot/db2monBefore.sql
# Earlier versions did not offer a easily changable monitor time
if [ -z "$monitorTime" ]; then
db2 +c -tvf $scriptRoot/db2monInterval.sql
else
if [ "$monitorTime" == "0" ]; then
echo Hit enter to finish monitoring
read string
else
sleep $monitorTime
fi
fi
db2 +c -tvf $scriptRoot/db2monAfter.sql
db2 -v commit work
db2 -v connect reset
db2 -v connect to $dbName
db2 -v drop tablespace db2montmptbsp
db2 -v drop bufferpool db2monbp
db2 -v connect reset