Posts

Showing posts from 2017

Script to find memory usage on Ubuntu

This simple script will show the total memory, free memory and percentage of memory used. Have tested it on Ubuntu 14/16 but will work on CentOS as well #!/bin/bash freemem=$(($(free -m |grep "buffers/cache:"|awk '{print $4}'))) totalmem=$(($(free -m |awk 'NR==2 {print $2}'))) usage=$(($totalmem-$freemem)) echo "Memory used: $usage" echo "Total memory: $totalmem" usage=$(($usage*100 / $totalmem)) echo "Usage percentage: $usage" echo "Free memory: $freemem" echo "$TIMESTAMP $totalmem $usage $freemem"