//Configuration - set this to match the information in /etc/monitrc //Set information about the monit server address, port and login details. $addr = 'localhost'; $port = 2812; $path = '/'; $user = 'admin'; $pass = 'monit'; $timeout = 30; //End of configuration $urlHandle = fsockopen($addr, $port, $errno, $errstr, $timeout); socket_set_timeout($urlHandle, $timeout); $urlString = "GET $path HTTP/1.0\r\nHost: $addr\r\nConnection: Keep-Alive\r\nUser-Agent: MonitPHP\r\n"; $urlString .= "Authorization: Basic ".base64_encode("$user:$pass")."\r\n"; $urlString .= "\r\n"; fputs($urlHandle, $urlString); $response = fgets($urlHandle); $endHeader = false; // Strip initial header information while ( !$endHeader){ if (fgets($urlHandle) == "\r\n") $endHeader = true; } $info = ''; // Generate a string to send to the screen while (!feof($urlHandle)) { $info.=fgets($urlHandle); } fclose ($urlHandle); echo $info; ?>