Linux Memory Calculation


free -m => FALSE

Formula :

(used-buffers-cached)/total * 100%

#!/bin/bash
 free -m | grep "Mem:" | cut -f2 -d:|sed 's/\([0-9]\) /\1\,/g' | sed -e 's/[\t ]//g;/^$/d' | while read array; do \
 used=`echo $array | cut -d',' -f2`
 buffers=`echo $array | cut -d',' -f5`
 cached=`echo $array | cut -d',' -f6`
 total=`echo $array | cut -d',' -f1`
 HASIL=`echo - | awk '{ print '$((used-buffers-cached))'/'$total'}'`
 echo `printf "Usage Memory = %.2f" $HASIL`"%";
 done

by moses

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

shisdew

Listens until think alike

moses.spaceku@yahoo.com / voip ipbx

Hosted PBX, IP-PBX SOHO/ CALL CENTER, VOICE GATEWAY, VOICE CARD, COST EFECTIVE SOLUTIONS (LCR), GSM/CDMA GATEWAY

%d bloggers like this: