Sunday, 19 February 2012

Thread Contentions

Free Memory in Linux

Actual Free Memory in Linux = Free+ Buffer+Cache

Linux uses RAM to load the Disk data in RAM (emory) as reading data from memory is faster. As the needs for memory to other process increases it shrinks the cahced data accordingly.

http://blog.scoutapp.com/articles/2010/10/06/determining-free-memory-on-linux

Saturday, 11 February 2012

calculate avg and 90th percentile from awk command



Average:
cat <filename> |grep HOME|grep "Number of samples"|awk -F "," '{sum+=$2} END { print "Average = ",sum/NR}'


95th Percentile:
cat <filename> |grep HOME|grep "Number of samples"|awk -F "," '{print $2}' |sort -n|awk 'BEGIN{i=0} {s[i]=$1; i++;} END{print s[int(NR*0.95-0.5)]}'

Friday, 10 February 2012

calculate avg of a column


awk '{ s += $1 } END { print "sum: ", s, " average: ", s/NR, " samples: ", NR }' rails_production_log_or_whatever.log

Friday, 3 February 2012

AWk command to cut a big file into small files at a repeatative word

awk '/selected./{n++}{print >"out" n ".txt" }' partitionbased_cc_acc_ids.txt

here "selected." is the repeatative word..