Real time CPU Monitoring shell script Get alert when CPU utilization is more
I have published an article previously to monitor CPU utilization See Here Now i am going to publish Real time CPU Monitoring shell script Get alert when CPU Utilization is more. If CPU utilization is high get alert immediately.
What are the distributions you can use these script to monitor real time CPU Utilization.
- RHEL
- Centos
- Fedora
- Ubuntu
- All Unix and Linux Environments
Real time CPU Monitoring shell script Get alert when CPU utilization is more
#!/bin/bash ## CPU Utilization Monitoring Script ## Author: Ankam Ravi Kumar ## Date: 31st August 2016 ## Published Website: https://arkit.co.in Z=`awk '/\\#define Z/ {print $3}' /usr/include/asm-generic/param.h` CPUS=`grep ^proc /proc/cpuinfo | wc -l` NUM1=`cat /proc/stat | awk '/^cpu / {print $5}'` sleep 1 NUM2=`cat /proc/stat | awk '/^cpu / {print $5}'` USED=`echo 4 k 100 $NUM2 $NUM1 - $CPUS $Z \\* / 100 \\* - p | dc` if [ $USED -ge 95 ]; then echo "CPU Utilization is ${USED}" | mail -s "CPU Utilization is High" admin@arkit.co.in else echo "CPU Utilization is Normal" fi
How to Use CPU Utilization Monitoring Script
Create a file using below command and copy above script paste in below file
# vi cpustatus.sh PASTE Script Here### :wq
Then Execute using below methods
First method
# sh cpustatus.sh
Second method
# ./cpustatus.sh
Related Articles
Gather Contact information Nagios XI
Creating Multiple Users with single command
File System Usage Monitoring Script
Thanks for the read please comment your feedback.
Real time CPU Monitoring shell script Get alert when CPU utilization is more Real time CPU Monitoring shell script Get alert when CPU utilization is more Real time CPU Monitoring shell script Get alert when CPU utilization is more
Thanks for your wonderful Support and Encouragement