有什么方法可以将 nagios 警报发送到 Amazon SNS?
我已尝试以下步骤,但 Nagios 日志文件中出现此错误:
Jul 12 11:38:23 ip-10-134-13-204 nagios3: Warning: Attempting to execute the command "export $NOTIFICATIONTYPE $HOSTNAME $HOSTSTATE $HOSTADDRESS $HOSTOUTPUT $LONGDATETIME | sh -x /etc/nagios3/notify_by_sns" resulted in a return code of 127. Make sure the script or binary you are trying to execute actually exists...
命令脚本:
cat /etc/nagios3/notify_by_sns
#!/bin/bash
#########################################################
export AWS_ACCESS_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXX
export AWS_SECRET_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXX
export AWS_SNS_HOME=/usr/local/sns
sns-publish arn:aws:sns:us-west-1:xxxxxxxxxxxx:NAGIOS --subject "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" --message "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n"
编辑
谢谢亚当的回复。
我能够从命令行执行 sns-publish,并且脚本也运行良好。我面临的问题是 nagios
EROOR MSG 是 :-
警告:尝试执行命令“/usr/lib/nagios/plugins/notify_by_sns $NOTIFICATIONTYPE $HOSTNAME $HOSTSTATE $HOSTADDRESS $HOSTOUTPUT $LONGDATETIME”导致返回代码为 127。请确保您尝试执行的脚本或二进制文件确实存在...