![]() When something happens, the both processes (ad their threads) usually exist and need a restart. Of course, I never know, if nginx may crash as well, some day. If some trouble occurs, usually php5-fpm hung up, resulting in a "bad gateway" server error. You may now check the status of the monitored services with the following command:Ĭongratulations! You have successfully installed Monit on your server, and key services are being monitored using Monit on your Alibaba Cloud Elastic Compute Service (ECS) CentOS 7 server.My webserver runs nginx with php5-fpm. If no syntax errors, reload the service, so changes take effect: Then, check for syntax errors on the config file, with the following command: ![]() Once you have all the services you required, you may save and close the file (CNTR+X and Enter). In this case, an administrator may be able to execute a single command to all services associated with the database group:įinally, note that a service can be added to multiple groups by using more than one group statement. Monit provides functions to start, stop, restart, monitor and unmonitor a group of services. With this statement it is possible to group similar service entries together and manage them as a unit. Service entries in the control file, can be grouped together by the group statement. This is to prevent using system resources on a service that is likely to continue to fail, and thus require further administration. This, of course, will send an email alert. With the timeout option, you tell the system that if the service restarts x amount of times within a time range, to timeout the service. If 5 restarts within 5 cycles then timeout If failed host 127.0.0.1 port 3306 then restart ![]() Stop program = "/usr/bin/systemctl stop mariadb" Start program = "/usr/bin/systemctl start mariadb" timeout of service (last line of block)Ĭheck process mysql with pidfile /var/run/mariadb/mariadb.pid.However, two new options are included for this service: Let’s look at the MariaDB process monitoring. In this case, ports 80 and 443 are monitored, and the service will be restarted if any of these failed. Then, optionally, you may also indicate ports to be monitored. This is followed by the process start and stop commands. In the first line, the process (ngnix in this case) and its pid location are identified. If failed port 443 protocol https then restart If failed port 80 protocol http then restart Stop program = "/usr/bin/systemctl stop nginx" ![]() Start program = "/usr/bin/systemctl start nginx" In this case, we are using Nginx.Ĭheck process nginx with pidfile /var/run/nginx.pid Set alert you add the services you need to monitor. You may also configure the system send email alerts (note that the underscore (_) below should be dots (.) but the system is taking these as links which are not allowed ) In this example, the first check is after 4 minutes of service start. Optionally you may delay the first check. Then, we start Monit in the background (that is, run as a daemon), that will check services every 30 seconds. Monit logs to syslog or to its own log file. This is how the configuration file looks like in my system. However, my recommendation is to keep it as simple as possible. There are many options and rules of actions available with Monit. Now, it is necessary to provide Monit with the services to be monitored, and the required actions on different events. To confirm the service is running, you may use the following command: With the enable command, you tell the system to start the Monit service on system boot. The following command takes care of this:įinally, create the system startup links. It is also important to ensure that the system is up to date, and that the EPEL package list is loaded prior installation of Monit. Rpm -import /etc/pki/rpm-gpg/RPM-GPG-KEY* Then, import the EPEL GPG-key, using the following command: Therefore, before installing Monit, you need to install the EPEL repository, using the following command: Monit is not available in the default CentOS 7 repositories. For example, your LEMP or LAMP stack should already be active and configured. Processes that Monit will be monitoring, should already be configured. Monit supports different Linux distros, but this guide will use CentOS 7. If you are a new user, you can get a free account in your Alibaba Cloud account. You must have Alibaba Cloud Elastic Compute Service (ECS) activated and verified your valid payment method. In this tutorial, we will be installing and configuring Monit on an Alibaba Cloud Elastic Compute Service (ECS) instance with CentOS 7.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |