I just want to know how to find the memory consumption of a particular process for particular time(say 5 seconds)
I am new to linux. So, detailed steps of doing that will be appreciated
you may use SNMP to get the memory and cpu usage of a process in a particular device in network :)
Requirements:
Notes:
HOST-RESOURCES-MIB::hrSWRunPerfCPU is the number of centi-seconds of the total system's CPU resources consumed by this process. Note that on a multi-processor system, this value may increment by more than one centi-second in one centi-second of real (wall clock) time.
HOST-RESOURCES-MIB::hrSWRunPerfMem is the total amount of real system memory allocated to this process.
**
Process monitoring script:
**
echo "IP: "
read ip
echo "specfiy pid: "
read pid
echo "interval in seconds:"
read interval
while [ 1 ]
do
date
snmpget -v2c -c public $ip HOST-RESOURCES-MIB::hrSWRunPerfCPU.$pid
snmpget -v2c -c public $ip HOST-RESOURCES-MIB::hrSWRunPerfMem.$pid
sleep $interval;
done
use watch to periodically execute your script. here is an example:
watch 'cat /proc/status' --interval=5
watch 'ps aux' --interval=5
This previously posted question:
How to measure actual memory usage of an application or process?
seems like it may thoroughly address your question.
edit: My personal favorite Linux utility for checking the resource usage of processes is top, though it can be misleading for reasons that are explained in the question I linked.
free
-d is often still (internally) allocated by the system (because it will be re-used and given back at some latermalloc
). You may want to usevalgrind
– Basile Starynkevitch