![monit examples monit examples](https://dz2cdn1.dzone.com/storage/temp/11142742-image3.png)
Tell Monit which program it should use to start the process if it is not running. Stop program = "/etc/init.d/apache2 stop" Start program = "/etc/init.d/apache2 start" Automatically start a ProcessĬheck process apache with pidfile /var/run/httpd.pid Next, we'll see how Monit can be configured to automatically start or restart Apache if it is not running.
![monit examples monit examples](https://lifetweakers.com/wp-content/uploads/2020/12/monit-default.png)
That's all, Monit will check the process id (pid) in the given pid file and consult the system's process table and check if the process exist. Here is how we can check if Apache is running check process apache with pidfile /var/run/httpd.pid Monit can do that.įor this example, let us assume that your web-server is Apache, if not, no worries, the same applies to any process. If your web-site is down, getting an alert is all well and good, but it is much more useful if you can also have itĪutomatically fixed, especially at 04 AM. Check a section on your siteĬheck host with address Īnd request /monit/ with content = "Monit +" Pingdom and if you use M/Monit you will also get the ping and response-time charts. You can add as many host checks as you need. Test using the HTTP protocol, if this fails, raise an alert.(3) if failed port 443 type TCPSSL protocol http then alert (2) if failed port 80 protocol http then alert In addition to the command line interface, Monit also provides a super lightweight Web-Interface you can use to check the status ofĪll monitored services Configuration Examples Is your website up? Sleep for a configured period, then wakes up and start monitoring again in anĮndless loop until you choose to stop monit by this command: As a daemon Monit runs in cycles It monitors services, then goes to Monit will detach from the terminal and run as a daemon process (background process).