Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Processes

252852Nov 19 2007
After Every 4 minutes To Find out the % of cpu using by 10 top Oracle processs
When it run first time only get information for P1 and P2 For top 10 Oracle processes and store some where
and Run again 2nd time after 4 minutes. If in 2nd time it find old Pid with Threshold P1 and P2 then show
on screen or store in a varible.
If CPU useage is between 80%-89.99% Then It Generate the P2 Message
If cpu useage is 90% and Up then it generates P1 message


$ /usr/ucb/ps -auxw | head | grep oracle

process PID CPU%
oracle 14248 7.0 4.9862512790568 ? S 14:25:56 25:04 oracleXEYEist2 (LOCAL=NO)
oracle 27975 0.8 4.6836984737048 ? S Oct 26 8:59 ora_dbw0_XEYEist2
oracle 24448 11.6 4.7826736748184 ? S 15:00:53 0:01 ora_j000_XEYEist
oracle 27977 0.4 4.6840920729880 ? S Oct 26 6:26 ora_lgwr_XEYEist2
oracle 23376 10.1 4.7825504743624 ? S 14:57:42 0:01 ora_q000_XEYEdev2

In above example cpu% will be multiply by number of proceessors.

We have to calculte total no of CPU
num_cpu=`/usr/sbin/psrinfo |wc -l`
echo num_cpu = 8
so we will multiply every cpu by 8 that will be our threshold
10.00*8=80.0% (P2 Threshold )
0.80*8=7.2% (not in Threshold Limit)
11.6*8=92.8% (P1 Threshold)
0.40*8=3.20% (not in Threshold Limit)
10.1*8=80.8 (P2 Threshold)

First Time Ignore this threshold Message
and sleep for 4 minute and run again. If find same threshold P1 or P2 for same PID
Then show on the screen that
Pid 24448 Threshold P1
Pid 23376 Threshold P2
and continue to run After every Four Minites

What I did

#! /usr/bin/ksh
#
#Oracle Process CPU %
typeset -i usage
typeset -i thres
typeset -i maj_threshold
typeset -i cric_threshold
typeset -i num_cpu
user=oracle
maj_threshold=80
cric_threshold=90
num_cpu=`/usr/sbin/psrinfo |wc -l`
/usr/ucb/ps -auxw |head|grep $user|awk '{print $2 " " $3}'|while read UID usage
do
(( thres = $usage * $num_cpu ))
if (( $thres >= $maj_threshold )) && (( $thres < $cric_threshold ))
then
echo "user $user Pid $UID is $thres %, major threshold %"
elif (( $thres >= $cric_threshold ))
then
echo "user $user Pid $UID is $thres %, critical threshold %"
fi
done


*****Issues********

In this scrip it is not calculating decimal places
Thres=$usage*$num_cpu
Thres=10.5*8=80
Out put is 80 that should be 84

Other isse is that Script is only calculating First Time all Top 10 Oracle Proceesses and Showing P1 and p2
But i dont know How to run after 4 minutes and To check the Previous 10 Oracle Pid with current Pid and show
I need total solution because i am not a good script writer.

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Dec 17 2007
Added on Nov 19 2007
0 comments
223 views