Rebooting Central automatically in Oracle Linux

Hello Yaw,
Thank you for your suggestion to automate restarting the Central service guide for ubuntu.
We are using Oracle Linux Server 7.9. Do you have any suggestion to setup automate restarting script for Oracle Linux Server 7.9. If you can share that woule be really helpful for us.

Thanks again for good forum support.

Regards,
Abhishek

I'm sorry, I don't. Oracle Linux seems to be based on RHEL? So I'd encourage you to look at instructions for how to install monit on RHEL and adjust my instructions accordingly.

Hi Yaw,
Thanks for your response. I am able to sucessfully install monit on Oracle Linux Server 7.9. Below are the steps I follow and yes it is almost similar to ubuntu with few exception.

Step - 1 Install latest epel package using below command:

sudo rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

Step - 2 Install monit using below command:

sudo yum install monit

Step - 3 Create central conf file in /etc/monit.d file

check program central-healthcheck with path /usr/local/bin/central-healthcheck.sh
  if status > 0 for 2 cycles then exec "/bin/bash -c '/usr/bin/docker restart central_service_1'"

Step - 4 Created central-healthcheck.sh file in /usr/local/bin folder

#!/bin/bash

CENTRAL_HTTP_CODE=$(curl --silent --insecure --include --request POST --header "Content-Type: application/json" --data-binary "{\"email\": \"email\",\"password\": \"password\"}" --write-out "%{http_code}" --output /dev/null https://127.0.0.1/v1/sessions)
if [[ $CENTRAL_HTTP_CODE == 500 ]]; then
  echo "$CENTRAL_HTTP_CODE" > /dev/stderr
  exit 1
fi
exit

Step - 5 Changed permission using below command:

sudo chmod 0755 central-healthcheck.sh;
sudo chmod 0644 central.conf;

Step - 6 Reload monit service

sudo monit reload;

Thanks,
Abhishek

Glad you figured it out!

Remember that this does not solve the problem, it only hides it.

Be sure to check how often you are restarting with grep restart /var/log/monit.log (or the Oracle equivalent) and adjust your server usage and resources accordingly.