diff options
author | Subhendu Ghosh <sghosh@users.sourceforge.net> | 2002-06-06 04:15:06 (GMT) |
---|---|---|
committer | Subhendu Ghosh <sghosh@users.sourceforge.net> | 2002-06-06 04:15:06 (GMT) |
commit | 33d91abe09df43a041a8067c1e0e54450eba012c (patch) | |
tree | 0919d7222e027cbb13476b7c3feb32a93949e07c | |
parent | 9388f9494f5089f9e6e0ff267e742ca6acac20bc (diff) | |
download | monitoring-plugins-33d91abe09df43a041a8067c1e0e54450eba012c.tar.gz |
Add test for Oracle name server, can dynamicall determine ORACLE_HOME - tom Bertelson
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@45 f882894a-f735-0410-b71e-b25c423dba1c
-rwxr-xr-x | plugins-scripts/check_oracle.sh | 78 |
1 files changed, 65 insertions, 13 deletions
diff --git a/plugins-scripts/check_oracle.sh b/plugins-scripts/check_oracle.sh index 1a4d8ab..d2a84fe 100755 --- a/plugins-scripts/check_oracle.sh +++ b/plugins-scripts/check_oracle.sh | |||
@@ -36,6 +36,7 @@ print_usage() { | |||
36 | echo "Usage:" | 36 | echo "Usage:" |
37 | echo " $PROGNAME --tns <Oracle Sid or Hostname/IP address>" | 37 | echo " $PROGNAME --tns <Oracle Sid or Hostname/IP address>" |
38 | echo " $PROGNAME --db <ORACLE_SID>" | 38 | echo " $PROGNAME --db <ORACLE_SID>" |
39 | echo " $PROGNAME --oranames <Hostname>" | ||
39 | echo " $PROGNAME --help" | 40 | echo " $PROGNAME --help" |
40 | echo " $PROGNAME --version" | 41 | echo " $PROGNAME --version" |
41 | } | 42 | } |
@@ -52,13 +53,15 @@ print_help() { | |||
52 | echo "--db=SID" | 53 | echo "--db=SID" |
53 | echo " Check local database (search /bin/ps for PMON process and check" | 54 | echo " Check local database (search /bin/ps for PMON process and check" |
54 | echo " filesystem for sgadefORACLE_SID.dbf" | 55 | echo " filesystem for sgadefORACLE_SID.dbf" |
56 | echo "--oranames=Hostname" | ||
57 | echo " Check remote Oracle Names server" | ||
55 | echo "--help" | 58 | echo "--help" |
56 | echo " Print this help screen" | 59 | echo " Print this help screen" |
57 | echo "--version" | 60 | echo "--version" |
58 | echo " Print version and license information" | 61 | echo " Print version and license information" |
59 | echo "" | 62 | echo "" |
60 | echo "If the plugin doesn't work, check that the $ORACLE_HOME environment" | 63 | 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" | 64 | 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." | 65 | echo "tnsnames.ora file is locatable and is properly configured." |
63 | echo "" | 66 | echo "" |
64 | echo "When checking Local Database status your ORACLE_SID is case sensitive." | 67 | echo "When checking Local Database status your ORACLE_SID is case sensitive." |
@@ -78,27 +81,76 @@ case "$1" in | |||
78 | ;; | 81 | ;; |
79 | esac | 82 | esac |
80 | 83 | ||
84 | # Hunt down a reasonable ORACLE_HOME | ||
85 | if [ -z "$ORACLE_HOME" ] ; then | ||
86 | # Adjust to taste | ||
87 | for oratab in /var/opt/oracle/oratab /etc/oratab | ||
88 | do | ||
89 | [ ! -f $oratab ] && continue | ||
90 | ORACLE_HOME=`IFS=: | ||
91 | while read SID ORACLE_HOME junk; | ||
92 | do | ||
93 | if [ "$SID" = "$2" ] ; then | ||
94 | echo $ORACLE_HOME; | ||
95 | exit; | ||
96 | fi; | ||
97 | done < $oratab` | ||
98 | [ -n "$ORACLE_HOME" ] && break | ||
99 | done | ||
100 | fi | ||
101 | # Last resort | ||
102 | [ -z "$ORACLE_HOME" -a -d $PROGPATH/oracle ] && ORACLE_HOME=$PROGPATH/oracle | ||
103 | |||
104 | if [ -z "$ORACLE_HOME" -o ! -d "$ORACLE_HOME" ] ; then | ||
105 | echo "Cannot determine ORACLE_HOME for sid $2" | ||
106 | exit $STATE_UNKNOWN | ||
107 | fi | ||
108 | PATH=$PATH:$ORACLE_HOME/bin | ||
109 | LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib | ||
110 | export ORACLE_HOME PATH LD_LIBRARY_PATH | ||
111 | |||
81 | case "$cmd" in | 112 | case "$cmd" in |
82 | --tns) | 113 | --tns) |
83 | export tnschk=` tnsping $2` | 114 | tnschk=` tnsping $2` |
84 | export tnschk2=` echo $tnschk | grep -c OK` | 115 | tnschk2=` echo $tnschk | grep -c OK` |
85 | export tnschk3=` echo $tnschk | cut -d\( -f7 | sed y/\)/" "/` | ||
86 | if [ ${tnschk2} -eq 1 ] ; then | 116 | if [ ${tnschk2} -eq 1 ] ; then |
117 | tnschk3=` echo $tnschk | sed -e 's/.*(//' -e 's/).*//'` | ||
87 | echo "OK - reply time ${tnschk3} from $2" | 118 | echo "OK - reply time ${tnschk3} from $2" |
88 | exit 0 | 119 | exit $STATE_OK |
89 | else | 120 | else |
90 | echo "No TNS Listener on $2" | 121 | echo "No TNS Listener on $2" |
91 | exit $STATE_CRITICAL | 122 | exit $STATE_CRITICAL |
92 | fi | 123 | fi |
93 | ;; | 124 | ;; |
125 | --oranames) | ||
126 | namesctl status $2 | awk ' | ||
127 | /Server has been running for:/ { | ||
128 | msg = "OK: Up" | ||
129 | for (i = 6; i <= NF; i++) { | ||
130 | msg = msg " " $i | ||
131 | } | ||
132 | status = '$STATE_OK' | ||
133 | } | ||
134 | /error/ { | ||
135 | msg = "CRITICAL: " $0 | ||
136 | status = '$STATE_CRITICAL' | ||
137 | } | ||
138 | END { | ||
139 | print msg | ||
140 | exit status | ||
141 | }' | ||
142 | ;; | ||
94 | --db) | 143 | --db) |
95 | export pmonchk=`ps -ef | grep -v grep | grep ${2} | grep -c pmon` | 144 | pmonchk=`ps -ef | grep -v grep | grep ${2} | grep -c pmon` |
96 | if [ -e $ORACLE_HOME/dbs/sga*${2}* ] ; then | 145 | if [ ${pmonchk} -ge 1 ] ; then |
97 | if [ ${pmonchk} -eq 1 ] ; then | 146 | echo "${2} OK - ${pmonchk} PMON process(es) running" |
98 | export utime=`ls -la $ORACLE_HOME/dbs/sga*$2* | cut -c 43-55` | 147 | exit $STATE_OK |
99 | echo "${2} OK - running since ${utime}" | 148 | #if [ -f $ORACLE_HOME/dbs/sga*${2}* ] ; then |
100 | exit $STATE_OK | 149 | #if [ ${pmonchk} -eq 1 ] ; then |
101 | fi | 150 | #utime=`ls -la $ORACLE_HOME/dbs/sga*$2* | cut -c 43-55` |
151 | #echo "${2} OK - running since ${utime}" | ||
152 | #exit $STATE_OK | ||
153 | #fi | ||
102 | else | 154 | else |
103 | echo "${2} Database is DOWN" | 155 | echo "${2} Database is DOWN" |
104 | exit $STATE_CRITICAL | 156 | exit $STATE_CRITICAL |