I am working on a system that setup ssh connection remotely to another server, to get resources usage info like (CPU, ram, disk ), I am able to get these detail through an ssh connection, but my problem is I want to get CPU usage every 5 sec, to show it on my system, but every request the system creates a new connection to the server, are there any ways to save my connection so I can use that connection again in the other requests, I am using the collective package to ssh in my server
Asked
Active
Viewed 133 times
0
-
The way PHP works is by basically destroying all resources created at the end of each request. You can have a persistent connection to the server that polls and returns the result every 5 seconds and keep that connection alive however if you are using PHP-FPM the webserver will probably terminate the connection after the specified timeout period of a request. Another way would be to use websockets between front-end and backend and again have the backend establish and maintain the SSH connection. There are many more approaches as well. Its not clear what would work best for you – apokryfos Dec 29 '21 at 09:03
-
thanks for reply , so u suggest to use websocket , ok maybe I can have try with node js – Abobaker EngIt Dec 29 '21 at 09:06
1 Answers
0
take a look at this Laravel Envoy package

Mouhssine Soumairi
- 63
- 1
- 5
-
thank you for reply , but this package seems to run task in queue,and it running the commands without returning the output of it – Abobaker EngIt Dec 29 '21 at 08:54