Use Nagios to monitor the running state of a process

Source: Internet
Author: User

Using Nagios to monitor a program on a monitored server, the script returns a status value by looking at the status of the process and sending it to nagios for monitoring purposes. Nagios each plugin monitoring will return the following status values, I only use 0, 1, 2

Using Nagios to monitor a program on a monitored server, the script returns a status value by looking at the status of the process and sending it to nagios for monitoring purposes.
Nagios each plugin monitoring will return the following status values, I only use 0, 1, 2

Copy the Code code as follows:

#!/bin/bash-x
# Exit Values:
# ------------
# 0 OK
# 1 Warning
# 2 Cirital
# 3 Unknown
# Others Unknown

##-------
Dfs_process= ' Ps-ef | grep './dfs Client ' | Grep-v grep '
If [-z] $dfs _process "];then
echo "Critical The program of gather was down!!!"
Exit 2
Fi

Process_ppid= ' echo $dfs _process|awk ' {print $} '
Process_pid= ' echo $dfs _process|awk ' {print $} '

if [$process _ppid = 1];then
Echo ' The process of Dfs put back '
Exit 1
Else
While [$process _ppid! = 1]
Do
Old_process_ppid= $process _ppid
Process_ppid= ' Ps-ef | grep $process _ppid | Grep-v $process _pid | Grep-v grep | awk ' {print $} '
Process_pid= ' Ps-ef | grep $old _process_ppid| Grep-v $process _pid | Grep-v Grep|awk ' {print $} '
Done
Dfs_pprocess= ' Ps-ef | grep "$process _pid 1" | Grep-v grep '
echo "Process of"./dfs client ' OK! -Parent process is ' echo $dfs _pprocess | awk ' {print $8,$9,$10} ' "
Exit 0

Fi

Then, open the configuration file for the monitored end Nrpe
# vi/usr/local/nagios/etc/nrpe.cfg
Add to:

Copy the Code code as follows:

command[check_dfs]=/usr/local/nagios/libexec/check_dfs.sh

Finally, the Monitoring service (SERVICE.CFG) can start monitoring services.



Use Nagios to monitor the running state of a process

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.