"5", "usec" => "0"))) OR (!socket_set_option($socket, SOL_SOCKET, SO_SNDTIMEO, Array("sec" => "5", "usec" => "0")))) { die("Unable to set socket timeout"); } if (@socket_connect($socket, $adminHost, $adminPort)) { $data = ""; if (!$socket) { die("Unable to open socket to " . $server . ":" . $port . "\n"); } socket_write($socket, $command . "\n"); socket_recv($socket, $buffer, 65536, 0); $data .= $buffer; socket_close($socket); return $data; } else { return "Unable to connect: " . socket_strerror(socket_last_error()) . "\n"; } } // byteReduce(str) - this function converts a numeric value of bytes to a human readable format and returns the result function byteReduce($bytes) { // Terabytes if ($bytes > 1099511627776) { return round($bytes / 1099511627776) . "TB"; } else if ($bytes > 1073741824) { return round($bytes / 1073741824) . "GB"; } else if ($bytes > 1048576) { return round($bytes / 1048576) . "MB"; } else if ($bytes > 1024) { return round($bytes / 1024) . "KB"; } else { return $bytes . "B"; } } // This is where our main code starts echo "

Statistics since last reset:
"; ?>