Location: PHPKode > projects > web-cp - Web Hosting Control Panel > webcp/server/cron/monitor.inc.phps
<?	/*
	// File:	monitor.php
	// Purpose:	Services monitor script:  check the pids.
	// Author:	Felix <hide@address.com>
	*/

///////////////////////
// CONFIGURATION :  filename containing the scan data
$filename = $cfg['basedir']."/server/data/sysmon.dat";


// remove the services that shouldn't be monitored.
if ($cfg['mailserver'] != 'sendmail') {
	unset($cfg['spid']['sendmail']);
}
if ($cfg['mailserver'] != 'qmail') {
	unset($cfg['spid']['qmail']);
}
if (!$cfg['uwimap']) {
	unset($cfg['spid']['imap']);
}
if ($cfg['dns_system'] != 'bind') {
	unset($cfg['spid']['bind']);
}
if ($cfg['ftpserver'] != 'proftpd') {
	unset($cfg['spid']['proftpd']);
}
if ($cfg['ftpserver'] != 'wuftpd') {
	unset($cfg['spid']['wuftpd']);
}
if ($cfg['dns_system'] != 'mydns') {
	unset($cfg['spid']['mydns']);
}
	

reset($cfg);
unset($monitor);
foreach ($cfg['spid'] AS $key=>$val) {
	if ($val) {
		if (file_exists($val)) {
			$pid = file($val);
			$pid = intval(trim($pid[0]));
			if (posix_kill($pid,0))
				$monitor[$key] = 'up';
			else
				$monitor[$key] = 'down';
		}
		else
			$monitor[$key] = 'down';
	}
}

// Prepare $data
$data = serialize($monitor);
// write down results
$fp = fopen($filename,"w+");
fwrite($fp,$data,50000);
fclose($fp);
?>
Return current item: web-cp - Web Hosting Control Panel