Nagios monitors a process

Source: Internet
Author: User

After Nagios is installed, prepare to monitor a program on the monitored server. The script returns the status value by checking the Process status and sends it to Nagios for monitoring purposes.

The following status values are returned for each Nagios agent monitoring. I only use 0, 1, and 2.

#! /Bin/bash-x

# Exit values:
#------------
#0 OK
#1 warning
#2 circircle
#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 is down !!! "
Exit 2
Fi

Process_ppid = 'echo $ dfs_process | awk '{print $3 }''
Process_pid = 'echo $ dfs_process | awk '{print $2 }''

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 $3 }''
Process_pid = 'ps-Ef | grep $ old_process_ppid | grep-V $ process_pid | grep-V grep | awk' {print $2 }''
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 of the monitored nrpe.

# Vi/usr/local/Nagios/etc/nrpe. cfg

Add:

Command [check_dfs] =/usr/local/Nagios/libexec/check_dfs.sh

 

You can customize the Monitoring Service (service. cfg) on the monitoring end.

The following status values are returned for each Nagios agent monitoring. I only use 0, 1, and 2.

#! /Bin/bash-x

# Exit values:
#------------
#0 OK
#1 warning
#2 circircle
#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 is down !!! "
Exit 2
Fi

Process_ppid = 'echo $ dfs_process | awk '{print $3 }''
Process_pid = 'echo $ dfs_process | awk '{print $2 }''

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 $3 }''
Process_pid = 'ps-Ef | grep $ old_process_ppid | grep-V $ process_pid | grep-V grep | awk' {print $2 }''
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 of the monitored nrpe.

# Vi/usr/local/Nagios/etc/nrpe. cfg

Add:

Command [check_dfs] =/usr/local/Nagios/libexec/check_dfs.sh

 

You can customize the Monitoring Service (service. cfg) on the monitoring end.

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.