random1 Posted February 13, 2008 Share Posted February 13, 2008 I'm looking for a way of adding some PHP code to my site that shows the status of ther server. i.e. Server is offline (with image) and other common important server info. How can this be done? Link to comment https://forums.phpfreaks.com/topic/90849-server-status-info/ Share on other sites More sharing options...
Isityou Posted February 13, 2008 Share Posted February 13, 2008 You can use sockets to attempt a connection to the 'server'. Display the 'offline' 'online' image accordingly. Link to comment https://forums.phpfreaks.com/topic/90849-server-status-info/#findComment-465634 Share on other sites More sharing options...
random1 Posted February 13, 2008 Author Share Posted February 13, 2008 Thanks I create the following function. function pingDomain($domain = "10.1.1.1", $port = "80"){ try { $starttime = microtime(true); $file = fsockopen ($domain, $port, $errno, $errstr, 10); $stoptime = microtime(true); $status = 0; } catch(Exception $e) { // Exception occured pinging domain } if (!$file) $status = -1; // Site is down else { fclose($file); $status = ($stoptime - $starttime) * 1000; $status = floor($status); $this->setServerStatus($status); } // Else site is up $this->setServerStatus($status); return $status; // ping in ms } Link to comment https://forums.phpfreaks.com/topic/90849-server-status-info/#findComment-465661 Share on other sites More sharing options...
Isityou Posted February 13, 2008 Share Posted February 13, 2008 No problem, glad I could help Link to comment https://forums.phpfreaks.com/topic/90849-server-status-info/#findComment-465666 Share on other sites More sharing options...
random1 Posted February 13, 2008 Author Share Posted February 13, 2008 Are there any other stats we can get for the server? Like: Uptime Downtime Stability Rating Link to comment https://forums.phpfreaks.com/topic/90849-server-status-info/#findComment-466355 Share on other sites More sharing options...
Isityou Posted February 13, 2008 Share Posted February 13, 2008 Once to go would be to run a cronjob on the script checks the server status. From here you can insert data into a database and calculate the server uptime/downtime and stability. Link to comment https://forums.phpfreaks.com/topic/90849-server-status-info/#findComment-466361 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.