Phil Martin wrote:
Sure, sorry about that. I have a function that tells me if the host is DOWN
or UP. I want to run this function in parallel for each host I monitor. The
function is the following:
function servstatus($remote_ip, $remote_ip_port, $remote_ip_proto) {
if ($remote_ip_proto == "tcp") {
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
// Turning Off Warning Messages
$i_error_old=error_reporting();
error_reporting($i_error_old & ~ (E_WARNING));
if ($connect = socket_connect($socket, "$remote_ip", "" .
$remote_ip_port . "")) {
return true;
the following 3 statements will never be run.
socket_set_block($socket);
socket_close($socket);
unset($connect);
} else {
return false;
the following 3 statements will never be run.
socket_set_nonblock($socket);
socket_close($socket);
unset($connect);}
my guess is you know even less about sockets, especially blocking/non-blocking
than I do!
} else {
why are you making the distinction between udp and tcp in this way?
// Turning off Warning Messages
$i_error_old=error_reporting();
error_reporting($i_error_old & ~ (E_WARNING));
$socket = fsockopen("udp://$remote_ip", "$remote_ip_port", &$errno,
&$errstr, 2);
$timeout = 1;
if (!$socket) {
if you don't get the socket why does that mean the service is up?
return true;
}
socket_set_timeout ($socket, $timeout);
$write = fwrite($socket,"\x00");
if (!$write) {
again if you can't write why does that mean the service is up?
return true;
}
$startTime = time();
$header = fread($socket, 1);
$endTime = time();
$timeDiff = $endTime - $startTime;
if ($timeDiff >= $timeout) {
why does a time measurement mean the service is up?
fclose($socket);
return true;
} else {
fclose($socket);
return false;
}
}
}
Thanks in advance
Felipe Martins
On 5/30/06, Dave Goodchild <buddhamagnet@xxxxxxxxx> wrote:
On 30/05/06, Phil Martin <darkinner.lists@xxxxxxxxx> wrote:
>
> Hi everyone,
>
> I've made a very basic and small function to suit my needs in
> monitoring some hosts services. I've noticed that the script is a
little
> bit
> slow because of the number of hosts and services to monitor. Is there a
> way
> to execute my function servstatus(); in parallel with every hosts to
> increase the speed ?
> Thanks in advance.
>
> []'s
> Felipe Martins
>
>
Can you show us the function?
--
http://www.web-buddha.co.uk
dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css)
look out for project karma, our new venture, coming soon!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php