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
|
--- check_oracle 2010-10-07 17:11:31.000000000 +0200
+++ check_oracle_tsmax 2011-07-22 15:12:42.000000000 +0200
@@ -8,7 +8,7 @@
PROGNAME=`basename $0`
PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
-REVISION="1.4.15"
+REVISION="1.4.15-tsmax"
. $PROGPATH/utils.sh
@@ -19,7 +19,7 @@
echo " $PROGNAME --db <ORACLE_SID>"
echo " $PROGNAME --login <ORACLE_SID>"
echo " $PROGNAME --cache <ORACLE_SID> <USER> <PASS> <CRITICAL> <WARNING>"
- echo " $PROGNAME --tablespace <ORACLE_SID> <USER> <PASS> <TABLESPACE> <CRITICAL> <WARNING>"
+ echo " $PROGNAME --tablespace <ORACLE_SID> <USER> <PASS> <TABLESPACE> <CRITICAL> <WARNING> [maxbytes]"
echo " $PROGNAME --oranames <Hostname>"
echo " $PROGNAME --help"
echo " $PROGNAME --version"
@@ -42,7 +42,7 @@
echo "--cache"
echo " Check local database for library and buffer cache hit ratios"
echo " ---> Requires Oracle user/password and SID specified."
- echo " ---> Requires select on v_$sysstat and v_$librarycache"
+ echo " ---> Requires select on v_\$sysstat and v_\$librarycache"
echo "--tablespace"
echo " Check local database for tablespace capacity in ORACLE_SID"
echo " ---> Requires Oracle user/password specified."
@@ -246,12 +246,12 @@
result=`sqlplus -s ${3}/${4}@${2} << EOF
set pagesize 0
set numf '9999999.99'
-select NVL(b.free,0.0),a.total,100 - trunc(NVL(b.free,0.0)/a.total * 1000) / 10 prc
+select ROUND(a.maxi,0) MAXI, ROUND(a.total,0) ALLOCATED, ROUND(a.total-b.free,0) USED, ROUND(b.free,0) FREE, ROUND(a.maxi-a.total+b.free,0) FREEMAXI
from (
-select tablespace_name,sum(bytes)/1024/1024 total
+select tablespace_name,sum(NVL(bytes,0))/1024/1024 total,sum(NVL(maxbytes,0))/1024/1024 maxi
from dba_data_files group by tablespace_name) A
LEFT OUTER JOIN
-( select tablespace_name,sum(bytes)/1024/1024 free
+( select tablespace_name,sum(NVL(bytes,0))/1024/1024 free
from dba_free_space group by tablespace_name) B
ON a.tablespace_name=b.tablespace_name WHERE a.tablespace_name='${5}';
EOF`
@@ -262,23 +262,42 @@
exit $STATE_CRITICAL
fi
- ts_free=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($1)}'`
- ts_total=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($2)}'`
- ts_pct=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($3)}'`
- ts_pctx=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print $3}'`
+ ts_total=
+ ts_used=
+ ts_free=
+ if [ "${8}" = "max" ]; then
+ ts_total=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($1)}'`
+ ts_used=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($3)}'`
+ ts_free=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($5)}'`
+ else
+ ts_total=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($2)}'`
+ ts_used=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($3)}'`
+ ts_free=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($4)}'`
+ fi
+
+ compwarn=$7; compcrit=$6
+
+ if [ "$ts_total" = "" ]; then
+ echo "${2} : ${5} UNKNOWN - no data was returned|${5}=0%;$compwarn%;$compcrit%;0;100"
+ exit $STATE_UNKNOWN
+ fi
+
+ ts_pctx=`echo "scale=2; $ts_used/$ts_total * 100" | bc -l`
+ ts_pct=`echo "scale=0; $ts_used/$ts_total * 100" | bc -l`
+
if [ "$ts_free" -eq 0 -a "$ts_total" -eq 0 -a "$ts_pct" -eq 0 ] ; then
echo "No data returned by Oracle - tablespace $5 not found?"
exit $STATE_UNKNOWN
fi
if [ "$ts_pct" -ge ${6} ] ; then
- echo "${2} : ${5} CRITICAL - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100"
+ echo "${2} : ${5} CRITICAL - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;$compwarn%;$compcrit%;0;100"
exit $STATE_CRITICAL
fi
if [ "$ts_pct" -ge ${7} ] ; then
- echo "${2} : ${5} WARNING - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100"
+ echo "${2} : ${5} WARNING - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;$compwarn%;$compcrit%;0;100"
exit $STATE_WARNING
fi
- echo "${2} : ${5} OK - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100"
+ echo "${2} : ${5} OK - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;$compwarn%;$compcrit%;0;100"
exit $STATE_OK
;;
*)
|