For Linux
Download and install the Mutt E-Mail Client
Prepare a script to check the GC status and then send it by e-mail.
mkdir /tmp/oms_status.sh
chmod a+x /tmp/oms_status.sh
add the following commands to oms_status.sh:
rm /tmp/oms_status.txt
$OMS_HOME/bin/emctl status oms >> /tmp/oms_status.txt
/usr/bin/mutt -s "Grid Control Status" eugene@something.com < /tmp/oms_status.txt
add the crontab task:
#OMS Status
00 2 * * 0-6 /bin/sh /tmp/oms_status.sh
For Windows
Download and install the Blat E-Mail Client http://www.blat.net/
Unpack the archive to the some folder for example C:\Blat
cd C:\Blat
blat.exe -install <server addr> <sender's addr>
Example:
blat.exe -install 10.215.210.71 cwdbops@comsore.com
Prepare a script to check the GC status and then send it by e-mail.
Create a new bat file C:\Blat\oms_status.bat
add the following commands to oms_status.bat
ECHO OFF
call C:\app\Middleware\oms11g\BIN\emctl.bat status oms > oms_status.txt
call C:\Blat\blat.exe oms_status.txt -to eugene@something.com -subject "Grid Control Status" -log oms_status.log
Add the Windows scheduled task to execute the oms_status.bat file periodically.
Some additional scripts
To send the notification only if the GC status different then "Up". It will be useful for hourly check.
For Linux
Create a new bat file:
mkdir /tmp/oms_status_hourly.sh
chmod a+x /tmp/oms_status_hourly.sh
add the following commands to oms_status_hourly.sh:
#!/bin/sh
$OMS_HOME/bin/emctl status oms > /tmp/oms_status_hourly.txt
tmp1="Oracle Management Server is Up."
tmp2=$(sed -e '/^[<blank><tab>]*$/d' /tmp/oms_status_hourly | sed -n -e '$p')
if [ "$tmp1" == "$tmp2" ];
then
printf "Success"
else
/usr/bin/mutt -s "Grid Control Status" eugene@something.com < /tmp/oms_status_hourly.txt
fi
add the crontab task:
#OMS Status
00 */1 * * 0-6 /bin/sh /tmp/oms_status_hourly.sh
For Windows
Create a new bat file C:\Blat\oms_status_hourly.bat
add the following commands:
@echo OFF
call C:\app\Middleware\oms11g\BIN\emctl.bat status oms > gc_status_hourly.txt
@find /c /i "Oracle Management Server is Up" "gc_status_hourly.txt" > NUL
if %ERRORLEVEL% EQU 0 (
@echo Success
) else (
call C:\app\DBOPS\blat.exe gc_status_hourly -to eugene@something.com -subject "Grid Control Status" -log gc_status_hourly.log
)
Add the Windows scheduled task to execute the oms_status_hourly.bat file each hour.
No comments:
Post a Comment