#!/bin/sh
## Please run by User oinstall.

## ora_perl_report.sh ver =====================================================
## ver 0.01 04.12.22 Creation
## A required environment variable is defined.
source /etc/bashrc

## Required variable is defined.
mailaddress='user@youredomain.co.jp'
MachineId=`hostname`
dbuser=sys
dbpw=dba
tnsname=@testdb
log_file=/tmp/ora_perf_report.lst
script=/tmp/ora_perf_report.sql
##=============================================================================

## BEGIN BLOCK 1.2 : MailOnGood()----------------------------------------------
MailOnGood ()
{
    Today=`date '+%Y/%m/%d'`
    Time=`date '+%T'`
    MailTo=$mailaddress
    echo "===================
$0
$Today
$Time

HostName: $MachineId
Database: ${ORACLE_SID}
===================
$os_message

$message
" | mail -s "ORACLE performance & alert Report[$Today]" $MailTo
}
## ENDBLOCK 1.2----------------------------------------------------------------


## BEGIN BLOCK 2 : ORACLE Status SQL no1 --------------------------------------
CHK=`
sqlplus $dbuser/$dbpw$tnsname as sysdba << Eof 2>&1
    @ $script
    exit
Eof`

message=`/tmp/logfilter.pl $log_file`

## END BLOCK 2 ----------------------------------------------------------------


MailOnGood
exit 0
