[Open source server monitoring tool Monit]

Monit is a feature-rich process, file, directory and device monitoring software for Linux/Unix platforms. It can automatically repair programs that have stopped working, and Envoy is suitable for dealing with software errors caused by various reasons. At the same time, Monit includes a built-in HTTP(S) Web interface, you can use a browser to easily view what Monit monitors. server. Monit is a feature-rich process, file, directory and device monitoring software for Unix platforms. It can automatically repair those programs that have stopped working, and Envoy is suitable for dealing with software errors caused by many reasons. monit runs at the application layer. Monit is particularly easy to install, very lightweight (only 500KB in size), and doesn't rely on any third-party programs, plugins, or libraries. Monit can monitor server process status, HTTP/TCP status codes, server resource changes, file system changes, etc. According to these changes, you can set email alarms, restart processes or services. Ease of installation, lightweight implementation, and powerful features make Monit an ideal backup monitoring tool.



 

 

What Monit can do

Proactive adj. Proactive; proactive; proactive; preemptive;

Monit can act if an error situation should occur, e.g.; if sendmail is not running, Monit can start sendmail again automatically or if apache is using too much resources (e.g. if a DoS attack is in progress) Monit can stop or restart apache and send you an alert message. Monit can also monitor process characteristics, such as; how much memory or cpu cycles a process is using.

 

Processes

You can use Monit to monitor daemon processes or similar programs running on localhost. Monit is particularly useful for monitoring daemon processes, such as those started at system boot time from /etc/init/ For instance sendmail, sshd, apache and mysql.

 

Files, Dirs and Filesystems

You can also use Monit to monitor files, directories and filesystems on localhost. Monit can monitor these items for changes, such as timestamps changes, checksum changes or size changes. This is also useful for security reasons - you can monitor the md5 or sha1 checksum of files that should not change and get an alert or perform an action if they should change.

 

Cloud and Hosts

Monitor network connections to various servers, either on localhost or on remote hosts. TCP, UDP and Unix Domain Sockets are supported. Network tests can be performed on a protocol level; Monit has built-in tests for the main Internet protocols, such as HTTP, SMTP etc. Even if a protocol is not supported you can still test the server as you can configure Monit to send any data and test the response from the server.

 

Programs and scripts

Monit can be used to test programs or scripts at certain times, much like cron, but in addition, you can test the exit value of a program and perform an action or send an alert if the exit value indicates an error. This means that you can use Monit to perform any type of check you can write a script for.

 

System

Finally, Monit can be used to monitor general system resources on localhost such as overall CPU usage, Memory and Load Average.

 

 

The following is a simple example, the configuration file has included a lot of examples, you can see the configuration file reference.

 

set daemon 120 #Set the detection time

set logfile /var/log/monit.log #monit log

set alert [email protected] with reminder on 1 cycle #When an error occurs, send an alert email to the specified email address

set mailserver mail.vpser.net #Set the mail server

set httpd port 2812 and # Set the port of the http monitoring page

     use address 74.207.246.99 # IP of http monitoring page

     allow localhost # allow local access

     allow 123.23.45.0/24 # Allow this IP segment to access

     #allow 0.0.0.0/0.0.0.0 # Allow all IP access

     allow username:password #Set the access username and password

 

#Detect sshd service

check process sshd with pidfile /var/run/sshd.pid

   start program  "/etc/init.d/sshd start"

   stop program  "/etc/init.d/sshd stop"

   if failed port 22 protocol ssh then restart

   if 5 restarts within 5 cycles then timeout

 

#Detect mysql service

check process mysql with pidfile /usr/local/mysql/var/vpser.pid

   group database

   start program = "/etc/init.d/mysql start"

   stop program = "/etc/init.d/mysql stop"

   if failed host 127.0.0.1 port 3306 then restart

   if 5 restarts within 5 cycles then timeout

 

#Detect nginx service

 check process nginx with pidfile /usr/local/nginx/logs/nginx.pid

    start program = "/etc/init.d/nginx start"

    stop program  = "/etc/init.d/nginx stop"

    if failed host www.vpser.net port 80 protocol http

       then restart

The pid in the configuration and the path of the startup and shutdown scripts must be the full path, and the parameters must be correct, otherwise it will not be able to detect or start normally.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326308950&siteId=291194637