There are machines. PHP is used as the backend. when the machine is started, it will access the server. At this time, the status is set to "online", but the server will not be accessed because many machines are directly powered off, in this case, how can we modify the machine status? There are machines. PHP is used as the backend. when the machine is started, it will access the server. At this time, the status is set to "online", but the server will not be accessed because many machines are directly powered off, in this case, how can we modify the machine status?
Reply content:
There are machines. PHP is used as the backend. when the machine is started, it will access the server. At this time, the status is set to "online", but the server will not be accessed because many machines are directly powered off, in this case, how can we modify the machine status?
When the machine is running, it regularly sends a heartbeat packet to the background, telling the background that I am still online. The background checks the heartbeat packet once every time and treats the machine that has not received the heartbeat packet as offline, I wonder if this will meet your needs.
(1) Offline Detection: open a crontab on the server, Poll and send ping packets to the machine list at intervals of time, and set the dropped machine to offline.
(2) Real-Time Detection: if the background is only used to show whether the machine is still online, you can send a ping packet to check whether the machine is online when displaying the machine list. This method can only meet the requirement of displaying whether the machine is online in real time and has performance problems.
Make a regular round robin!
You can use socket.