This is using SuSE 11 with SP4. Recently, I came across an online article discussed about how to use pmap to display the actual mapping, memory in active/cached and so on.
Please see the full command below,
for i in `ps -eaf | grep “any application process” | grep -v grep | awk '{print $2}'`; do echo -n "PID $i actual memory usage is :" >> totaluse.txt; pmap -d $i | grep -i "writeable/private: " >> totaluse.txt; done
I was ended up with "nothing" when copy and paste the whole command to the terminal. Can I create a bash script? if so, please enlighten how, thanks.
Try this command, which will work on any running machine.
Open in new window
Now break your script into sections + print debug info...
So... get your PID list + print out all the PIDs + command/args.
Then cycle through your PID list printing every pmap command before running the command.
Basic, incremental debugging, will provide enough data to fix your code.
Tip: Also print out information messages, like PID count + a warning each time pmap runs on a PID + returns no result. Be sure to add additional code to test if PID is still alive, when you get no return data from pmap.