设为首页 收藏本站
查看: 971|回复: 0

Nagios 3 & Centreon 2 RC5 安装与配置(2)

[复制链接]

尚未签到

发表于 2019-1-17 07:04:05 | 显示全部楼层 |阅读模式
  创建NDO2DB服务脚本
  创建文件/etc/init.d/ndo2db (vi /etc/init.d/ndo2db),写入下面的内容。
  #!/bin/sh
  #
  #
  # chkconfig: 345 99 01
  # description: Nagios to mysql
  #
  # Author : phenix
  # Realase : 07/02/08
  # Version : 0.1 b
  # File : ndo2db
  # Description: Starts and stops the Ndo2db daemon
  # used to provide network services status in a database.
  #
  status_ndo ()
  {
  if ps -p $NdoPID > /dev/null 2>&1; then
  return 0
  else
  return 1
  fi
  return 1
  }
  printstatus_ndo()
  {
  if status_ndo $1 $2; then
  echo "ndo (pid $NdoPID) is running..."
  else
  echo "ndo is not running"
  fi
  }
  killproc_ndo ()
  {
  echo "kill $2 $NdoPID"
  kill $2 $NdoPID
  }
  pid_ndo ()
  {
  if test ! -f $NdoRunFile; then
  echo "No lock file found in $NdoRunFile"
  echo -n " checking runing process..."
  NdoPID=`ps h -C ndo2db -o pid`
  if [ -z "$NdoPID" ]; then
  echo " No ndo2db process found"
  exit 1
  else
  echo " found process pid: $NdoPID"
  echo -n " reinit $NdoRunFile ..."
  touch $NdoRunFile
  chown $NdoUser:$NdoGroup $NdoRunFile
  echo "$NdoPID" > $NdoRunFile
  echo " done"
  fi
  fi
  NdoPID=`head $NdoRunFile`
  }
  # Source function library
  # Solaris doesn't have an rc.d directory, so do a test first
  if [ -f /etc/rc.d/init.d/functions ]; then
  . /etc/rc.d/init.d/functions
  elif [ -f /etc/init.d/functions ]; then
  . /etc/init.d/functions
  fi
  prefix=/usr/local/nagios
  exec_prefix=${prefix}
  NdoBin=${exec_prefix}/bin/ndo2db
  NdoCfgFile=${prefix}/etc/ndo2db.cfg
  NdoRunFile=${prefix}/var/ndo2db.run
  NdoLockDir=/var/lock/subsys
  NdoLockFile=ndo2db.lock
  NdoUser=nagios
  NdoGroup=nagios
  # Check that ndo exists.
  if [ ! -f $NdoBin ]; then
  echo "Executable file $NdoBin not found. Exiting."
  exit 1
  fi
  # Check that ndo.cfg exists.
  if [ ! -f $NdoCfgFile ]; then
  echo "Configuration file $NdoCfgFile not found. Exiting."
  exit 1
  fi
  # See how we were called.
  case "$1" in
  start)
  echo -n "Starting ndo:"
  touch $NdoRunFile
  chown $NdoUser:$NdoGroup $NdoRunFile
  $NdoBin -c $NdoCfgFile
  if [ -d $NdoLockDir ]; then
  touch $NdoLockDir/$NdoLockFile;
  fi
  ps h -C ndo2db -o pid > $NdoRunFile
  if [ $? -eq 0 ]; then
  echo " done."
  exit 0
  else
  echo " failed."
  $0 stop
  exit 1
  fi
  ;;
  stop)
  echo -n "Stopping ndo: "
  pid_ndo
  killproc_ndo
  # now we have to wait for ndo to exit and remove its
  # own NdoRunFile, otherwise a following "start" could
  # happen, and then the exiting ndo will remove the
  # new NdoRunFile, allowing multiple ndo daemons
  # to (sooner or later) run
  #echo -n 'Waiting for ndo to exit .'
  for i in 1 2 3 4 5 6 7 8 9 10 ; do
  if status_ndo > /dev/null; then
  echo -n '.'
  sleep 1
  else
  break
  fi
  done
  if status_ndo > /dev/null; then
  echo
  echo 'Warning - ndo did not exit in a timely manner'
  else
  echo 'done.'
  fi
  rm -f $NdoRunFile $NdoLockDir/$NdoLockFile
  ;;
  status)
  pid_ndo
  printstatus_ndo ndo
  ;;
  restart)
  $0 stop
  $0 start
  ;;
  *)
  echo "Usage: ndo {start|stop|restart|status}"
  exit 1
  ;;
  esac
  # End of this script
  增加可执行权限
  # chmod +x /etc/init.d/ndo2db
  自动启动
  # chkconfig ndo2db on
  注意:这里先不要创建ndo使用的数据库,在centreon安装完成以后创建即可


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-664155-1-1.html 上篇帖子: Nagios 3 & Centreon 2 RC5 安装与配置(1) 下篇帖子: Nagios 3 & Centreon 2 RC5 安装与配置(3)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表