-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathnagios-centos7-ram-plugin
55 lines (32 loc) · 1.06 KB
/
nagios-centos7-ram-plugin
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
#Aurthor:Muhammad Asim
#Date:14-Mar-18
TOTALRAM=`free -m | awk '{print $2}' | sed -n 2p`
#TR=`free -m | awk '{print $2}' | sed -n 2p | cut -c1-2`
#AVAILABLERAM=`free -m | awk '{print $7}' | cut -c1-3`
AR=`free -m | awk '{print $7}' | sed -n 2p`
#USEDRAM=`echo $TOTALRAM - $AVAILABLERAM | bc` In Ubuntu you might need this
USEDRAM=`free -m | awk '{print $3}' | sed -n 2p`
#USEDRAMNODEC=`free -m | awk '{print $3}' | cut -c1 | sed -n 2p`
GIGA="G"
MB="MB"
#echo -e "\nTotal RAM is $TOTALRAM$MB\n"
#echo -e "\nAvailable RAM is"$AVAILABLERAM$MB"\n"
#echo -e "\nUsed RAM is $USEDRAM$MB\n"
if [ "$AR" -ge "2048" ]
then
echo "Ok - Available RAM is "$AR""$MB" out of Total "$TOTALRAM""$MB""
exit 0
elif [ "$AR" -gt "1500" ]
then
echo "WARNING - Available RAM is "$AR""$MB" out of Total "$TOTALRAM""$MB""
exit 1
elif [ "$AR" -lt "1024" ]
then
echo "Critical - Available RAM is "$AR""$MB" out of Total "$TOTALRAM""$MB""
exit 2
else
echo "UNKNOWN Centos-7 RAM Settings, please adjust numbers with according to your Host"
exit 3
fi
#END