How to monitor Linux server memory usage by using
vmstat?
During performance testing monitoring, we are supposed to check how memory is being utilized for your Linux server, but how?
If you can use simple vmstat (have a look at attached SS). You may not get accurate used memory utilization, if you use vmstat –s will facilities this need but we need to iterate this to get memory usage during entire tenure of your performance tests.
Below small shell script will print the used memory along with time stamp.
for i in {1..120}
do
vmstat -s | sed "s/$/$(date)/" | awk '/used memory/'
sleep 30
done
Note: this will take the reading for every 30 seconds and for 120 times.
If you want to print the output into a file use the below command.
./sampleloop.sh > UsedMemory1.txt
Where sampleloop.sh is your shell script name (copy past the above code in the file named as sampleloop.sh) and UsedMemory1.txt is the text file where you want to print the output.
Sample Output:
1674660 used memoryWed Jun 18 09:52:46 UTC 2014
1504104 used memoryWed Jun 18 09:53:16 UTC 2014
1623140 used memoryWed Jun 18 09:53:46 UTC 2014
1675956 used memoryWed Jun 18 09:54:16 UTC 2014
1675624 used memoryWed Jun 18 09:54:46 UTC 2014
1591800 used memoryWed Jun 18 09:55:16 UTC 2014
1676364 used memoryWed Jun 18 09:55:46 UTC 2014
1685188 used memoryWed Jun 18 09:56:16 UTC 2014
1558236 used memoryWed Jun 18 09:56:46 UTC 2014
1674660 used memoryWed Jun 18 09:52:46 UTC 2014
1504104 used memoryWed Jun 18 09:53:16 UTC 2014
1623140 used memoryWed Jun 18 09:53:46 UTC 2014
1675956 used memoryWed Jun 18 09:54:16 UTC 2014
1675624 used memoryWed Jun 18 09:54:46 UTC 2014
1591800 used memoryWed Jun 18 09:55:16 UTC 2014
1676364 used memoryWed Jun 18 09:55:46 UTC 2014
1685188 used memoryWed Jun 18 09:56:16 UTC 2014
1558236 used memoryWed Jun 18 09:56:46 UTC 2014
No comments:
Post a Comment