Sponsored Link
monit is a utility for managing and monitoring, processes, files, directories and devices on a UNIX system. Monit conducts automatic maintenance and repair and can execute meaningful causal actions in error situations.Running Monit 5.4 on an Ubuntu server. When I use monit reload, it seems that it restarts monitored services (Tomcat 7 in this situation).Is it the expected behavior? Documentation says. Reload - Reinitialize a running Monit daemon, the daemon will reread its configuration, close and reopen log files. Ubuntu Universe amd64 Official monit5.16-2amd64.deb: utility for monitoring and managing daemons or similar programs: Ubuntu Universe arm64 Official monit5.16-2arm64.deb. 2 days ago bpytop might be the freaking-coolest way to monitor your Linux system; You can now order a PC case that looks like the classic Commodore 64; ScummVM to merge in ResidualVM, adding support for a number of 3D titles; Play the classic Diablo on Linux with a huge new release of DevilutionX.
Monit Features
* Daemon mode -- poll programs at a specified interval
* Monitoring modes -- active, passive or manual
* Start, stop and restart of programs
* Group and manage groups of programs
* Process dependency definition
* Logging to syslog or own logfile
* Configuration -- comprehensive controlfile
* Runtime and TCP/IP port checking (tcp and udp)
* SSL support for port checking
* Unix domain socket checking
* Process status and process timeout
* Process cpu usage
* Process memory usage
* Process zombie check
* Check the systems load average
* Check a file or directory timestamp
* Alert, stop or restart a process based on its characteristics
* MD5 checksum for programs started and stopped by monit
* Alert notification for program timeout, restart, checksum, stop resource and timestamp error
* Flexible and customizable email alert messages
* Protocol verification. HTTP, FTP, SMTP, POP, IMAP, NNTP, SSH, DWP,LDAPv2 and LDAPv3
* An http interface with optional SSL support to make monit accessible from a webbrowser
* Monitoring modes -- active, passive or manual
* Start, stop and restart of programs
* Group and manage groups of programs
* Process dependency definition
* Logging to syslog or own logfile
* Configuration -- comprehensive controlfile
* Runtime and TCP/IP port checking (tcp and udp)
* SSL support for port checking
* Unix domain socket checking
* Process status and process timeout
* Process cpu usage
* Process memory usage
* Process zombie check
* Check the systems load average
* Check a file or directory timestamp
* Alert, stop or restart a process based on its characteristics
* MD5 checksum for programs started and stopped by monit
* Alert notification for program timeout, restart, checksum, stop resource and timestamp error
* Flexible and customizable email alert messages
* Protocol verification. HTTP, FTP, SMTP, POP, IMAP, NNTP, SSH, DWP,LDAPv2 and LDAPv3
* An http interface with optional SSL support to make monit accessible from a webbrowser
Install Monit in Ubuntu
sudo apt-get install monit
This will complete the installation.
Configuring Monit
Default configuration file located at /etc/monit/monitrc you need to edit this file to configure your options
sudo vi /etc/monit/monitrc
Sample Configuration file as follows and uncomment all the following options
## Start monit in background (run as daemon) and check the services at 2-minute
## intervals.
#
set daemon 120
## intervals.
#
set daemon 120
## Set syslog logging with the ‘daemon' facility. If the FACILITY option is
## omited, monit will use ‘user' facility by default. You can specify the
## path to the file for monit native logging.
#
set logfile syslog facility log_daemon
## omited, monit will use ‘user' facility by default. You can specify the
## path to the file for monit native logging.
#
set logfile syslog facility log_daemon
## Set list of mailservers for alert delivery. Multiple servers may be
## specified using comma separator. By default monit uses port 25 -- it is
## possible to override it with the PORT option.
#
set mailserver localhost # primary mailserver
## specified using comma separator. By default monit uses port 25 -- it is
## possible to override it with the PORT option.
#
set mailserver localhost # primary mailserver
## Monit by default uses the following alert mail format:
From: [email protected]$HOST # sender
Subject: monit alert --- $EVENT $SERVICE # subject
Subject: monit alert --- $EVENT $SERVICE # subject
$EVENT Service $SERVICE
Date: $DATE
Action: $ACTION
Host: $HOST # body
Description: $DESCRIPTION
Action: $ACTION
Host: $HOST # body
Description: $DESCRIPTION
Your faithful,
monit
monit
## You can override the alert message format or its parts such as subject
## or sender using the MAIL-FORMAT statement. Macros such as $DATE, etc.
## are expanded on runtime. For example to override the sender:
#
set mail-format { from: [email protected] }
## or sender using the MAIL-FORMAT statement. Macros such as $DATE, etc.
## are expanded on runtime. For example to override the sender:
#
set mail-format { from: [email protected] }
## Monit has an embedded webserver, which can be used to view the
## configuration, actual services parameters or manage the services using the
## web interface.
#
set httpd port 2812 and
use address localhost # only accept connection from localhost
allow localhost # allow localhost to connect to the server and
allow 172.29.5.0/255.255.255.0
allow admin:monit # require user ‘admin' with password ‘monit'
## configuration, actual services parameters or manage the services using the
## web interface.
#
set httpd port 2812 and
use address localhost # only accept connection from localhost
allow localhost # allow localhost to connect to the server and
allow 172.29.5.0/255.255.255.0
allow admin:monit # require user ‘admin' with password ‘monit'
> Change 172.29.5.0/255.255.255.0 to your network ip range
# Monitoring the apache2 web services.
# It will check process apache2 with given pid file.
# If process name or pidfile path is wrong then monit will
# give the error of failed. tough apache2 is running.
check process apache2 with pidfile /var/run/apache2.pid
# It will check process apache2 with given pid file.
# If process name or pidfile path is wrong then monit will
# give the error of failed. tough apache2 is running.
check process apache2 with pidfile /var/run/apache2.pid
#Below is actions taken by monit when service got stuck.
start program = '/etc/init.d/apache2 start'
stop program = '/etc/init.d/apache2 stop'
# Admin will notify by mail if below of the condition satisfied.
if cpu is greater than 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if totalmem > 200.0 MB for 5 cycles then restart
if children > 250 then restart
if loadavg(5min) greater than 10 for 8 cycles then stop
if 3 restarts within 5 cycles then timeout
group server
start program = '/etc/init.d/apache2 start'
stop program = '/etc/init.d/apache2 stop'
# Admin will notify by mail if below of the condition satisfied.
if cpu is greater than 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if totalmem > 200.0 MB for 5 cycles then restart
if children > 250 then restart
if loadavg(5min) greater than 10 for 8 cycles then stop
if 3 restarts within 5 cycles then timeout
group server
#Monitoring Mysql Service
check process mysql with pidfile /var/run/mysqld/mysqld.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
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
#Monitoring ssh Service
check process sshd with pidfile /var/run/sshd.pid
start program '/etc/init.d/ssh start'
stop program '/etc/init.d/ssh stop'
if failed port 22 protocol ssh then restart
if 5 restarts within 5 cycles then timeout
start program '/etc/init.d/ssh start'
stop program '/etc/init.d/ssh stop'
if failed port 22 protocol ssh then restart
if 5 restarts within 5 cycles then timeout
You can also include other configuration files via include directives:
include /etc/monit/default.monitrc
include /etc/monit/mysql.monitrc
include /etc/monit/mysql.monitrc
This is only sample configuration file. The configuration file is pretty self-explaining; if you are unsure about an option, take a look at the monit documentation
After configuring your monit file you can check the configuration file syntax using the following command
sudo monit -t
Once you don't have any syntax errors you need to enable this service by changing the file /etc/default/monit
sudo vi /etc/default/monit
# You must set this variable to for monit to start
startup=0
startup=0
to
# You must set this variable to for monit to start
startup=1
startup=1
Now you need to start the service using the following command
sudo /etc/init.d/monit start
Monit Web interface
Monit Web interface will run on the port number 2812.If you have any firewall in your network setup you need to enable this port. Imindmap 11 full version crack mac & win.
Now point your browser to http://yourserverip:2812/ (make sure port 2812 isn't blocked by your firewall), log in with admin and monit.If you want a secure login you can use https check here
Once it opens you should see the following screen
Here you need to enter the username and password
Once it opens you should see the following screen with all the services we are monitoring
Apache web server process details
You can start,stop,restart and disable this service from web interface you can see this in the following screen
Sponsored Link
Related posts
- Ubuntu Networking Configuration Using Graphical Tool (21)
- Pandora FMS 3.0 Released! (0)
- Network traffic analyzers for Ubuntu System (8)
- netspeed – Traffic monitor applet for GNOME (0)
- Nagios Network Monitoring System Setup in Ubuntu (92)
- mytop – top like query monitor for MySQL (0)
- Monitoring Ubuntu Servers and Desktops Using Cacti (10)
Monit is an open-source process monitoring tool for Linux operating system that monitors the system processes for problems. Whenever the services or process goes down, Monit will automatically do the maintenance or repair of a particular process (i.e., restarting the service) to bring back online.
Monit can also be used for managing and monitoring of files, directories, and devices for permission changes, timestamps changes, size changes, and checksum changes.
It logs to its log file and notifies the user via customizable email messages.
This guide will help you to install Monit on Ubuntu 18.04 / Ubuntu 16.04.
Install Monit
Update the repository index.
Monit is available on Ubuntu repositories, so you can use the apt to install it.
Configure Monit
The main configuration file of Monit is /etc/monit/monitrc and additional configuration files for process/service are usually placed in /etc/monit/conf-available and /etc/monit/conf-enabled directories.
Edit the main configuration file to configure important parameters of Monit’s to meet our requirements.
If you want to change the time intervals between service check, edit the below value.
Set the mail server information for relaying the alerts generated by Monit.
Specify an email address on which you want to be alerted in case of any failures/events.
If you only want alert emails for specific events like Timeout and Ping failed events, use the below alert filtering.
Check out How to filter an event.
By default, Monit sends only one notification for the failure of service and another one when it recovers. If you want to be alerted on each N cycle if service remains in the failed state.
For example, to get alerts for four cycles, you can use the below settings.
Enable Monit Web Interface
Monit also comes with an embedded web interface to view the status of services and manage them through a web browser.
By default, the Monit web interface is disabled. To enable it, edit the Monit configuration file /etc/monit/monitrc.
Ubuntu Install Monit
Look for the set httpd port 2812 line and change the following entries.
Restart the Monit service.
Check whether the Monit service is listening correctly on all interfaces.
Access Monit Web Interface
Access the web interface by using the below URL.
You need to use the username as admin and password as monit to access the Monit’s web interface.
Monit’s home page will look like this.
Click on server.itzgeek.local to see the detailed information of Monit.
You can also use Monit’s command-line interface to see the status of Monit.
Configure Services For Monitoring
Pre-defined Service Configuration Templates
Monitrc
Monit also comes with a pre-defined configuration template for some of process and services. The templates are found in /etc/monit/conf-available/ directory, and you can enable them by creating a symbolic link to /etc/monit/conf-enabled/ directory.
Monitor Apache With Monit
Let us monitor the Apache2 service using the pre-defined template provided by Monit.
Symlink the templates to /etc/monit/conf-enabled/ directory.
Reload Monit service to take effect of changes.
Access the Monit web interface. You would find the new services that we configured using the template.
Manually Configure Monit for NTP
Configure Monit to start when the NTP daemon dies for any reason. Create the config file called ntp under /etc/monit/conf-available directory.
Append the following config to the above file.
Enable the configuration file symlinking to /etc/monit/conf-enabled/ directory.
Verify the Monit syntax.
Reload Monit service to take effect of changes.
You should see the NTP service on the web interface.
Click on the service name to see detailed information about the service.
Test Monit
Now, we will test the action that will be taken by Monit when the service or process dies for no reason.
Stop the ntp daemon.
Wait for 30 seconds. NTP service will be up and running because of Monit. You can check the Monit log to find out.
Monit Ubuntu
Conclusion
Monit Ubuntu Service
That’s All. We have successfully configured Monit on Ubuntu 18.04 / Ubuntu 16.04. We welcome your feedback, please post your valuable comments below.