模拟Nagios通知

use*_*692 5 testing notifications nagios simulate

我测试通知和升级链的正常方法是通过引起故障(例如阻塞端口)来模拟故障。

但这是完全不令人满意的。我不想在没有的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.
Run Code Online (Sandbox Code Playgroud)

扩展这种范式,我可能会将通知链本身做为Nagios检查,但是在我的大脑爆炸之前,我将在这里停止。

任何人?

Tyl*_*orn 5

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

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
Run Code Online (Sandbox Code Playgroud)

命令.cfg:

define command{
  command_name  test_alert
  command_line  /bin/bash /usr/local/scripts/test_alert.sh
}
Run Code Online (Sandbox Code Playgroud)

服务.cfg:

define service {
  host                  localhost
  service_description   Test Alert
  check_command         test_alert
  use                   generic-service
}
Run Code Online (Sandbox Code Playgroud)