2

I'm going to be running an Ubuntu 14.04 LTS server that will have a few Garry's Mod (Half-life 2/Source based) servers running on it. I don't want any one of those servers getting out of line by taking up too much RAM or CPU. If any server uses over 1 gig of RAM or 100% of 1 CPU core, I'd like it to automatically restart. In addition to this, is there a way to automatically restart each of these applications daily, say at 12 am?

I'm very new to bash scripting and know little, but if someone could atleast point me in the right direction that would be greatly appreciated.

1 Answer 1

5

Have monit keep an eye on those daemons:

Monit is a small utility for managing and monitoring Unix systems. Monit conducts automatic maintenance and repair and can execute meaningful causal actions in error situations.

For example, apache is using too much resources. Monit can stop or restart apache and send you an alert message [...]

The configuration files make it easy to express what you want in a natural way. For example you can do something like:

check process spamd with pidfile /var/run/spamd.pid
   group mail
   start program = "/etc/init.d/spamd start"
   stop  program = "/etc/init.d/spamd stop"
   if 5 restarts within 5 cycles then timeout
   if cpu usage > 99% for 5 cycles then restart
   if mem usage > 99% for 5 cycles then restart

To install:

$ sudo apt-get install monit
1
  • I'm guessing the memory has to be in a percentage and also that the cpu is one core? If it was a percentage and I had 4 gig of ram, I could just say 25%. I have a 4 core machine and I want application to restart if they use 100% of one core.
    – Jake
    Nov 25, 2014 at 5:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .