Simple PHP script to test server up and SSH connectivity

I’m a PHP newbie, still learning the ropes. I have what should be an easy solution to provide, which is a simple drop-down list and button to facilitate rebooting them – think of it as an emergency button. The remote systems are Windows-based, and the command is being called via SSH.

My problem is how to manage the lifecycle of this process and determine that the server is back up. First, I would create a lockfile that would prevent additional reboots if it’s in process; but, after, I would need to test something SSH connectivity to determine the host is up and release the lockfile.

Only a few people would have access to it, it doesn’t need to be completely fool proof for now. The use would be for emergencies, and we agreed this would be one method we’d use.

I originally thought I’d call the command from PHP using escapeshellcmd() – then it became apparent that, depending on what call I use (ie: passthru()), I may not be able to pass HTML or scripting from the shell to PHP (and that’s probably counter-intuitive anyway).

I have the layout and the drop-down, CSS and all that working fine. It’s the above that I’m really stuck on.

It was suggested I use javascript to facilitate a ping to the server, but that doesn’t tell you that a reliable service (like SSH) is accessible, and the examples I found online use HTTP (the Windows servers are not providing that).

Any pointers would be greatly appreciated :smile:

Thanks in advance.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.