Answer the question
In order to leave comments, you need to log in
How to organize parallel ping of local machines from multiple servers using PHP?
Good day to all. There is a big network, in it ~1000 machines. There are several servers running PHP with Apache on MS Windows Server, there are 2 MS SQL databases, the task is to ping all the machines on the network and draw a network map, there is no problem with drawing, the question is how to ping them all?
Initially, the task was at least with 1 server and 1 database, pinged them all sequentially through exec(ping...) once in a certain amount of time, wrote to the database, then read from there, took quite (even very) a lot of time, tried to do it with different threads via curl_multi, but since almost all machines are not visible via http, 99% of machines answer OFFLINE.
How to organize a parallel ping of all machines from at least 1 server? As far as I understand pthreads can only be used on a linux server, in my case it is MS. Is it possible to implement exec(ping...) in multi-threaded way?
The maximum task is to split the ping of machines into several servers, write to the databases (replicas), go to the face from one server, read the information from the database and already draw. Minimize ping time. However, it is worth considering that the ping of all machines must go constantly, that is, if the machine is turned off, it should be visible as quickly as possible.
To be honest, when I came across this task, I thought that this is far from a PHP task and that’s not what PHP is for, but there is a task, and a solution is needed, and my version with sequential ping takes an unforgivably long time. I also want to note that it is necessary to use only native tools, no matter how absurd it may be. There is no way to use tools like nagios etc.
Answer the question
In order to leave comments, you need to log in
php.net/manual/en/book.gearman.php
gearman.org/getting-started
Install, assign tasks, assign tasks to workers, start.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question