-
Notifications
You must be signed in to change notification settings - Fork 0
/
\
24 lines (20 loc) · 1003 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
#!/bin/bash
strMemTotal=$(cat /proc/meminfo | grep 'MemTotal:')
strMemFree=$(cat /proc/meminfo | grep 'MemFree:')
strMemBuffers=$(cat /proc/meminfo | grep 'Buffers:')
strMemCache=$(cat /proc/meminfo | grep 'Cached:')
strMemAvailable=$(cat /proc/meminfo | grep 'MemAvailable:')
strSwapFree=$(cat /proc/meminfo | grep 'SwapFree:')
outputMemTotal="${strMemTotal//MemTotal:}"
outputMemFree="${strMemFree//MemFree:}"
outputMemBuffers="${strMemBuffers//Buffers:}"
outputMemCache="${strMemCache//Cached:}"
outputMemAvailable="${strMemAvailable//MemAvailable:}"
outputSwapFree="${strSwapFree//SwapFree:}"
MemTotal=$(( ${outputMemTotal::-3} / 1024))
MemUsed=$(( ( ${outputMemTotal::-3} - ${outputMemFree::-3} - ${outputMemBuffers::-3} - ${outputMemCache::-24} ) / 1024))
MemAvailable=$(( ${outputMemAvailable::-3} / 1024))
SwapFree=$(( ${outputSwapFree::-3} / 102400))
SwapFreeGb=$(( ${SwapFree::2} ))
SwapFreeMb=$(( ${SwapFree::-1} ))
echo $MemTotal Mb / $MemUsed Mb / $MemAvailable Mb '('$SwapFreeGb Gb')'