Compare commits
2 Commits
master
...
shellcheck
Author | SHA1 | Date | |
---|---|---|---|
a0087dbd1a | |||
4fcc3b900b |
@ -100,15 +100,6 @@ SET TIMING OFF"
|
||||
# And BACKUP_METHOD allowed: ${LIGHTGREEN}${KNOWNTYPE[*]}${RESET}\n"
|
||||
# # VERY INITIAL CHECKS
|
||||
|
||||
support() {
|
||||
printf "%sSend email to nagios-users@lists.sourceforge.net if you have questions\nregarding use of this software. To submit patches or suggest improvements,\nsend email to nagiosplug-devel@lists.sourceforge.net.\nPlease include version information with all correspondence (when possible,\nuse output from the --version option of the plugin itself).\n" | sed -e 's/\n/ /g'
|
||||
}
|
||||
|
||||
print_revision() {
|
||||
echo "$1 v$2 (nagios-plugins 2.0)"
|
||||
printf "%sThe nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\ncopies of the plugins under the terms of the GNU General Public License.\nFor more information about these matters, see the file named COPYING.\n" | sed -e 's/\n/ /g'
|
||||
}
|
||||
|
||||
# H host
|
||||
# U oracle user
|
||||
# S sid
|
||||
@ -174,114 +165,6 @@ usage()
|
||||
exit 0
|
||||
}
|
||||
|
||||
print_usage()
|
||||
{
|
||||
echo "Usage:
|
||||
${PROGPATH}/${PROGNAME} -H <Hostname/IP address> [-U Oracle OS User] --tns <ORACLE_SID>
|
||||
${PROGPATH}/${PROGNAME} -H <Hostname/IP address> [-U Oracle OS User] --db <ORACLE_SID>
|
||||
${PROGPATH}/${PROGNAME} -H <Hostname/IP address> [-U Oracle OS User] --login <ORACLE_SID>
|
||||
${PROGPATH}/${PROGNAME} -H <Hostname/IP address> [-U Oracle OS User] --userslocked <ORACLE_SID>
|
||||
${PROGPATH}/${PROGNAME} -H <Hostname/IP address> [-U Oracle OS User] --ospassword CRITICAL_THRESHOLD WARNING_THRESHOLD
|
||||
${PROGPATH}/${PROGNAME} -H <Hostname/IP address> [-U Oracle OS User] --sessions <ORACLE_SID> CRITICAL_THRESHOLD WARNING_THRESHOLD
|
||||
${PROGPATH}/${PROGNAME} -H <Hostname/IP address> [-U Oracle OS User] --asessions <ORACLE_SID> CRITICAL_THRESHOLD WARNING_THRESHOLD
|
||||
${PROGPATH}/${PROGNAME} -H <Hostname/IP address> [-U Oracle OS User] --cache <ORACLE_SID> CRITICAL_THRESHOLD WARNING_THRESHOLD
|
||||
${PROGPATH}/${PROGNAME} -H <Hostname/IP address> [-U Oracle OS User] --parsing <ORACLE_SID> CRITICAL_THRESHOLD WARNING_THRESHOLD
|
||||
${PROGPATH}/${PROGNAME} -H <Hostname/IP address> [-U Oracle OS User] --tablespace <ORACLE_SID> <TABLESPACE> CRITICAL_THRESHOLD WARNING_THRESHOLD
|
||||
${PROGPATH}/${PROGNAME} -H <Hostname/IP address> [-U Oracle OS User] --undo <ORACLE_SID> CRITICAL_THRESHOLD WARNING_THRESHOLD
|
||||
${PROGPATH}/${PROGNAME} -H <Hostname/IP address> [-U Oracle OS User] --diskgroup <ORACLE_SID> <DISKGROUP> CRITICAL_THRESHOLD WARNING_THRESHOLD
|
||||
${PROGPATH}/${PROGNAME} -H <Hostname/IP address> [-U Oracle OS User] --asmfs <ASMFS_PATH> CRITICAL_THRESHOLD WARNING_THRESHOLD
|
||||
${PROGPATH}/${PROGNAME} -H <Hostname/IP address> [-U Oracle OS User] --dgstats <ORACLE_SID> CRITICAL_THRESHOLD WARNING_THRESHOLD
|
||||
${PROGPATH}/${PROGNAME} -H <Hostname/IP address> [-U Oracle OS User] --fra <ORACLE_SID> CRITICAL_THRESHOLD WARNING_THRESHOLD
|
||||
${PROGPATH}/${PROGNAME} -H <Hostname/IP address> [-U Oracle OS User] --redogen <ORACLE_SID>
|
||||
${PROGPATH}/${PROGNAME} -H <Hostname/IP address> [-U Oracle OS User] --sessionlock <ORACLE_SID>
|
||||
${PROGPATH}/${PROGNAME} -H <Hostname/IP address> [-U Oracle OS User] --totalspace <ORACLE_SID>
|
||||
${PROGPATH}/${PROGNAME} -H <Hostname/IP address> [-U Oracle OS User] --totalspacedelta <ORACLE_SID>
|
||||
${PROGPATH}/${PROGNAME} -H <Hostname/IP address> [-U Oracle OS User] --plsqllines <ORACLE_SID>
|
||||
${PROGPATH}/${PROGNAME} --help
|
||||
${PROGPATH}/${PROGNAME} --version
|
||||
|
||||
"
|
||||
|
||||
}
|
||||
|
||||
print_help()
|
||||
{
|
||||
print_revision $PROGNAME $REVISION
|
||||
echo ""
|
||||
print_usage
|
||||
echo "
|
||||
Check Oracle status
|
||||
|
||||
--tns SID/IP Address
|
||||
Check remote TNS server
|
||||
--db SID
|
||||
Check remote database (search /bin/ps for PMON process)
|
||||
--sessions SID
|
||||
Check remote database concurrent active sessions
|
||||
--asessions SID
|
||||
Count sessions on the database (either active or not) per database user
|
||||
--login SID
|
||||
Attempt a dummy login and alert if not ORA-01017: invalid username/password
|
||||
--userslocked SID
|
||||
Check if there's any user account is locked
|
||||
--cache
|
||||
Check remote database for library and buffer cache hit ratios
|
||||
--parsing
|
||||
Check remote database for Soft/Hard parse ratios
|
||||
--tablespace
|
||||
Check remote database for tablespace capacity in ORACLE_SID
|
||||
--undo
|
||||
Check remote database for UNDO tablespace capacity in ORACLE_SID
|
||||
--fra
|
||||
Check remote database for FLASH_RECOVERY_AREA capacity in ORACLE_SID
|
||||
--diskgroup
|
||||
Check remote database for diskgroup capacity in ORACLE_ASM_SID (Tipically +ASM1/2...)
|
||||
--dgstats
|
||||
Dataguard statistics (Apply & Transport Lag). This check is done ON THE STANDBY (the master does not have information on V\$DATAGUARD_STATS. So ORACLE_SID and HOSTNAME must be the STANDBY ones.
|
||||
--redogen
|
||||
Daily check for yesterday's redo generation
|
||||
--sessionlock
|
||||
Watch for session locks (any lock with return CRITICAL)
|
||||
--totalspace
|
||||
Total Space taken by the database Excluding sytem tablespaces.
|
||||
--totalspacedelta
|
||||
Delta of the Total Space (Yesterday-thedaybeforeyesterday)
|
||||
--developers
|
||||
Number of sessions of the developers.
|
||||
--help
|
||||
Print this help screen
|
||||
--version
|
||||
Print version and license information
|
||||
|
||||
If the plugin doesn't work, check that the ORACLE_HOME environment
|
||||
variable is set, that ORACLE_HOME/bin is in your PATH, and the
|
||||
tnsnames.ora file is locatable and is properly configured on your Oracle server.
|
||||
|
||||
If you want to use a default Oracle home, add in your oratab file:
|
||||
*:/opt/app/oracle/product/7.3.4:N
|
||||
"
|
||||
}
|
||||
|
||||
## getops ### usage()
|
||||
## getops ### {
|
||||
## getops ### # Information options
|
||||
## getops ### case "${1^^}" in
|
||||
## getops ### "--HELP"|"-H")
|
||||
## getops ### print_help
|
||||
## getops ### exit $STATE_OK
|
||||
## getops ### ;;
|
||||
## getops ### "--VERSION"|"-V")
|
||||
## getops ### print_revision $PROGNAME $REVISION
|
||||
## getops ### exit $STATE_OK
|
||||
## getops ### ;;
|
||||
## getops ### *)
|
||||
## getops ### print_usage
|
||||
## getops ### exit $STATE_OK
|
||||
## getops ### ;;
|
||||
## getops ### esac
|
||||
## getops ### }
|
||||
|
||||
|
||||
oraerror_check()
|
||||
{
|
||||
local CHECKTHIS="$*"
|
||||
@ -294,7 +177,7 @@ oraerror_check()
|
||||
|
||||
return_values()
|
||||
{
|
||||
local let VALUE=$1
|
||||
local VALUE=$1
|
||||
if [[ ${VALUE} -gt ${CRITICAL} ]] ; then
|
||||
MSG="CRITICAL"
|
||||
RETURNCODE=${STATE_CRITICAL}
|
||||
@ -314,7 +197,7 @@ return_values()
|
||||
|
||||
reverse_return_values()
|
||||
{
|
||||
local let VALUE=$1
|
||||
local VALUE=$1
|
||||
if [[ ${VALUE} -lt ${CRITICAL} ]] ; then
|
||||
MSG="CRITICAL"
|
||||
RETURNCODE=${STATE_CRITICAL}
|
||||
@ -341,11 +224,11 @@ get_remote_oraclehome()
|
||||
{
|
||||
#set -x
|
||||
# Hunt down a reasonable ORACLE_HOME
|
||||
ORATABLIST="$(${SSH} "locate oratab" | egrep "/oratab$" | tr '\n' ' ')"
|
||||
ORATABLIST="$(${SSH} "locate oratab" | grep -E "/oratab$" | tr '\n' ' ')"
|
||||
|
||||
for ORATAB in ${ORATABLIST} ; do
|
||||
ORACLE_HOME=$(${SSH} "cat ${ORATAB}" | egrep "^(${ORACLE_SID}|\*):" | awk -F\: '{print $2}')
|
||||
if [[ "${ORACLE_HOME}" ]] && [ $($SSH "ls -d ${ORACLE_HOME}" |wc -l) -eq 1 ] ; then
|
||||
ORACLE_HOME=$(${SSH} "cat ${ORATAB}" | grep -E "^(${ORACLE_SID}|\*):" | awk -F: '{print $2}')
|
||||
if [[ "${ORACLE_HOME}" ]] && [ "$($SSH "ls -d ${ORACLE_HOME}" |wc -l)" -eq 1 ] ; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
@ -355,7 +238,8 @@ get_remote_oraclehome()
|
||||
check_tns()
|
||||
{
|
||||
local AUX="${ORAENV} tnsping ${ORACLE_SID}"
|
||||
local TNSCHECK="$(${SSH} ${AUX})"
|
||||
local TNSCHECK
|
||||
TNSCHECK="$(${SSH} "${AUX}")"
|
||||
# echo ${TNSCHECK}
|
||||
if [[ "${TNSCHECK}" =~ .*OK.*\(([0-9]{1,})\ .* ]] ; then
|
||||
return ${STATE_OK}
|
||||
@ -366,8 +250,9 @@ check_tns()
|
||||
|
||||
check_db()
|
||||
{
|
||||
local PMONCHECK="$(${SSH} "ps -ef" | egrep -v grep | grep -c "ora_pmon_${ORACLE_SID}")"
|
||||
if [ ${PMONCHECK} -ge 1 ] ; then
|
||||
local PMONCHECK
|
||||
PMONCHECK="$(${SSH} "ps -ef" | grep -Ev grep | grep -c "ora_pmon_${ORACLE_SID}")"
|
||||
if [[ ${PMONCHECK} -ge 1 ]] ; then
|
||||
# echo "${ORACLE_SID} OK - ${PMONCHECK} PMON process(es) running"
|
||||
return ${STATE_OK}
|
||||
else
|
||||
@ -391,8 +276,8 @@ check_login()
|
||||
|
||||
check_total_sessions()
|
||||
{
|
||||
local let RETURNCODE=${STATE_UNKNOWN}
|
||||
local let TOTALSESSIONS=0
|
||||
local RETURNCODE=${STATE_UNKNOWN}
|
||||
local TOTALSESSIONS=0
|
||||
|
||||
local QUERY="${NOHEAD}
|
||||
set numf 99999
|
||||
@ -421,11 +306,11 @@ and not username in ('SYS', 'PUBLIC', 'NAGIOS' )
|
||||
|
||||
check_asessions_v3()
|
||||
{
|
||||
local let RETURNCODE=${STATE_UNKNOWN}
|
||||
local let MAXINDEX=0
|
||||
local let i=0
|
||||
local let x=0
|
||||
local let TOTALSESSIONS=0
|
||||
local RETURNCODE=${STATE_UNKNOWN}
|
||||
local MAXINDEX=0
|
||||
local i=0
|
||||
local x=0
|
||||
local TOTALSESSIONS=0
|
||||
|
||||
declare -a RESSULTARRAY
|
||||
declare -a RESSULTUSERS
|
||||
@ -473,10 +358,10 @@ order by 1
|
||||
|
||||
check_sharedpool()
|
||||
{
|
||||
local let RETURNCODE=${STATE_UNKNOWN}
|
||||
local let SHAREDFREE=0
|
||||
local let SHAREDTOTAL=0
|
||||
local let SHAREDPERCENT=100
|
||||
local RETURNCODE=${STATE_UNKNOWN}
|
||||
local SHAREDFREE=0
|
||||
local SHAREDTOTAL=0
|
||||
local SHAREDPERCENT=100
|
||||
|
||||
local QUERY="${NOHEAD}
|
||||
SELECT 'shared_pool_total=' || ROUND(SUM(BYTES)/1024/1024) FROM sys.V_\\\$SGASTAT WHERE POOL='shared pool' GROUP BY POOL;
|
||||
@ -535,7 +420,7 @@ check_developers()
|
||||
# Included SYSTEM in the query's exclusion pattern to avoid reporting backup sessions.
|
||||
check_sessions()
|
||||
{
|
||||
local let RETURNCODE=${STATE_UNKNOWN}
|
||||
local RETURNCODE=${STATE_UNKNOWN}
|
||||
local QUERY="${NOHEAD}
|
||||
set numf 99
|
||||
select count(SES.SID)
|
||||
@ -565,8 +450,8 @@ and UPPER(SES.USERNAME) not in ( 'SYS','SYSMAN','MDSYS','SYSTEM','NAGIOS', 'DBSN
|
||||
# Included SYSTEM in the query's exclusion pattern to avoid reporting backup sessions.
|
||||
check_activesessions()
|
||||
{
|
||||
local let RETURNCODE=${STATE_UNKNOWN}
|
||||
local let TOTALSESSIONS=0
|
||||
local RETURNCODE=${STATE_UNKNOWN}
|
||||
local TOTALSESSIONS=0
|
||||
local PERFDATA=""
|
||||
local QUERY="${NOHEAD}
|
||||
set numf 999
|
||||
|
Loading…
Reference in New Issue
Block a user