-
Notifications
You must be signed in to change notification settings - Fork 155
/
check_oracle.ksh
69 lines (51 loc) · 1.32 KB
/
check_oracle.ksh
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
#!/bin/ksh
# Script Name : check_oracle.ksh
# Author : Craig Richards
# Created : 05-Jul-2005
# Last Modified :
# Version :
# Modifications :
# Description : This script checks the pmon and the listener processes are running on the server
#################################
# Start of procedures/functions #
#################################
funct_check_user()
{
if [ `/usr/ucb/whoami` != oracle ]
then echo 'You Must be oracle to execute this script !!!'
exit 99
fi
}
funct_check_params()
{
if [ ${NARG} -ne 1 ]; then
echo "Check Oracle Failed : Not enough Parameters passed" >> $LOGFILE
exit 1
fi
}
funct_check_pmon()
{
check_pmon=`ps -ef | grep ${ORACLE_SID} | grep pmon | wc -l`;
err_log=`tail -100 $ORACLE_BASE/admin/$ORACLE_SID/bdump/alert_$ORACLE_SID.log`
oracle_num=`expr $check_pmon`
echo $err_log > /tmp/db_err_$ORACLE_SID.log
if [ $oracle_num -lt 1 ]
then
mailx -s "PMON Process for $ORACLE_SID - Not Running" [email protected] < /tmp/db_err_$ORACLE_SID.log
exit 0
fi
}
################
# Main Program #
################
# Variable Settings
NARG=$#
# Oracle Environment
ORACLE_SID=$1 ; export ORACLE_SID
ORACLE_BASE=/opt/oracle ; export ORACLE_BASE
{
funct_check_user
funct_check_params
funct_check_pmon
}
## End of Script