Server Type – VPS
OS – Centos
Panel – cpanel
Root access – Yes i have.
Sometime due to load or some other issues my vps goes down. Then i always need to perform a restart by login at my host’s server control panel.
When i click on restart tab after few minutes my server come back online.
But i want to do that pragmatically or with some kind of script.
I can detect when my server gets down. I have my own server monitoring system but its not possible for me to be available online every time when my server goes down. So i bear loss at that time.
That is why i am looking for making a script by which i can remotely send a reboot/restart request automatically to my down VPS. Same way like my host’s server control panel does.
But i am not getting any clue about how to do that?
Is there any hidden kind of access that you perform to reboot/restart to the server?
May i know if is there any kind of API to do so?
Any technical advice will be an advantage for me.
Your system doesn’t go down “due to load or some other issues”. It goes down because you’ve misconfigured it. For example if the main application takes up all CPUs, it’s your job to prepare the system to survive that. If I were you, I’d get to work on finding a root cause.
That being said the most common solution on centos 7 for the use-case you presented is pacemaker with multitude of various fence agents. The fence agents are responsible for telling various VPSs’ APIs to cold-boot the unresponsive system.
Again, it’s much more beneficial to find a root cause than to spend time on learning pacemaker.
Source : Link , Question Author : Kapil Sharma , Answer Author : kubanczyk