-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcloud-RDS.sh
More file actions
39 lines (30 loc) · 1.47 KB
/
cloud-RDS.sh
File metadata and controls
39 lines (30 loc) · 1.47 KB
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
#!/bin/bash
#declare cpuutil=6.99921021
starttime=$(date -d '6 hour ago' +%FT%T)
endtime=$(date +%FT%T)
freeablemem=$(aws cloudwatch get-metric-statistics --metric-name FreeableMemory --start-time $starttime --end-time $endtime --period 3600 --namespace AWS/RDS --statistics Average --dimensions --query Datapoints[0].Average | cut -d . -f 1 )
cpuutil=$(aws cloudwatch get-metric-statistics --metric-name CPUUtilization --start-time $starttime --end-time $endtime --period 3600 --namespace AWS/RDS --statistics Average --dimensions --query Datapoints[0].Average | cut -d . -f 1 )
dbcon=$(aws cloudwatch get-metric-statistics --metric-name DatabaseConnections --start-time $starttime --end-time $endtime --period 3600 --namespace AWS/RDS --statistics Average --dimensions --query Datapoints[0].Average | cut -d . -f 1 )
#echo -e "CPUUtilization:$cpuutil"
#echo -e "DatabaseConnections:$dbcon"
#echo -e "FreeableMemory:$freeablemem"
low=10
output="Load Average: $cpuutil | DatabaseConnections:$dbcon | FreeableMemory:$freeablemem"
if [ "$cpuutil" -le "$low" ]
then
echo "OK- $output"
exit 0
elif [ "$cpuutil" -ge '15' ]
then
echo "WARNING- $output"
exit 1
elif [ "$cpuutil" -ge "30" ]
then
echo "CRITICAL - $output"
exit 2
else
echo 'UNKNOWN - $output'
exit 3
fi