Search This Blog

Showing posts with label Grid Control. Show all posts
Showing posts with label Grid Control. Show all posts

Friday, 19 October 2012

Create a UDM in Oracle Grid Control

The Oracle Grid Control provides us very powerful functionaly to create a User-Defined Metrics (UDM) that we can use to collect any additional information from any target host and build statistics graphs based on this data. I will decribe bellow an example how to create a UDM to be able to gather memory usage on the host.
Preparing a scrip/command to get the "used" column of the Linux "free" command.
mkdir /tmp/test.sh
chmod a+x /tmp/test.sh
add the following command to the /tmp/test.sh
/usr/bin/free | grep Mem | awk '{ print $3 }' | awk 'END {print line} { line = line "em_result=" $0 }'
The script will return the value for em_result variable like this:
em_result=32830100
Create a new GC UDM for the host where you placed the script.
Metric Name Memory_Used
Command Line: /bin/ksh /tmp/test.sh
Start: Immediately after creation
Frequency: Repeat every 5 mins(for example).
The GC will be gather this data like all other metrics and it will be possible create Chart from SQL based on this data.
The SQL statement that can be used to get data to build "Chart from SQL" graphs:
select decode(column_label,'Memory_Used','Memory Used (MB)'),COLLECTION_TIMESTAMP, value
from mgmt$metric_details
where target_type = 'host'
and target_name='hostname'
and column_label = 'Memory_Used' and METRIC_TYPE=0
AND COLLECTION_TIMESTAMP >= ??EMIP_BIND_START_DATE??
AND COLLECTION_TIMESTAMP <= ??EMIP_BIND_END_DATE??
order by COLLECTION_TIMESTAMP

Saturday, 13 October 2012

Monitoring OMS status

Sometimes it is very useful to have the monitoring for Oracle Grid Control status. Here is the way how to setup daily checks for OMS status to be sure either it  running or not.

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.