【发布时间】:2014-10-06 06:21:36
【问题描述】:
我正在尝试为 Nagios 中的特定服务发送不同样式的通知,即当用户帐户被 AD 锁定时。我不需要与普通电子邮件相关的所有多余信息(例如,服务所属的主机、IP 地址、服务状态等),因为我需要的所有信息都在$SERVICEOUTPUT 中从 Windows 发送的 SNMP 陷阱中给出.但是,我不能只更改 notify-service-by-email 命令,因为我需要使用所有其他服务的完整输出。
我需要找到一种方法:
-
发送为此服务定制的电子邮件通知
define command{ command_name notify-service-by-email command_line $~LongOutputCommand~$ } define command{ command_name notify-lockouts-by-email command_line $-ShortOutputCommand~$ } define service{ service_description Account Lockouts service_notification notify-lockouts-by-email ... } -
在 Nagios 命令的 command_line 部分执行 if 语句:
define command{ command_name notify-service-by-email command_line if [ "$SERVICEDESC" == "Account Lockouts" ]; then $-ShortOutputCommand~$; else $~LongOutputCommand~$; fi }
由于它的编程方式,我不相信 Nagios 可以执行第一种方式,但无论我如何尝试第二种方式,它都不会将其作为正确的命令处理(“如果无法识别”等)。
【问题讨论】:
标签: nagios