Monit is one of the best tools to monitor server resource usage and processes. It is versatile and works with all types of application processes. The best thing about this utility is that it is newbie friendly. Setting up Monit hardly takes half an hour even if you’re completely new to this tool.
What does this tool do?
Once you install this tool and start it, Monit will run parallelly with other applications running in the background. It will keep an eye on processes and make you aware of the process which is using a huge amount of system memory or using a high amount of CPU. It can also stop/restart these processes.
Example usage of Monit
Java is a robust programming language. Its web servers require > 512 MB RAM if you want to host multiple applications on the same machine. Java ships with various garbage collectors, each having their own advantages and disadvantages. For those who don’t know, the role of the GC is to clear objects from the heap space which are not used by the app.
Although you can specify the heap size and configure the GC, this approach has some problems if the settings are tweaked by a person who does not have deep knowledge of garbage collectors or if the configuration is not right.
When the allocated heap is full, the applications will stop working. Instead of the IP address, browser details, etc, the server log files will be filled with OutOfMemory exceptions and the CPU utilization will be well over 90%.
To prevent this error, you’ll have to monitor the server’s resources or use a monitoring tool which will alert you when the java process is consuming abnormally high CPU cycles or RAM.
Uses of Monit
Monit can be configured to check the RAM as well as CPU usage. It can also monitor the ports and URLs. The app can restart the service that has created the service automatically. To use this feature, the user must specify the threshold value in their Monit configuration files.
Monit is available in the repo of all major Linux distributions. It is also available for download on mmonit.com. To install this tool, type one of the following three commands in the Linux terminal/ssh console and hit the enter key.
apt-get install monit
yum install monit
dnf install monit
Once installed, open the /etc/ directory and verify the presence of Monit by typing
ls -ltr | grep "monit* ;
monit.d is the folder where the configuration files reside. monitrc is the main configuration file of monit.
The monitrc file contains an option to set the time interface, enable web interface, specify the log file location, configure mail settings, etc.
The log file will be updated each time you restart, reload, stop, reload Monit or when this tool stops/starts a service.
Now, go through the documentation to learn how to use this tool.
Am I using this tool?
Yep, I have installed Monit on my server. The following log file snapshot proves the same:
Final thoughts: Monit is a powerful tool that can save time and resources. It is one of the best server monitoring tools I’ve come across. It is powerful and easy to use. Once you configure it on your server, you just have to check your inbox or the monit log file instead once a day or week. This tool will take care of “Out Of Memory” errors. It will automatically stop/start processes that are consuming a large amount of RAM or are keeping the processor of the server very busy.
Leave a Reply