Bryan Smith wrote: > Chris, > > Everyone gave great answers, but why reinvent the wheel when there are > awesome packages that will do exactly what you want with a web-interface > as well. Enter monit(apt-get install monit)...it does exactly what is > sounds like it does; monitor daemons. > > Monit will actually attempt to connect to your daemons at a set > interval(1 minute on my system) and lie dormant if there is no alarm. > When monit fails to connect it sends an email that the process is down > and restarts it for you...it also send an email letting you know that > the process is back up. It does ssl as well...this is what you need, it > is a script indeed but has a bit more intelligence than the run of the > mill cronjob. I use it for snmp, ldap, nscd, apache, postfix, blah and > blah blah. This thing is totally customizable and there are tons of > examples out in the wild.
Okay, a quick go at monit produced these configuration directives: ======================================================================== check process mysql with pidfile /var/run/mysqld/mysqld.pid group database start program = "/etc/init.d/mysql start" stop program = "/etc/init.d/mysql stop" if failed host 192.168.1.1 port 3306 protocol mysql then restart if 5 restarts within 5 cycles then timeout depends on mysql_bin depends on mysql_rc check file mysql_bin with path /usr/bin/mysql group database if failed checksum then unmonitor if failed permission 755 then unmonitor if failed uid root then unmonitor if failed gid root then unmonitor check file mysql_rc with path /etc/init.d/mysql group database if failed checksum then unmonitor if failed permission 755 then unmonitor if failed uid root then unmonitor if failed gid root then unmonitor check process proftpd with pidfile /var/run/proftpd.pid start program = "/etc/init.d/proftpd start" stop program = "/etc/init.d/proftpd stop" if failed port 21 protocol ftp then restart if 5 restarts within 5 cycles then timeout check process sshd with pidfile /var/run/sshd.pid start program "/etc/init.d/sshd start" stop program "/etc/init.d/sshd stop" if failed port 22 protocol ssh then restart if 5 restarts within 5 cycles then timeout check process apache with pidfile /var/run/apache2.pid group www start program = "/etc/init.d/apache2 start" stop program = "/etc/init.d/apache2 stop" if failed host 192.168.1.1 port 80 protocol HTTP request / then restart if 5 restarts within 5 cycles then timeout check process sendmail with pidfile /var/run/sendmail.pid group mail start program = "/etc/init.d/sendmail start" stop program = "/etc/init.d/sendmail stop" if failed port 25 protocol smtp then restart if 5 restarts within 5 cycles then timeout check process mongrel_rails with pidfile /opt/redmine/tmp/pids/mongrel.3000.pid start program = "PATH = $PATH:/var/lib/gems/1.8/bin ; mongrel_rails cluster::start -C /opt/redmine/config/mongrel_cluster.yml --clean" stop program = "PATH = $PATH:/var/lib/gems/1.8/bin ; mongrel_rails cluster::stop -C /opt/redmine/config/mongrel_cluster.yml --clean" if 5 restarts within 5 cycles then timeout check process mongrel_rails with pidfile /opt/redmine/tmp/pids/mongrel.3001.pid start program = "PATH = $PATH:/var/lib/gems/1.8/bin ; mongrel_rails cluster::start -C /opt/redmine/config/mongrel_cluster.yml --clean" stop program = "PATH = $PATH:/var/lib/gems/1.8/bin ; mongrel_rails cluster::stop -C /opt/redmine/config/mongrel_cluster.yml --clean" if 5 restarts within 5 cycles then timeout ======================================================================== Obviously that's not the whole configuration, but that's the important part :^) Only time will tell if it's more effective than my current gambit of billions of hourly cron scripts. I'm going to keep a daily script that restarts apache every day, since apache seems to be happier that way. I also was tromping through various things and found that my MySQL server has a 78 day uptime. Let's see how long it can last! -- Registered Linux Addict #431495 http://profile.xfire.com/mrstalinman | John 3:16! http://www.fsdev.net/ | http://lordsauron.wordpress.com/
signature.asc
Description: OpenPGP digital signature
