Tuesday, September 20, 2011

script to monitor a particular process & memory usage

#!/bin/bash



while [ 1 ]; do
   export phpcount=`ps -ef|grep php-cgi|wc| awk '{print $1}'`
   memtotal=`free | awk '/Mem/ { print }' | awk '{ print $2 }'`
   memused=`free | awk '/Mem/ { print }' | awk '{ print $3 }'`
   memfree=`free | awk '/Mem/ { print }' | awk '{ print $4 }'`
   echo "there are $phpcount php-cgi processes at `date` mem $memtotal used $memused free $memfree"
   #free
   sleep 2
done

No comments:

Post a Comment