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