1

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.

Bart De Vos
  • 17,911
  • 6
  • 63
  • 82
Eric L.
  • 13
  • 2

3 Answers3

1

You could try using monit

AlexD
  • 8,747
  • 2
  • 29
  • 38
  • I do not see how monit solves my problem. – Eric L. May 04 '11 at 08:47
  • 3
    Monit solve it easily : http://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 04 '11 at 10:00
  • Thanks! I did not know it and it looks interesting. – Eric L. May 04 '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
1

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
Henk
  • 1,331
  • 11
  • 24
1

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.

Bart De Vos
  • 17,911
  • 6
  • 63
  • 82