为什么使用Nagios Core自定义测试无法通过电子邮件发送SMS消息

问题描述

当主机无法使用Nagios Core到达主机时,我想向手机发送SMS通知。我已经配置了Nagios并对其进行监视。另外,我已经添加了contacts.cfg和commands.cfg文件。我正在使用电子邮件发送短信。例如:8041233456@tmomail.net。我正在使用Redhat Linux,并且已经在Linux命令中使用了命令定义,以查看是否能够获取短信并起作用。例如:添加下面在Linux命令中初始化的“ command_line”,我实际上收到一条消息,并且仅将$视为输出,但至少可以通过。 我的问题是转到Nagios core并选择发送自定义主机测试时,我没有收到任何响应。但是,此自定义测试确实适用于常规电子邮件。以下是我添加配置文件

define contact {
    contact_name                  ericg-cell
    use                           generic-contact
    alias                         my name
    email                         8041233456@tmomail.net
    service_notification_commands notify-service-by-email
    host_notification_commands    notify-service-by-email
    service_notifications_enabled 1
    #service_notification_options u

}

define command {

    command_name    notify-host-by-email
    command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mailx -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}

define command {

    command_name    notify-service-by-email
    command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n $NOTIFICATIONCOMMENT$\n" | /bin/mailx -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$

}

I want to stay using mailx to send sms messaging and not any other tools related because I see online that there are only showing other tools to use and not mailx. I also already have my services and host files already being monitored.

解决方法

您可以使用https://d7networks.com Nagios插件来实现SMS服务。它易于配置,并且可以实时获取SMS功能。

请参阅https://exchange.nagios.org/directory/Addons/Notifications/SMS/D7SMS-for-Nagios/details