Monit, a tool for linux System Monitoring

Source: Internet
Author: User
Tags inode usage
Article Title: monit, a tool for linux system monitoring. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Monit is a tool used to monitor and manage processes, files, directories, and devices in the system. When the specified server goes down or does not respond, monit will kill the process and restart the server. And send notifications by email. Monit contains an embedded HTTP (S) Web interface. You can use a browser to conveniently view the servers monitored by Monit.

Monit Official Website: http://www.mmonit.com

The following describes how to install and configure monit on CentOS5.3:

Download: http://mmonit.com/monit/dist/monit-5.1.1.tar.gz

Shell> tar xzvf monit-5.1.1.tar.gz

Shell> cd monit-5 .*

Shell>./configure

Shell> make

Shell> make install

Shell> rm/etc/monitrc

Shell> cp monitrc/etc/

Add the following sentence to the inittab file to enable init to guard the monit process !!

Shell> vi/etc/inittab

Mo: 2345: respawn:/usr/local/bin/monit-Ic/etc/monitrc

The installation is complete. Is it super simple !!

Next, configure it !!

Monitrc file ###################################### ##################

Set daemon 120 # set the monit check interval, in seconds !!

Set logfile syslog facility log_daemon # Use syslog To record logs

Set logfile/var/logs/monit. log # set the log Path

Set idfile/var/. monit. id # set the PID File Location

Set mailserver 192.168.0.21, # IP address of the primary mailserver email server

Set mail-format {from: monit@test.com} # set the account from which your mail is sent

Set alert phoneNumber@139.com # send to my 139 mailbox, with 139 mailbox because 139 has a mail Arrival notification function

Set httpd port 2812 and # set the port number of the monit listener

Use address 192.168.0.21 # Set the IP address of the monit server to facilitate http access

Allow admin: pass # Set the user name and password

################################## Services ###### ########################

Monitor server disk usage

Check the device system with path/dev/mapper/VolGroup00-LogVol00

If space usage> 85% for 5 times within 15 cycles then alert

If space usage> 95% then stop

If inode usage> 85% then alert

If inode usage> 95% then stop

######################################## ##############

# Sshd monitoring sshd Process

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 host 127.0.0.1 port 22 then restart

If 5 restarts within 5 cycles then timeout

######################################## ###############

# Cron monitoring crontab Process

Check process cron with pidfile/var/run/crond. pid

Group system

Start program = "/etc/init. d/crond start"

Stop program = "/etc/init. d/crond stop"

If 5 restarts within 5 cycles then timeout depends on cron_rc

######################################## #################################

# Scripts monitors nginx log cutting script files

Check file cut_nginx_log.sh with path/scripts/cut_nginx_log.sh

Group scripts

If failed checksum then unmonitor

If failed permission 755 then unmonitor

If failed uid root then unmonitor

If failed gid root then unmonitor

######################################## ##################################

# Systemfile monitoring passwd files and group files

Check file passwd with path/etc/passwd

Group system

If failed checksum then unmonitor

If failed permission 644 then unmonitor

If failed uid root then unmonitor

If failed gid root then unmonitor

Check file group with path/etc/group

Group system

If failed checksum then unmonitor

If failed permission 644 then unmonitor

If failed uid root then unmonitor

If failed gid root then unmonitor

######################################## ######################

# Monitor the 25,110 Port Number of the Local Machine

Check host localhost with address 127.0.0.1

If failed port 25 with timeout 15 seconds then exec "/usr/bin/qmailctl restart"

If failed port 110 protocol pop with timeout 15 seconds then exec "/usr/bin/vpopmailctl restart"

The basic configuration is like this, and the rest is modified according to their actual situation !!!, Log on to the browser and check whether the operation is successful. Next, you can enjoy tea easily and visit the forum !! Haha

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.