Monit is a free open source process monitoring tool that can be used to monitor system processes using Web browsers and command lines. It is also used to monitor file size, directory and device size changes and permissions changes. If you drop, Monit will automatically fix the specific process. Monit also monitors most of the services such as Apache, Sendmail, Nginx, FTP, SSH, and MySQL on Linux-based systems. You can use Monit to monitor remote host TCP / IP ports, protocols, and ping. Monit has the ability to stop using specific processes with high resources. Monit keeps watch on your server and sends alerts about any serious error status and recovery status.
feature
- Automatically start, stop and kill the specific process.
- User-friendly Web interface for status monitoring.
- Notify any key conditions via email.
- Check system load, CPU usage, RAM usage, disk, file size changes, permissions changes, and so on.
- Monitor various protocols HTTP, FTP, SSH, POP, IMAP, LDAP, IMAP, and SMTM.
- Logged by syslog or its own log file.
In this tutorial, we will show you how to set up and use Monit on Debian 9.
Claim
- A new Debian 9 server is installed on your system.
- The root password is set on your server.
Update the system
We first update from your system to the latest stable version. You can update it with the following command:
apt-get update -y
apt-get upgrade -y
apt-get upgrade -y
After updating the system, restart the system and make the following commands take effect:
reboot
After rebooting, use the root user to log in and proceed to the next step.
2. Prompt installation
By default, Monit is available in the Ubuntu repository. You can easily install it by running the following command:
apt-get install monit -y
After installing Monit, start the Monit service and start it by running the following command:
systemctl start monit
systemctl enable monit
systemctl enable monit
You can check the status of the Monit service at any time by running the following command:
systemctl status monit
3 Prompt Configuration
Monit default configuration file monitrc is located in / etc / monit / directory, other processes and server-specific configuration files are located in / etc / monit / conf-available / diractory. Monit comes with a built-in Web interface that is disabled by default. You can enable it by editing the / etc / monit / monitrc file as follows:
nano / etc / monit / monitrc
Change the following line:
# set httpd port 2812 and
# use address localhost # only accept connection from localhost
# allow localhost # allow localhost to connect to the server and
# allow admin:monit # require user 'admin' with password 'monit'
to
set httpd port 2812 and
allow admin:monit # require user 'admin' with password 'monit'
When finished, save and close the file, and then restart the monit service to apply the changes using the following command:
systemctl restart monit
You can use the following command to check the Monit service status:
netstat -ant | grep :2812
You should see the following output:
tcp 0 0 0.0.0.0:2812 0.0.0.0:* LISTEN 1615/monit
tcp6 0 0 :::2812 :::* LISTEN 1615/monit
4 Visit the Monit Web interface
You can use the URL http://192.168.0.227:2812 to access the Monit Web interface, and then enter the username admin and password monit . You should see the Monit dashboard as follows:
You can use the following command to view the status of Minit:
monit status
You should see the following output:
System 'localhost'
status Running
monitoring status Monitored
load average [0.68] [0.78] [0.45]
cpu 0.0%us 0.0%sy 0.0%wa
memory usage 294.1 MB [14.7%]
swap usage 0 B [0.0%]
data collected Mon, 07 Aug 2017 20:12:36
Upon completion, you can proceed to the next step.
5 add monitoring services
Once the Monit Web interface is configured, you need to add the services you want to monitor.
Here, we will give some examples to monitor Apache, Proftpd and Rsyslog and some other services.
Configure Monit for Apache services
By default, Monit comes with predefined templates for certain processes and services. You can find these templates in the / etc / monit / conf-available / directory. By default, Apache templates are available in Monit. So you just need to enable it. You can enable it by running the following command:
ln -s /etc/monit/conf-available/apache2 /etc/monit/conf-enabled/
Next, restart monit servcie to apply the changes using the following command:
systemctl restart monit
Configure Monit for the Rsyslog service
First, use the following command to enable the Rsyslog template:
ln -s /etc/monit/conf-available/rsyslog /etc/monit/conf-enabled/
Next, restart the monit service to apply the changes using the following command:
systemctl restart monit
Configure Monit for the Proftpd service
Proftpd's template does not apply to Monit. So you need to create a configuration file for Proftpd. You can do this by creating the proftpd file in the / etc / monit / conf-available / directory, as follows:
nano /etc/monit/conf-available/proftpd
Add the following line:
check process proftpd with pidfile /var/run/proftpd.pid
start program = "/etc/init.d/proftpd start"
stop program = "/etc/init.d/proftpd stop"
if failed port 21 protocol ftp then restart
When finished, save and close the file, and then use the following command to enable the configuration file:
ln -s /etc/monit/conf-available/proftpd /etc/monit/conf-enabled
Next, use the following command to check if the configuration file has any syntax errors
monit -t
Finally, restart the monit service to apply the changes using the following command:
systemctl restart monit
After you have configured all the necessary services, visit the Web interface to monitor all services as follows:
Next, click on the service apache to see more information about apache:
6 through the command line monitoring
You can also monitor Monit from the command line. You can view a quick summary of monit by running the following command:
monit summary
You should see the following output:
The Monit daemon 5.16 uptime: 0m
Process 'rsyslogd' Initializing - start pending
File 'rsyslogd_bin' Accessible
File 'rsyslogd_rc' Accessible
File 'rsyslog_file' Does not exist
Process 'proftpd' Running
Process 'apache' Execution failed
File 'apache_bin' Accessible
File 'apache_rc' Accessible
System 'localhost' Running
You can also use the following command to view the status of all services:
monit status
You should see the following output:
The Monit daemon 5.16 uptime: 0m
Process 'rsyslogd'
status Initializing - start pending
monitoring status Initializing
data collected Mon, 07 Aug 2017 20:41:18
File 'rsyslogd_bin'
status Accessible
monitoring status Monitored
permission 755
uid 0
gid 0
size 585.3 kB
timestamp Tue, 25 Oct 2016 11:38:40
checksum d71f3d1c58df065e3aac1e2c566a6436 (MD5)
data collected Mon, 07 Aug 2017 20:41:18
File 'rsyslogd_rc'
status Accessible
monitoring status Monitored
permission 755
uid 0
gid 0
size 2.7 kB
timestamp Tue, 25 Oct 2016 11:48:29
checksum a1ef1bb01ba370040d705c92fc09e92e (MD5)
data collected Mon, 07 Aug 2017 20:41:18
File 'rsyslog_file'
status Does not exist
monitoring status Monitored
data collected Mon, 07 Aug 2017 20:41:18
Process 'proftpd'
status Running
monitoring status Monitored
pid 4915
parent pid 1
uid 0
effective uid 119
gid 65534
uptime 3m
threads 1
children 0
memory 3.6 MB
memory total 3.6 MB
memory percent 0.2%
memory percent total 0.2%
cpu percent 0.0%
cpu percent total 0.0%
port response time 10.737 ms to [localhost]:21 type TCP/IP protocol FTP
data collected Mon, 07 Aug 2017 20:41:18
Process 'apache'
status Execution failed
monitoring status Monitored
data collected Mon, 07 Aug 2017 20:41:48
File 'apache_bin'
status Accessible
monitoring status Monitored
permission 755
uid 0
gid 0
size 647.0 kB
timestamp Sat, 29 Jul 2017 22:19:09
checksum ef2a678bdcd791948ceabc3013d9a2c0 (MD5)
data collected Mon, 07 Aug 2017 20:41:18
File 'apache_rc'
status Accessible
monitoring status Monitored
permission 755
uid 0
gid 0
size 7.9 kB
timestamp Mon, 07 Aug 2017 20:40:33
checksum 744ef9ca584493299c353e2251cbf993 (MD5)
data collected Mon, 07 Aug 2017 20:41:18
System 'localhost'
status Running
monitoring status Monitored
load average [0.96] [0.60] [0.46]
cpu 0.0%us 0.0%sy 0.0%wa
memory usage 266.4 MB [13.3%]
swap usage 2.1 MB [0.4%]
data collected Mon, 07 Aug 2017 20:41:18
To view more information about the Proftpd service, run the following command:
monit status proftpd
You should see the following output:
The Monit daemon 5.16 uptime: 2m
Process 'proftpd'
status Running
monitoring status Monitored
pid 4915
parent pid 1
uid 0
effective uid 119
gid 65534
uptime 6m
threads 1
children 0
memory 3.6 MB
memory total 3.6 MB
memory percent 0.2%
memory percent total 0.2%
cpu percent 0.0%
cpu percent total 0.0%
port response time 7.945 ms to [localhost]:21 type TCP/IP protocol FTP
data collected Mon, 07 Aug 2017 20:43:49
Congratulations! You have successfully installed and configured Monit on the Debian 9 server.
Thank you for your visite .. ☺
Enjoy
Youtube New Update Monetization Enable On Bangladesh,Sri Lanka and Nepal
ReplyDeletesuspense24