1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
|
###########################################
###########################################
###########################################
#! /bin/sh
SIDDB1=MONRAC1
SIDDB2=MONRAC2
SIDSTANDBY=MA_STANDBY
ARCHIVEDEST=2
STATE_OK=0
STATE_CRITICAL=2
CHECK_TNSPING ()
{
tnschk=` tnsping $1`
tnschk2=` echo $tnschk | grep -c OK`
if [ ${tnschk2} -eq 1 ] ; then
tnschk3=` echo $tnschk | sed -e 's/.*(//' -e 's/).*//'`
echo "OK - reply time ${tnschk3} from $1 OK |status=0"
exit $STATE_OK
else
echo "No TNS Listener on $1 KO|status=1"
exit $STATE_CRITICAL
fi
}
CHECK_ARCHIVEDEST ()
{
SID=$1
ARCHIVE_DEST=$2
res=`sqlplus -S "system/xxx@$SID" <<EOL
SET NEWPAGE 0
SET SPACE 0
SET LINESIZE 130
SET PAGESIZE 0
SET ECHO OFF
SET FEEDBACK OFF
SET VERIFY OFF
SET HEADING OFF
SET MARKUP HTML OFF SPOOL OFF
select status from v\\$archive_dest where dest_id = $ARCHIVE_DEST;
EOL
`
if [ $res != 'VALID' ] ; then
echo "Archive dest N°:$ARCHIVE_DEST sur $SID KO|status=1"
exit $STATE_CRITICAL
else
echo "Archive dest N°:$ARCHIVE_DEST sur $SID OK|status=0"
exit $STATE_OK
fi
}
CHECK_ERROR () {
SID=$1
res=`sqlplus -S "sys/xxx@$SID as sysdba" <<EOL
SET NEWPAGE 0
SET SPACE 0
SET LINESIZE 130
SET PAGESIZE 0
SET ECHO OFF
SET FEEDBACK OFF
SET VERIFY OFF
SET HEADING OFF
SET MARKUP HTML OFF SPOOL OFF
rem select count(*) from v\\$dataguard_status where severity in ('Error','Fatal') and timestamp > (sysdate -1);
select count(*) from v\\$dataguard_status where severity in ('Fatal') and timestamp > (sysdate -1);
EOL
`
if [ -z "$res" ] ; then
echo "Check ERROR - KO"
exit $STATE_CRITICAL
else
if [ $res -ne 0 ] ; then
echo "Error dans dataguard_status KO|status=1"
exit $STATE_CRITICAL
else
echo "Check ERROR OK|status=0"
exit $STATE_OK
fi
fi
}
CHECK_APPLY () {
SID=$1
res=`sqlplus -S "sys/xxx@$SID as sysdba" <<EOL
SET NEWPAGE 0
SET SPACE 0
SET LINESIZE 130
SET PAGESIZE 0
SET ECHO OFF
SET FEEDBACK OFF
SET VERIFY OFF
SET HEADING OFF
SET MARKUP HTML OFF SPOOL OFF
select count(*) from v\\$managed_standby where process like 'MRP%';
EOL
`
if [ -z "$res" ] ; then
echo "Check APPY KO|status=1"
exit $STATE_CRITICAL
else
if [ $res -eq 0 ] ; then
echo "Pas de MRP KO|status=1"
exit $STATE_CRITICAL
else
echo "Check APPLY OK|status=0"
exit $STATE_OK
fi
fi
}
CHECK_GAP ()
{
SID=$1
res=`sqlplus -S "sys/xxx@$SID as sysdba" <<EOL
SET NEWPAGE 0
SET SPACE 0
SET LINESIZE 130
SET PAGESIZE 0
SET ECHO OFF
SET FEEDBACK OFF
SET VERIFY OFF
SET HEADING OFF
SET MARKUP HTML OFF SPOOL OFF
select count(*) from v\\$archive_gap;
EOL
`
if [ -z "$res" ]; then
echo "Check GAP KO|status=1"
exit $STATE_CRITICAL
else
if [ $res -ne 0 ]; then
echo "Il existe $res GAP KO|status=1"
exit $STATE_CRITICAL
else
echo "Check GAP OK|status=0"
exit $STATE_OK
fi
fi
}
for sid in $SIDDB1 $SIDDB2 $SIDSTANDBY
do
res=`CHECK_TNSPING $sid`
if [ $? -ne 0 ] ; then
echo $res
exit $STATE_CRITICAL
fi
done
res=`CHECK_ARCHIVEDEST $SIDDB1 $ARCHIVEDEST`
if [ $? -ne 0 ] ; then
echo $res
exit $STATE_CRITICAL
fi
res=`CHECK_ARCHIVEDEST $SIDDB2 $ARCHIVEDEST`
if [ $? -ne 0 ] ; then
echo $res
exit $STATE_CRITICAL
fi
res=`CHECK_APPLY $SIDSTANDBY`
if [ $? -ne 0 ] ; then
echo $res
exit $STATE_CRITICAL
fi
res=`CHECK_ERROR $SIDSTANDBY`
if [ $? -ne 0 ] ; then
echo $res
exit $STATE_CRITICAL
fi
echo "check_nic_oracle_phycalstandby.sh OK|status=0"
exit $STATE_OK
###########################################
###########################################
########################################### |