Monit
is a utility for managing and monitoring processes, programs, files, directories and filesystems on a Unix system. Monit conducts automatic maintenance and repair and can execute meaningful causal actions in error situations. E.g. Monit can start a process if it does not run, restart a process if it does not respond and stop a process if it uses too much resources. You can use Monit to monitor files, directories and filesystems for changes, such as timestamps changes, checksum changes or size changes.
Monit is controlled via an easy to configure control file based on a free-format, token-oriented syntax. Monit logs to syslog or to its own log file and notifies you about error conditions via customizable alert messages. Monit can perform various TCP/IP network checks, protocol checks and can utilize SSL for such checks. Monit provides a http(s) interface and you may use a browser to access the Monit program.
WHAT TO MONITOR?
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.d/. For instance sendmail, sshd, apache and mysql. In contrast to many other monitoring systems, 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 many 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.
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.
Monit can monitor network connections to various servers, either on localhost or on remote hosts. TCP, UDP and Unix Domain Sockets are supported. Network test 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 because you can configure Monit to send any data and test the response from the server.
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 indicate an error. This means that you can use Monit to perform any type of check you can write a script for.
Finally, Monit can be used to monitor general system resources on localhost such as overall CPU usage, Memory and Load Average.
Install MONIT on pcDuino Ubuntu
$ sudo apt-get install monit
Enable Web Interface in Monit
After you have built Monit you can simply start the monit program from the build directory to test it. Monit will use the monitrc
control file located in this directory for it’s configuration. The file is setup to start Monit’s http server so you have something interesting to look at; After you have started monit, point your browser to http://127.0.0.1:2812/
and log in with the username admin
and password monit
.
Once started, monit will run as a background process. To stop monit, use monit quit
. To run monit in the foreground and in diagnostic mode, start monit with the -Iv options. In diagnostic mode, monit will print debug information to the console. Use ctrl+c
to stop monit in diagnostic mode. To see all options for the program, use monit -h
.
Copy monitrc
in the build directory to $HOME/.monitrc or if you plan to run Monit as root, to /etc/monitc. Use this file as a starting point to write your own configuration file for Monit.
(Optional For CLI Lovers) Monit also provided an web interface to view services and processes status. To enable monit web interface, edit configuration file (/etc/monit/monitrc ) in your favorite editor and uncomment following lines
$ sudo nano /etc/monit/monitrc set httpd port 2812 and use address localhost allow localhost allow admin:monit allow @monit allow @users readonly
and start monit service.
# service monit restart * Restarting daemon monitor monit [ OK ]
As per above configuration monit will start on port 2812 and only accessible from localhost. To change default port simply update first line of above showing configuration and set your preferred port.
Now access Monit web interface by pointing your browser to 2812 on localhost
Leave a Reply
You must be logged in to post a comment.