I have a Debian server where some processes going rogue from time to time and start consuming too much memory. How I could monitor this at process level so I can set an alarm? Currently I monitor when the server starts using too much memory but I would like to monitor the process individually.

link|improve this question
What monitoring system are you using? – SvenW May 4 '11 at 8:26
I am using zabbix. – Eric L. May 4 '11 at 8:42
feedback

3 Answers

up vote 1 down vote accepted

This is how I monitor the total RAM used by apache:

ps -e -orss=,args= | awk '/apache/{ SUM += $1} END { print SUM }'

Just change apache to your process.

link|improve this answer
is that the RAM used currently or the RAM that has been used while the process has been runnning? Thanks! – Eric L. May 4 '11 at 11:15
Currently used. – Bart De Vos May 4 '11 at 12:13
feedback

You could try using monit

link|improve this answer
I do not see how monit solves my problem. – Eric L. May 4 '11 at 8:47
3  
Monit solve it easily : mmonit.com/monit/documentation/monit.html#resource_testing Here example how I monitor memory of my tomcat processes and if something get wrong send an alarm and run set of scripts that take number of snapshot of running services before restart service: check process tomcat6 with pidfile /var/run/tomcat6.pid if cpu > 80% for 5 cycles then alert if totalmem > 7 GB for 2 cycles then alert else if succeeded for 5 cycles then alert if totalmem > 7 GB for 2 cycles then exec "/usr/local/bin/asset4/jvm_mon.sh" – Ruslan May 4 '11 at 10:00
Thanks! I did not know it and it looks interesting. – Eric L. May 4 '11 at 11:16
+1 for monit. As Ruslan explained, it can not only alert on the failure mode, but it can be given instructions on how to remedy the problem (which is normally a case of restarting the service) – Daniel Lawson May 29 '11 at 23:32
feedback

Use Nagios and it's "check_procs" plugin with the RSS-metric parameter:

 -r, --rss=RSS
  Only scan for processes with RSS higher than indicated.

E.g.:

"check_procs -w 1500000 -c 2000000 --metric=RSS"

Alter w & c to fit your warning- and critical-levels for the misbehaving process.

To see the current RSS use this one-liner and check the proc its RSS in the third column:

ps -eo pid,ppid,rss,size,vsize,sz,pmem,comm
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.