首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用shinken、check_apt和event_handler更新服务器

使用shinken、check_apt和event_handler更新服务器
EN

Stack Overflow用户
提问于 2014-07-04 22:21:19
回答 1查看 151关注 0票数 1

我想要得到Shinken的关键更新的提醒。我使用check_apt,但当有更新时,它返回0个更新。然后,我希望在警报变为严重时启动event_handler。这些文件是: commands.cfg

代码语言:javascript
复制
# 'check_apt' command definition
define command {
    command_name    check_apt
    command_line    /usr/local/shinken/libexec/check_apt
    }
 define command {
  command_name    upgrade_server
  command_line    sudo /usr/local/shinken/libexec/upgrade $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$

脚本升级:

代码语言:javascript
复制
  #!/bin/sh
   #
  # Event handler script for upgrade server
  #
  #
 case "$1" in
OK)

 ;;
  WARNING)

  ;;
  UNKNOWN)

   ;;
   CRITICAL)
  case "$2" in

  case "$3" in

    # Wait until the check has been tried 3 times before restarting the web server.
    # If the check fails on the 4th time (after we restart the web server), the state
    # type will turn to "hard" and contacts will be notified of the problem.
    # Hopefully this will restart the web server successfully, so the 4th check will
    # result in a "soft" recovery. If that happens no one gets notified because we
    # fixed the problem!
    3)
      echo -n "Mise à jour ...."
    #lancement de la commande 
     /usr/bin/aptitude -y full-upgrade
      ;;
    esac
    ;;


  HARD)
      echo -n "Mise à jour ...."
    #lancement de la commande 
     /usr/bin/aptitude -y full-upgrade
    ;;
  esac
  ;;
      esac
      exit 0

和services.cfg:

代码语言:javascript
复制
  ## In this directory you can put all your specific service
   # definitions
   define service{
    use                             generic-service
    host_name                       router
     service_description             APT
     check_command                   check_apt!
     }

   define service{
   host_name    router
   service_description   APT
     max_check_attempts    4
     event_handler    upgrade_server
      }

提前感谢

EN

回答 1

Stack Overflow用户

发布于 2014-12-27 12:57:48

我认为你在定义服务的方式上是错误的。

您需要定义APT服务:

define service{ use generic-service host_name router service_description APT check_command check_apt! max_check_attempts 4 event_handler upgrade_server }

你不应该把它们分开。

我试过了,它工作得很好。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24576344

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档