a lot of changtes

This commit is contained in:
dodger 2022-05-12 11:55:38 +02:00
parent ac6ec92e03
commit 434b1713a1
Signed by: dodger
GPG Key ID: F6701F6CB4D1C826

View File

@ -7,6 +7,39 @@
# #
# GRANTS for nagios user
# CREATE USER NAGIOS IDENTIFIED BY SOMEPASSWORD;
# GRANT CONNECT, RESOURCE TO NAGIOS ;
# GRANT SELECT ON V_$ARCHIVED_LOG to nagios ;
# GRANT SELECT ON V_$ASM_DISKGROUP to nagios ;
# GRANT SELECT ON V_$DATAGUARD_STATS to nagios ;
# GRANT SELECT ON V_$LOCK to nagios ;
# GRANT SELECT ON V_$LOG_HISTORY to nagios ;
# GRANT SELECT ON V_$PROCESS to nagios ;
# GRANT SELECT ON V_$SESSION to nagios ;
# GRANT SELECT ON V_$SESSION_WAIT to nagios ;
# GRANT SELECT ON V_$SQLAREA to nagios ;
# GRANT SELECT ON V_$SYSSTAT to nagios ;
# GRANT SELECT ON V_$controlfile to nagios ;
# GRANT SELECT ON V_$librarycache to nagios ;
# GRANT SELECT ON V_$lock to nagios ;
# GRANT SELECT ON V_$log to nagios ;
# GRANT SELECT ON V_$log_history to nagios ;
# GRANT SELECT ON V_$parameter to nagios ;
# GRANT SELECT ON V_$recovery_file_dest to nagios ;
# GRANT SELECT ON V_$session to nagios ;
# GRANT SELECT ON V_$sysstat to nagios ;
# GRANT SELECT ON DBA_DATA_FILES TO NAGIOS ;
# GRANT SELECT ON DBA_EXTENTS TO NAGIOS ;
# GRANT SELECT ON DBA_UNDO_EXTENTS TO NAGIOS ;
# GRANT SELECT ON dba_data_files TO NAGIOS ;
# GRANT SELECT ON dba_free_space TO NAGIOS ;
# GRANT SELECT ON dba_objects TO NAGIOS ;
# GRANT SELECT ON dba_source TO NAGIOS ;
# GRANT SELECT ON dba_temp_files TO NAGIOS ;
######################################################################## ########################################################################
# #
# CONSTANTS # CONSTANTS
@ -82,7 +115,7 @@ print_revision() {
# t tns # t tns
# d db # d db
# l login # l login
# o ospassword # o ospassword <- NOT NECESSARY
# s sessions # s sessions
# c cache # c cache
# p parsing # p parsing
@ -91,28 +124,49 @@ print_revision() {
# g diskgroup # g diskgroup
# f FRA # f FRA
# r redogen # r redogen
# k locks
# a dgstats
# o totalspace
usage() usage()
{ {
echo -e "${LIGHTBLUE}USAGE${RESET} echo -e "${LIGHTBLUE}USAGE${RESET}
# H host Mandatory options:
# U oracle user -H destination_hostname
# S sid -U oracle_linux_user
# W warning -S ORACLE_SID
# C critical Optional arguments (required for some checks):
# t tns -W warning
# d db -C critical
# l login
# o ospassword
# s sessions
# c cache
# p parsing
# b tablespace
# u undo
# g diskgroup
# f FRA
# r redogen
Checks:
-t
Check remote TNS server
-d
Check remote database (search /bin/ps for PMON process)
-s
Check remote database concurrent active sessions
-l
Attempt a dummy login and alert if not ORA-01017: invalid username/password
-c
Check remote database for library and buffer cache hit ratios
-p
Check remote database for Soft/Hard parse ratios
-b
Check remote database for tablespace capacity in ORACLE_SID
-u
Check remote database for UNDO tablespace capacity in ORACLE_SID
-f
Check remote database for FLASH_RECOVERY_AREA capacity in ORACLE_SID
-d
Check remote database for diskgroup capacity in ORACLE_ASM_SID (Tipically +ASM1/2...)
-a
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.
-r
Daily check for yesterday's redo generation
-k
Watch for session locks (any lock with return CRITICAL)
-o
Total Space taken by the database Excluding sytem tablespaces.
" "
exit 0 exit 0
@ -278,6 +332,9 @@ reverse_return_values()
# get_remote_oraclehome look for ORACLE_SID on oratab
# so if you don't have ORACLE_SID in the oratab file, it will avoid
# you can add a pseudo dummy line there...
get_remote_oraclehome() get_remote_oraclehome()
{ {
#set -x #set -x
@ -1541,6 +1598,31 @@ ORDER BY 1;
} }
printmsg()
{
echo -e "$*"
}
abort_message()
{
local let ABORTCODE=1
[[ ${EXITCODE} -ne 0 ]] && ABORTCODE=${EXITCODE}
printmsg "${LIGHTRED}ERROR${RESET}: $*"
exit ${ABORTCODE}
}
# debug_me uses variable ${DEBUG}
debug_me()
{
if [[ "${DEBUG}" && ${DEBUG} -eq 0 ]] ; then
echo -e "${LIGHTBLUE}DEBUG: ${RESET}$*"
fi
}
######################################################################## ########################################################################
# #
# / FUNCTIONS # / FUNCTIONS
@ -1593,26 +1675,7 @@ ORACLEUSERPASSWORD="D2HSHBFMO5IINME9I9WT"
######################################################################## ########################################################################
while getopts "H:U:S:W:C:tdloscpbugfrhkaDF" arg; do
# H host
# U oracle user
# S sid
# W warning
# C critical
# t tns
# d db
# l login
# o ospassword
# s sessions
# c cache
# p parsing
# b tablespace
# u undo
# g diskgroup
# f FRA
# r redogen
while getopts "H:U:S:W:C:tdloscpbugfrhDF" arg; do
case $arg in case $arg in
# H host # H host
H) H)
@ -1646,9 +1709,11 @@ while getopts "H:U:S:W:C:tdloscpbugfrhDF" arg; do
l) l)
COMMAND="login" COMMAND="login"
;; ;;
# o ospassword # o ospassword <- not necessary
# o totalspace
o) o)
COMMAND="ospassword" #COMMAND="ospassword"
COMMAND="totalspace"
;; ;;
# s sessions # s sessions
s) s)
@ -1682,6 +1747,14 @@ while getopts "H:U:S:W:C:tdloscpbugfrhDF" arg; do
r) r)
COMMAND="redogen" COMMAND="redogen"
;; ;;
# k sessionlock
k)
COMMAND="sessionlock"
;;
# a dgstats
a)
COMMAND="dgstats"
;;
h) h)
usage usage
;; ;;
@ -1700,20 +1773,25 @@ done
# mandatory ops # mandatory ops
if [[ ! "${REMOTE_SERVER}" ]] ; then if [[ ! "${REMOTE_SERVER}" ]] ; then
debug_me "No REMOTE_SERVER"
usage usage
fi fi
if [[ ! "${ORACLE_OSUSER}" ]] ; then if [[ ! "${ORACLE_OSUSER}" ]] ; then
debug_me "No ORACLE_OSUSER"
usage usage
fi fi
if [[ ! "${ORACLE_SID}" ]] ; then if [[ ! "${ORACLE_SID}" ]] ; then
debug_me "No ORACLE_SID"
usage usage
fi fi
if [[ ! "${WARNING}" || ! "${CRITICAL}" ]] ; then if [[ ! "${WARNING}" || ! "${CRITICAL}" ]] ; then
debug_me "no warning or critical, maybe this will fail"
fi
if [[ ! "${COMMAND}" ]] ; then
debug_me "No COMMAND received"
usage usage
fi fi
SSH="ssh ${ORACLE_OSUSER}@${REMOTE_SERVER} -xq" SSH="ssh ${ORACLE_OSUSER}@${REMOTE_SERVER} -xq"
get_remote_oraclehome get_remote_oraclehome
@ -1722,65 +1800,10 @@ get_remote_oraclehome
SQLPLUS="sqlplus -s '${ORACLEUSER}/${ORACLEUSERPASSWORD}@${ORACLE_SID}'" SQLPLUS="sqlplus -s '${ORACLEUSER}/${ORACLEUSERPASSWORD}@${ORACLE_SID}'"
ORAENV="ORACLE_HOME=${ORACLE_HOME};PATH=$PATH:$ORACLE_HOME/bin;LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib;export ORACLE_HOME PATH LD_LIBRARY_PATH;" ORAENV="ORACLE_HOME=${ORACLE_HOME};PATH=$PATH:$ORACLE_HOME/bin;LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib;export ORACLE_HOME PATH LD_LIBRARY_PATH;"
debug_me "${SSH}"
debug_me "${SQLPLUS}"
echo -e "${SSH}" debug_me "${ORAENV}"
echo -e "${SQLPLUS}" debug_me "${COMMAND}"
echo -e "${ORAENV}"
echo -e "${COMMAND}"
exit 0
## getops ### # CLEANING THE COMMAND
## getops ### COMMAND="${1:2}"
## getops ### ORACLE_SID="$2"
## getops ### [[ ! "${COMMAND}" || ! "${ORACLE_SID}" ]] && print_usage && exit ${STATE_UNKNOWN}
## getops ### if [ $# -eq 3 ] ; then
## getops ### #ospassword check
## getops ### # the values are REVERSE as it use reverse_return_values
## getops ### CRITICAL=$2
## getops ### WARNING=$3
## getops ###
## getops ### if [[ "${WARNING}" && ${CRITICAL} ]] ; then
## getops ### if [[ ${CRITICAL} -gt ${WARNING} ]] ; then
## getops ### echo "UNKNOWN - ${COMMAND} CRITICAL level is bigger than WARNING (reverse check)"
## getops ### exit $STATE_UNKNOWN
## getops ### fi
## getops ### fi
## getops ### else
## getops ### if [ $# -eq 4 ] ; then
## getops ### CRITICAL=$3
## getops ### WARNING=$4
## getops ### elif [ $# -eq 5 ] ; then
## getops ### TSDG=$3
## getops ### CRITICAL=$4
## getops ### WARNING=$5
## getops ### fi
## getops ### if [[ "${WARNING}" && ${CRITICAL} ]] ; then
## getops ### if [[ ${WARNING} -gt ${CRITICAL} ]] ; then
## getops ### echo "UNKNOWN - ${COMMAND} Warning level is less than Critical"
## getops ### exit $STATE_UNKNOWN
## getops ### fi
## getops ### fi
## getops ###
## getops ### fi
## getops ### # if the check is not for asmfs, then a ORACLE_HOME is necessary
## getops ### if ! [[ "${COMMAND}" = "asmfs" || "${COMMAND}" = "ospassword" ]] ; then
## getops ### get_remote_oraclehome
## getops ### RES=$?
## getops ### if [ ${RES} -ne ${STATE_OK} ] ; then
## getops ### echo "CRITICAL - No ORACLE_HOME found"
## getops ### exit $STATE_UNKNOWN
## getops ### fi
## getops ### #
## getops ### fi
## getops ### # SQLPLUS FOR CONNECTIONS
## getops ### SQLPLUS="sqlplus -s '${ORACLEUSER}/${ORACLEUSERPASSWORD}@${ORACLE_SID}'"
## getops ### ORAENV="ORACLE_HOME=${ORACLE_HOME};PATH=$PATH:$ORACLE_HOME/bin;LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib;export ORACLE_HOME PATH LD_LIBRARY_PATH;"
case "${COMMAND}" in case "${COMMAND}" in