#!/bin/ksh
# This is the Linux
version
# First, we must set the
environment . . . .
ORACLE_SID=edm1
export ORACLE_SID
ORACLE_HOME=`cat /etc/oratab|grep
\^$ORACLE_SID:|cut
-f2 -d':'`
export ORACLE_HOME
ORACLE_HOME=/usr/app/oracle/admin/product/8/1/6
export ORACLE_HOME
PATH=$ORACLE_HOME/bin:$PATH
export PATH
MON=`echo
~oracle/mon`
export
MON
SERVER_NAME=`uname -a|awk
'{print $2}'`
typeset -u SERVER_NAME
export SERVER_NAME
# sample every five
minutes (300 seconds) . . . .
SAMPLE_TIME=300
while true
do
vmstat
${SAMPLE_TIME} 2 > /tmp/msg$$
# run vmstat and direct
the output into the Oracle table . . .
cat /tmp/msg$$|sed 1,3d |
awk '{ printf("%s %s %s %s %s %s\n",
$1, $8, $9, $14, $15, $16) }' | while read
RUNQUE PAGE_IN PAGE_OUT USER_CPU SYSTEM_CPU
IDLE_CPU
do
$ORACLE_HOME/bin/sqlplus -s
system/manager@testb1<<EOF
insert into sys.mon_vmstats
values (
sysdate,
$SAMPLE_TIME,
'$SERVER_NAME',
$RUNQUE,
$PAGE_IN,
$PAGE_OUT,
$USER_CPU,
$SYSTEM_CPU,
$IDLE_CPU,
0
);
EXIT
EOF
done
done
rm /tmp/msg$$
This daemon collects server
performance information every five minutes (300
seconds) and stores the server data inside
Oracle tables. These Oracle vmstat tables, once
populated, can give interesting details about
the server. For example, one can find out usage
information about how much
RAM and disk I/O is being used
on the database server, as well as how many CPUs
are being used.
When analyzing vmstat
output, there are several metrics to which the
DBA should pay attention. For example, keep an
eye on the CPU run queue column. The run queue
should never exceed the number of CPUs on the
server. If it is noticed that the run queue
starts exceeding the amount of CPUs, it is a
good indication that the server has a CPU
bottleneck.