summaryrefslogtreecommitdiffstats
path: root/plugins-scripts/check_oracle.sh
diff options
context:
space:
mode:
Diffstat (limited to 'plugins-scripts/check_oracle.sh')
-rwxr-xr-xplugins-scripts/check_oracle.sh126
1 files changed, 126 insertions, 0 deletions
diff --git a/plugins-scripts/check_oracle.sh b/plugins-scripts/check_oracle.sh
new file mode 100755
index 0000000..1a4d8ab
--- /dev/null
+++ b/plugins-scripts/check_oracle.sh
@@ -0,0 +1,126 @@
1#!/bin/sh
2#
3# latigid010@yahoo.com
4# 01/06/2000
5#
6# This Nagios plugin was created to check remote or local TNS
7# status and check local Database status.
8#
9# Add the following lines to your object config file (i.e. commands.cfg)
10# command[check-tns]=/usr/local/nagios/libexec/check_ora 1 $ARG$
11# command[check-oradb]=/usr/local/nagios/libexec/check_ora 2 $ARG$
12#
13#
14# Usage:
15# To check TNS Status: ./check_ora 1 <Oracle Sid or Hostname/IP address>
16# To Check local database: ./check_ora 2 <ORACLE_SID>
17#
18# I have the script checking for the Oracle PMON process and
19# the sgadefORACLE_SID.dbf file.
20#
21#
22# If you have any problems check that you have the $ORACLE_HOME
23# enviroment variable set, have $ORACLE_HOME/bin in your PATH, and
24# dont forget about your tnsnames.ora file. when checking Local
25# Database status your ORACLE_SID is case sensitive.
26#
27
28PROGNAME=`basename $0`
29PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
30REVISION=`echo '$Revision$' | sed -e 's/[^0-9.]//g'`
31
32. $PROGPATH/utils.sh
33
34
35print_usage() {
36 echo "Usage:"
37 echo " $PROGNAME --tns <Oracle Sid or Hostname/IP address>"
38 echo " $PROGNAME --db <ORACLE_SID>"
39 echo " $PROGNAME --help"
40 echo " $PROGNAME --version"
41}
42
43print_help() {
44 print_revision $PROGNAME $REVISION
45 echo ""
46 print_usage
47 echo ""
48 echo "Check remote or local TNS status and check local Database status"
49 echo ""
50 echo "--tns=SID/IP Address"
51 echo " Check remote TNS server"
52 echo "--db=SID"
53 echo " Check local database (search /bin/ps for PMON process and check"
54 echo " filesystem for sgadefORACLE_SID.dbf"
55 echo "--help"
56 echo " Print this help screen"
57 echo "--version"
58 echo " Print version and license information"
59 echo ""
60 echo "If the plugin doesn't work, check that the $ORACLE_HOME environment"
61 echo "variable is set, that $ORACLE_HOME/bin is in your PATH, and the"
62 echo "tnsnames.ora file is locatable and is properly configured."
63 echo ""
64 echo "When checking Local Database status your ORACLE_SID is case sensitive."
65 echo ""
66 support
67}
68
69case "$1" in
701)
71 cmd='--tns'
72 ;;
732)
74 cmd='--db'
75 ;;
76*)
77 cmd="$1"
78 ;;
79esac
80
81case "$cmd" in
82--tns)
83 export tnschk=` tnsping $2`
84 export tnschk2=` echo $tnschk | grep -c OK`
85 export tnschk3=` echo $tnschk | cut -d\( -f7 | sed y/\)/" "/`
86 if [ ${tnschk2} -eq 1 ] ; then
87 echo "OK - reply time ${tnschk3} from $2"
88 exit 0
89 else
90 echo "No TNS Listener on $2"
91 exit $STATE_CRITICAL
92 fi
93 ;;
94--db)
95 export pmonchk=`ps -ef | grep -v grep | grep ${2} | grep -c pmon`
96 if [ -e $ORACLE_HOME/dbs/sga*${2}* ] ; then
97 if [ ${pmonchk} -eq 1 ] ; then
98 export utime=`ls -la $ORACLE_HOME/dbs/sga*$2* | cut -c 43-55`
99 echo "${2} OK - running since ${utime}"
100 exit $STATE_OK
101 fi
102 else
103 echo "${2} Database is DOWN"
104 exit $STATE_CRITICAL
105 fi
106 ;;
107--help)
108 print_help
109 exit $STATE_OK
110 ;;
111-h)
112 print_help
113 exit $STATE_OK
114 ;;
115--version)
116 print_revision $PLUGIN $REVISION
117 exit $STATE_OK
118 ;;
119-V)
120 print_revision $PLUGIN $REVISION
121 exit $STATE_OK
122 ;;
123*)
124 print_usage
125 exit $STATE_UNKNOWN
126esac