Hoping theres something already out there like this.
I have a list of proccesses who's "ps -elf" (field 10) values I need to continuously monitor and if the values of field 10 start to signiciantly increase (double, triple) then do something. The field 10 is the "memory size" field.
#!/bin/bash
while true
do
while read pid mem
do
[ -z "${orig[pid]}" ] && orig[pid]=$mem
if [ $((orig[pid]*2)) -lt $mem ]
then
echo "$pid has grown from ${orig[pid]} to $mem"
fi
done < <(ps -elf | awk '/[p]rocess1|[p]rocess2|[p]rocess3/{print $4 " " $10}')
sleep 5
done
Things to think about:
process ends - should really be removed from orig array, this one isn't a big deal.
the above script by Chubler_XL works great. The only issue is that the process names (process1, process2, process3) are not always very unique, and often just using the unique part of the name will reference multiple processes. I'd rather generate up a list of PIDs and then use this list for monitoring. I'm trying to figure out a way to do this based on just the PID
Also,
If there is an Solaris OS utility for this type of monitoring please let me know.
Thank you all so much!