System Monitoring monit

Source: Internet
Author: User

The company's Tomcat server Java Virtual Machine is unstable. To ensure security, install monit self-monitoring.

Monit is a monitoring software that provides rich functions for processes, files, directories, and devices. It is used on UNIX platforms. It can automatically fix stopped programs and is suitable for the Special Envoy to handle software errors caused by multiple reasons. Services can be "recovered ".

Official http://mmonit.com/monit/documentation/monit.html


I. Installation

# Tar-zxvf monit-5.8.1.tar.gz

# Cd monit-5.8.1

#./Configure -- prefix =/usr/local/monit \

-- Without-Pam \

-- Sysconfdir =/usr/local/monit/etc

# Make & make install

# Cp-A monit-5.8.1/monitrc/usr/local/monit/etc

# Chmod 700/usr/local/monit/etc/monitrc


Ii. Configuration File

 # Vim/Urs/local/monit/etc/monitrc

Set Daemon 300 # Set the monitoring time, in seconds

Set logfile/usr/local/monit/log/monit. log # Set the location of the log file

Set MailServer smtp.xxxxx.com username "" password "# Set the alarm mailbox

Set mail-format {from: Any name @ domain name} # Set the alarm mail format, the alarms received are all fromRenyi name @ domain name this mailbox

Set alert: email address for receiving alarm emails # Set the email address for receiving alarm emails. If there are multiple email addresses, use the same format and select another line.

Set httpd port 2812 and

Use address local IP # only accept connection from localhost

Allow IP (accessible IP) # allow localhost to connect to the server

Allow admin: ccmonit # require user 'admin' with password 'monit'

Allow @ monit # Allow Users of group 'monit' to connect (RW)

Allow @ users readonly # Allow Users of group 'users' to connect readonly

#Self-monitoring Tomcat

Check host Tomcat with address IP (local IP)

Start program = "/usr/local/tomcat/bin/Catalina. Sh start"

Stop program = "/usr/local/tomcat/bin/shutdown. Sh"

If failed

Port 80

Protocol HTTP

Request "/test/time. jsp" # Time Test page

Then restart

If 4 restarts within 4 cycles then unmonitor # If tmcat cannot be started four times in a row, stop the restart.


Iii. Test page

# Cd/usr/local/tomcat/webapps/

# Mkdir Test

# Cd Test

# Vim time. jsp (display the current system time)

      
   
  

Access http: // ip/test/time. jsp for verification


4. monit init script

#! /Bin/bash # init file for monit ### chkconfig:-80 20 # Description: monit daemon # processname: monitsource/etc/rc. d/init. d/functions ### default variablesconfig = "/usr/local/monit/etc/monitrc" [-x/usr/local/monit/bin/monit] | Exit 1 [-R "$ config"] | exit 1bin_path =/usr/local/monit/binretval = 0 prog = "monit" DESC = "monit daemon" Start () {echo-N $ "Starting $ DESC ($ prog):" daemon $ bin_path/$ prog-C "$ Config" retval =$? Echo [$ retval-EQ 0] & Touch/var/lock/subsys/$ prog return $ retval} STOP () {echo-N $ "shutting down $ DESC ($ prog):" killproc $ prog retval =$? Echo [$ retval-EQ 0] & Rm-F/var/lock/subsys/$ prog return $ retval} restart () {stop start} reload () {echo-N $ "reloading $ DESC ($ prog):" killproc $ prog-hup retval =$? Echo return $ retval} case "$1" in START) Start; stop) Stop; restart) restart; RELOAD) Reload; condrestart) [-E/var/lock/subsys/$ prog] & restart retval =$?; Status) # Status $ prog $ bin_path/$ prog status retval = $?; *) Echo $ "Usage: $0 {START | stop | restart | reload | condrestart | status}" retval = 1 esacexit $ retv


5. Management Process

# Service monit monitor name | all starts monitoring a service | all services

# Service monit unmonitor name | all disables monitoring of a service | all services

# Service monit start name | all starts a service | all services

# Service monit stop name | all disables a service | all services

# Service monit status: displays the monitored service status

This article is from the blog of the "Bremen band" and will not be reposted!

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.