[ create a new paste ] login | about

Link: http://codepad.org/ubBUhu2J    [ raw code | output | fork ]

PHP, pasted on May 5:
<?php

function test_port($host,$port=80,$timeout=6)
{
    $fsock = fsockopen($host, $port, $errno, $errstr, $timeout);
    if (!$fsock)
    {
        return FALSE;                    
    }
    else
    {
        return TRUE;
    }
}

/* check our website http://www.example.com is up and running (port 80) and timeout after 20 seconds */
$myhost = 'IP/website';
$ok = test_port($myhost,80,20);

if (!$ok) {
    mail('youremail@gmail.com', 'Monitoring', $myhost.' down');
}

?>


Output:
1
2
3
4
5
6

Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known on line 5

Warning: fsockopen(): unable to connect to IP/website:80 (Unknown error) on line 5

Disallowed system call: SYS_pipe


Create a new paste based on this one


Comments: