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.