summaryrefslogtreecommitdiffstats
path: root/web/attachments/419185-check_oracle_1.4.15_tsmax.patch
diff options
context:
space:
mode:
Diffstat (limited to 'web/attachments/419185-check_oracle_1.4.15_tsmax.patch')
-rw-r--r--web/attachments/419185-check_oracle_1.4.15_tsmax.patch95
1 files changed, 95 insertions, 0 deletions
diff --git a/web/attachments/419185-check_oracle_1.4.15_tsmax.patch b/web/attachments/419185-check_oracle_1.4.15_tsmax.patch
new file mode 100644
index 0000000..86a3232
--- /dev/null
+++ b/web/attachments/419185-check_oracle_1.4.15_tsmax.patch
@@ -0,0 +1,95 @@
1--- check_oracle 2010-10-07 17:11:31.000000000 +0200
2+++ check_oracle_tsmax 2011-07-22 15:12:42.000000000 +0200
3@@ -8,7 +8,7 @@
4
5 PROGNAME=`basename $0`
6 PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
7-REVISION="1.4.15"
8+REVISION="1.4.15-tsmax"
9
10 . $PROGPATH/utils.sh
11
12@@ -19,7 +19,7 @@
13 echo " $PROGNAME --db <ORACLE_SID>"
14 echo " $PROGNAME --login <ORACLE_SID>"
15 echo " $PROGNAME --cache <ORACLE_SID> <USER> <PASS> <CRITICAL> <WARNING>"
16- echo " $PROGNAME --tablespace <ORACLE_SID> <USER> <PASS> <TABLESPACE> <CRITICAL> <WARNING>"
17+ echo " $PROGNAME --tablespace <ORACLE_SID> <USER> <PASS> <TABLESPACE> <CRITICAL> <WARNING> [maxbytes]"
18 echo " $PROGNAME --oranames <Hostname>"
19 echo " $PROGNAME --help"
20 echo " $PROGNAME --version"
21@@ -42,7 +42,7 @@
22 echo "--cache"
23 echo " Check local database for library and buffer cache hit ratios"
24 echo " ---> Requires Oracle user/password and SID specified."
25- echo " ---> Requires select on v_$sysstat and v_$librarycache"
26+ echo " ---> Requires select on v_\$sysstat and v_\$librarycache"
27 echo "--tablespace"
28 echo " Check local database for tablespace capacity in ORACLE_SID"
29 echo " ---> Requires Oracle user/password specified."
30@@ -246,12 +246,12 @@
31 result=`sqlplus -s ${3}/${4}@${2} << EOF
32 set pagesize 0
33 set numf '9999999.99'
34-select NVL(b.free,0.0),a.total,100 - trunc(NVL(b.free,0.0)/a.total * 1000) / 10 prc
35+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
36 from (
37-select tablespace_name,sum(bytes)/1024/1024 total
38+select tablespace_name,sum(NVL(bytes,0))/1024/1024 total,sum(NVL(maxbytes,0))/1024/1024 maxi
39 from dba_data_files group by tablespace_name) A
40 LEFT OUTER JOIN
41-( select tablespace_name,sum(bytes)/1024/1024 free
42+( select tablespace_name,sum(NVL(bytes,0))/1024/1024 free
43 from dba_free_space group by tablespace_name) B
44 ON a.tablespace_name=b.tablespace_name WHERE a.tablespace_name='${5}';
45 EOF`
46@@ -262,23 +262,42 @@
47 exit $STATE_CRITICAL
48 fi
49
50- ts_free=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($1)}'`
51- ts_total=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($2)}'`
52- ts_pct=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($3)}'`
53- ts_pctx=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print $3}'`
54+ ts_total=
55+ ts_used=
56+ ts_free=
57+ if [ "${8}" = "max" ]; then
58+ ts_total=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($1)}'`
59+ ts_used=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($3)}'`
60+ ts_free=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($5)}'`
61+ else
62+ ts_total=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($2)}'`
63+ ts_used=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($3)}'`
64+ ts_free=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($4)}'`
65+ fi
66+
67+ compwarn=$7; compcrit=$6
68+
69+ if [ "$ts_total" = "" ]; then
70+ echo "${2} : ${5} UNKNOWN - no data was returned|${5}=0%;$compwarn%;$compcrit%;0;100"
71+ exit $STATE_UNKNOWN
72+ fi
73+
74+ ts_pctx=`echo "scale=2; $ts_used/$ts_total * 100" | bc -l`
75+ ts_pct=`echo "scale=0; $ts_used/$ts_total * 100" | bc -l`
76+
77 if [ "$ts_free" -eq 0 -a "$ts_total" -eq 0 -a "$ts_pct" -eq 0 ] ; then
78 echo "No data returned by Oracle - tablespace $5 not found?"
79 exit $STATE_UNKNOWN
80 fi
81 if [ "$ts_pct" -ge ${6} ] ; then
82- echo "${2} : ${5} CRITICAL - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100"
83+ echo "${2} : ${5} CRITICAL - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;$compwarn%;$compcrit%;0;100"
84 exit $STATE_CRITICAL
85 fi
86 if [ "$ts_pct" -ge ${7} ] ; then
87- echo "${2} : ${5} WARNING - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100"
88+ echo "${2} : ${5} WARNING - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;$compwarn%;$compcrit%;0;100"
89 exit $STATE_WARNING
90 fi
91- echo "${2} : ${5} OK - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100"
92+ echo "${2} : ${5} OK - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;$compwarn%;$compcrit%;0;100"
93 exit $STATE_OK
94 ;;
95 *)