<?

$output = array();
$command = "/etc/init.d/u2p status";

exec($command, $output);

$sock = false;
$proc = false;
if(substr($output[0],0,17) == "mysql.sock exists") $sock = true; else $sock = false;
if(substr($output[1],0,14) == "Process exists") $proc = true; $procs = false;

if($proc && $sock) echo "UNIX2TCP Working";
if(!$proc && !$sock) echo "UNIX2TCP Both process and socket file missing";
else if(!$proc && $sock) echo "UNIX2TCP Process missing";
else if($proc && !$sock) echo "UNIX2TCP Socket file missing";

if(!$sock || !$proc) exec("/etc/init.d/u2p restart", $output);

?>
