Startup management scripts for Nrpe in Nagios

Source: Internet
Author: User

The recent period of time should be a lot of adjustments to modify the Nagios monitoring policy so need to re-restart Nrpe, but after Nagios installation is not provided Nrpe startup script, so I wrote a Nrpe for the usual restart:

#!/bin/sh#the startup script for nrpe#author:jim#processname:nrped# chkconfig:   2345 97 03#description:This is a daemon used for nrpe  Startup management in nagios#source functions libraryif [ -f /etc/rc.d /init.d/functions ]; then    . /etc/rc.d/init.d/functionselif [ - f /etc/init.d/functions ]; then    . /etc/init.d/functionselif [  -f /lib/lsb/init-functions ]; then    . /lib/lsb/ init-functionsfiprefix= "/usr/local/nagios" nrpe_bin= "${prefix}/bin/nrpe" nrpe_config_file= "${prefix}/etc/ Nrpe.cfg "nrpe_num=$ (ps aux | grep /bin/nrpe | grep -v grep |  wc -l) nrpe_pid=$ (ps aux | grep /bin/nrpe | grep -v grep  | awk  ' {print $2} ') retval=0Start ()  {   if [  $nrpe _num -eq 1 ];then       echo_warning      echo  "nrpe is running "     else      ${nrpe_bin} -c ${nrpe_config_file} -d       echo_success      echo  "Starting nrpe   "   fi}stop () {   if [  $nrpe _num -eq 1 ];then       kill -9  $nrpe _pid      echo_ success      echo  "starting nrpe "    else       echo_failure      echo  "nrpe is  stoping  "   fi}restart () {   if [  $nrpe _num -eq 1 ] ; Then      kill -9  $nrpe _pid      echo_success       echo  "stopting nrpe "       ${nrpe_bin} -c $ {nrpe_config_file} -d      echo_success       echo  "starting nrpe "    else      echo_failure       echo  "nrpe is stoping "        ${nrpe_bin} -c ${nrpe_config_file} -d      echo_success       echo  "starting nrpe "    fi}case $1  in start)       start      ;;  stop)       stop      ;;  restart)       RESTART&Nbsp;     ;;        *)       echo_failure       echo  "Usage: $0 {start|stop|restart}"        retval=2esacexit  $RETVAL

In short, it is relatively simple, including the use of the system functions, you can see: http://jim123.blog.51cto.com/4763600/1900432, one of the notes is to upload the file to/etc/ INIT.D directory needs to be granted execution, and then use Chkconfig to join the system to enable service management to, if the Linux/centos 7 system also use Systemctl Daemon-reload overload once:

[[email protected] init.d]# chmod +x nrped[[email protected] init.d]#  chkconfig --add nrpedchkconfig --list nrpedsystemctl daemon-reload[[email  protected] init.d]# chkconfig --list nrpednrped            0: Off   1: Turn off   2: Enable   3: Enable   4: Enable   5: Enable   6: Close [[Email protected] init.d]# /etc/init.d/nrped restartstopting nrpe                                                 [Determine]starting nrpe                                                 [Determine][[email protected] init.d]# service nrped restartstopting nrpe                                                 [Determine]starting nrpe                                                 [OK]


This article from "Jim's Technical Essay" blog, declined to reprint!

Startup management scripts for Nrpe in Nagios

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.