2014-07-04 2 views
1

Я хочу получать уведомления о важных обновлениях Shinken. Я использую check_apt, но он возвращает мне 0 обновлений, но когда есть обновления. Затем я хочу запустить event_handler, когда предупреждение становится критическим. Это файлы: commands.cfg обновитьОбновление серверов с shinken, check_apt и event_handler

# '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$ 

сценарий:

#!/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:

## 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 
     } 

Заранее спасибо

ответ

0

я думаю, что вы не правы в способе обслуживания определения.
Вам необходимо определить службу APT:
define service{ use generic-service host_name router service_description APT check_command check_apt! max_check_attempts 4 event_handler upgrade_server }
, и вы не должны их разделять.
Я пробовал, и все было хорошо.

Смежные вопросы