首页 文章

模拟nagios通知

提问于
浏览
4

我测试通知和升级链的常规方法是通过导致故障来模拟故障,例如阻塞端口 .

但这完全不令人满意 . 我不希望在没有的nagios中录制停机时间 . 我也不想等 .

有没有人知道测试通知链的方法而不会导致中断?例如这样的事情:

$ ./check_notifications_chain <service|host> <time down>
at <x> minutes notification email sent to group <people>
at <2x> minutes notification email sent to group <people>
at <3x> minutes escalated to group <management>
at <200x> rm -rf; shutdown -h now executed.

扩展这个范例我可能会让通知链本身成为一个nagios检查,但是在我的大脑爆炸之前我会停在这里 .

任何人?

1 回答

  • 4

    如果您只想验证电子邮件警报是否正常工作,则可以创建一个简单的测试服务,该服务每天生成一次警告 .

    test_alert.sh:

    #!/bin/bash
    
    date=`date -u +%H%M`
    
    echo $date
    echo "Nagios test script. Intentionally generates a warning daily."
    
    if [[ "$date" -ge "1900" && "$date" -le "1920" ]] ; then
      exit 1
    else
      exit 0
    fi
    

    commands.cfg:

    define command{
      command_name  test_alert
      command_line  /bin/bash /usr/local/scripts/test_alert.sh
    }
    

    services.cfg:

    define service {
      host                  localhost
      service_description   Test Alert
      check_command         test_alert
      use                   generic-service
    }
    

相关问题