[ previous ] [ next ] [ threads ]
 From:  Bob Zoller <bzoller at cavokintl dot com>
 To:  list at m0n0wall dot neon1 dot net
 Subject:  Script to watch DHCPD
 Date:  26 Mar 2003 11:24:27 -0600
I've been using m0n0wall for a couple weeks now, and truthfully it rocks
:)  The only issue I've had is the dhcp server dies occasionally. 
Sometimes twice within one day, sometimes only once during a whole
week..  In any case, I've written a script to check on the dhcpd process
every minute and reset it if it has died.

I launch it from /etc/rc, with the following line added after rc.bootup:
	# start the watch_dhcpd script
	/usr/local/sbin/watch_dhcpd &

And here is the watch_dhcpd script itself:
========= START SCRIPT ==========


while (true) {
	if (isset($config['dhcpd']['enable']) && !proc_running("{$g['varrun_path']}/dhcpd.pid")) {
		mwexec('/usr/bin/logger "DHCPD failed... restarting."');

function proc_running($pidfile) {
	if (file_exists($pidfile)) {
		$retval = mwexec("/bin/ps -p `/bin/cat " . $pidfile . "`");
		if ($retval == 0)
			return true;
	return false;

=========== END SCRIPT ============

Of course it's a bit tricky to install it on the router yourself.. gotta
do all the vnconfig crap to edit the .bin and mfsroot images, but maybe
if enough people are having this problem, it could just be included in
the next release.

Hope it helps someone!

Bob Zoller <bzoller at cavokintl dot com>
Cavok International, Inc.