Register
It is currently Fri Sep 19, 2014 11:52 pm

List RAM use in MB for a PID


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Fri Oct 20, 2006 11:32 am   
Site Admin

Joined: Tue May 17, 2005 7:31 pm
Posts: 251
Location: Georgia
#!/bin/bash
# you would call this like
# get_node_ram.sh 1234

pid="${1}"


totalRam=`cat /proc/meminfo | grep MemTotal | cut -d":" -f2 | /
sed 's# ##g' | sed 's#[a-zA-Z]*##g'`

measured=`cat /proc/meminfo | grep MemTotal | cut -d":" -f2 | /
sed 's# ##g' | sed 's#[0-9]*##g'`

case $measured in

mB) div=1;
;;
kB) div=1024;
;;
B) div=1048576;
;;
*) echo "Error";
exit
;;
esac

cur_per=`ps -p ${pid} -o pmem | tail -1`
amount=`echo -e "scale=2\n(${totalRam}/100*${cur_per})/${div}" | bc`
echo ${amount} MB


Top
 Profile  
 PostPosted: Fri Oct 20, 2006 12:11 pm   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 667
Location: Des Moines, Iowa
VERY cool :)


Top
 Profile WWW  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP