forked from 9652040795/aws-policies
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathec2-health.sh.txt
More file actions
32 lines (18 loc) · 813 Bytes
/
Copy pathec2-health.sh.txt
File metadata and controls
32 lines (18 loc) · 813 Bytes
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
#!/bin/bash
# Purpose: Check the System Health, CPU Utilization & take actions accordingly
# Maintainer: Muhammad Asim@cloudelligent.com
# nproc command basically displays in output the number of available processing units
cores=`nproc`
# Last 15 min Load avarage on System
load=`awk '{print $3}'< /proc/loadavg`
echo " "
# Relative Load on System
# The correlation between Relative CPU utilization (x-axis) and Absolute CPU utilization (y-axis)
echo | awk -v c="${cores}" -v l="${load}" '{print "Relative load on EC2 instance is " l*100/c "%"}'
# Actions
usage=$(echo | awk -v c="${cores}" -v l="${load}" '{print l*100/c}' | awk -F. '{print $1}')
if [[ ${usage} -ge 80 ]]; then
echo -e "\nCloudelligent Internal Infra is restarting\n"
shutdown -r now
fi
# END