[mythtv-users] heartbeat for mythbackend?
Richard Freeman
r-mythtv at thefreemanclan.net
Sun Aug 20 21:46:48 UTC 2006
Jan Johansson wrote:
> ( I was hoping to find something that would help me plug it into monit, but
> this works as well )
>
Hmm - I never thought to set something like that up but looking into
monit it seems like it would be handy. I tweaked the config files and
this seems to work:
check process mysqld with pidfile /var/run/mysqld/mysqld.pid
start program = "/etc/init.d/mysql start"
stop program = "/etc/init.d/mysql stop"
# if failed host localhost port 6329 proto mysql then restart
if cpu is greater than 60% for 2 cycles then alert
if cpu > 80% for 15 cycles then restart
if totalmem > 300.0 MB for 5 cycles then restart
if children > 250 then restart
if loadavg(5min) greater than 10 for 8 cycles then stop
if 3 restarts within 5 cycles then timeout
group server
check process mythbackend with pidfile /var/run/mythbackend.pid
start program = "/etc/init.d/mythbackend start"
stop program = "/etc/init.d/mythbackend stop"
if failed host localhost port 6544 proto http then restart
if cpu is greater than 60% for 2 cycles then alert
if cpu > 80% for 15 cycles then restart
if totalmem > 300.0 MB for 5 cycles then restart
if children > 250 then restart
if loadavg(5min) greater than 10 for 8 cycles then stop
if 3 restarts within 5 cycles then timeout
depends on mysqld
group server
You'll probably need to edit the init.d references and the pid
references for your distro. I included mysqld since more often than not
this is the process that goes down, and in theory this will restart the
backend if mysql goes down. The documentation for monit suggested that
it knows how to talk to mysql, but perhaps this isn't in the version I'm
using, so I commented this out. Also, note that this hasn't been
extensively tested other than to see that it does in fact work in the
case where the various backends are up. In particular, if a process
dies your distro might complain about running /etc/init.d/... stop - if
it does you might need to tweak that command (perhaps a script that
attempts to stop gracefully, and then forces the state to stopped
(/etc/init.d/... zap on gentoo) with a killall to kill any running
processes).
More information about the mythtv-users
mailing list