Hello Everyone,
The below script will help us to find number of processes runs in the background and send us alerts based on warning and critical thresholds.
Script :
# ]$ cat /home/oracle/DBA/bin/running_process.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#!/bin/bash # Syntax to run this script # ./running_process.sh oracle 100 170 # ./running_process.sh PROCESS_NAME WARNING CRITICAL export MAILIST='ajaykumar@ktexperts.com, process_name=$1 _limit1=$2 _limit2=$3 _proc=`ps -ef | grep $process_name | wc -l` if [ "$_proc" -ge "$_limit2" ] then echo "Current Running $process_name Proccess is running too high $_proc " > /tmp/proc.log cat /tmp/proc.log cat /tmp/proc.log | mailx -s "${TODAY} - Current Running $process_name Proccess is running too high/Critical $_proc " ${MAILIST} else if [ "$_proc" -ge "$_limit1" ] then echo "Current Running $process_name Proccess is running more than expected $_proc " > /tmp/proc.log cat /tmp/proc.log cat /tmp/proc.log | mailx -s "${TODAY} - Current Running $process_name Proccess is running more than expected $_proc " ${MAILIST} fi fi |
Script execution :
Syntax : ./running_process.sh <PROCESS_NAME> <WARNING> <CRITICAL>
Here I have executed by specifying java process with warning threshold 8 and critical 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
[oracle@oracl12 ~]$ sh -x /home/oracle/DBA/bin/running_process.sh java 8 15 + export MAILIST=ajaykumar@ktexperts.com + MAILIST=ajaykumar@ktexperts.com, + process_name=java + _limit1=8 + _limit2=15 ++ ps -ef ++ grep java ++ wc -l + _proc=10 + '[' 10 -ge 15 ']' + '[' 10 -ge 8 ']' + echo 'Current Running java Proccess is running more than expected 10 ' + cat /tmp/proc.log Current Running java Proccess is running more than expected 10 + cat /tmp/proc.log + mailx -s ' - Current Running java Proccess is running more than expected 10 ' ajaykumar.@ktexperts.com |
In above script output total 10 java processes are running and it sends us warning alerts. It will help us preventing DB crash.
Thank you for giving your valuable time to read the above information. Please click here to subscribe for further updates
KTEXPERTS is always active on below social media platforms.
Facebook : https://www.facebook.com/ktexperts/
LinkedIn : https://www.linkedin.com/company/ktexperts/
Twitter : https://twitter.com/ktexpertsadmin
YouTube : https://www.youtube.com/c/ktexperts
Instagram : https://www.instagram.com/knowledgesharingplatform