CentOS 6.5 monit Monitoring inotifywait process

Source: Internet
Author: User
Tags rsync

Nagios always alarms in the last 2 days, and the inotifywait process is 0

Express_1 this host has 2 rsync scripts, express_1 to express_2 synchronization, after opening, there will be 2 inotifywait process.

It hangs every few hours and needs to be started manually. But it was too much trouble, and one night there were more than 10 nagios alarms.


So I wanted to use Monit to monitor the inotifywait process.


To create a startup script

vi/manage/express_monit.sh


#!/bin/bash


Case "$" in

Start

echo "Starting Express ..."

/manage/rsync/rsync_express.sh &

Sleep 1

Ps-aux | grep kuaidihelp_express | head-1 | awk ' {print $ ' >/var/run/express.pid

;;


Stop

echo "Stopping express ..."

Kill-9 ' Cat/var/run/express.pid '

;;


Restart

echo "Stopping express ..."

Kill-9 ' Cat/var/run/express.pid '

Sleep 1

Echo

echo "Starting Express ..."

/manage/rsync/rsync_express.sh &

Sleep 1

Ps-aux | grep kuaidihelp_express | head-1 | awk ' {print $ ' >/var/run/express.pid

;;


*)

echo "Usage: $prog {Start|stop|restart}"

;;

Esac

Exit 0


Set permissions

chmod 755 express_monit.sh


Install Monit, preferably using RPM installation, using encoding package compilation problem

Yum Install-y Monit

Editing a configuration file

Vim/etc/monit.conf

Modify the check time to 3 seconds and ID file path and open log

Set Daemon 3 # Check services at 2-minute intervals


# set logfile syslog facility Log_daemon

Set Logfile/var/log/monit.log


Set Idfile/var/.monit.id

Set Statefile/var/.monit.state


Comment Bottom Line 3rd

# Set Daemon mode timeout to 1 minute

#set Daemon 60


Then start Monit

/etc/init.d/monit start


Go to configuration directory

cd/etc/monit.d/

Add Express Sync Process monitoring

VI Express


Check Process Express with Pidfile/var/run/express.pid

Start program = "/manage/express_monit.sh start"

Stop program = "/manage/express_monit.sh Stop"


Start Monit

/etc/init.d/monit start


Kill off the inotifywait process

Pkill inotifywait


Observing Monit Logs

Tail-f/var/log/monit

[CST APR 10:41:07] Error: ' Express ' process is not running

[CST Apr 10:41:07] Info: ' Express ' trying to restart

[CST Apr 10:41:07] Info: ' Express ' Start:/manage/express_monit.sh

[CST Apr 10:41:12] Info: ' Express ' process is running with PID 14139

To see if a process starts

[Email protected] ~]# ps-aux | grep ino

Warning:bad syntax, perhaps a bogus '-'? See/usr/share/doc/procps-3.2.8/faq

Root 14306 0.0 0.0 6344 776? S 10:41 0:00/usr/local/inotify/bin/inotifywait-mrq--timefmt%d/%m/%y%h:%m--format%T%w%f-e modify,delete,creat e,attrib/www/kuaidihelp_express/

Root 17537 0.0 0.0 103252 864 pts/2 s+ 10:47 0:00 grep ino


The test is normal.

This article is from the "Falling Star" blog, make sure to keep this source http://xiao987334176.blog.51cto.com/2202382/1635954

CentOS 6.5 monit Monitoring inotifywait process

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.