Nagios – NagWin – Send notification with gmail

monitoringnagiossmtpwindows-server-2012

I would like to send Nagios notifications using my gmail account.

I have already set up my hosts I want to monitor and services also.

What is the most simple way to accomplish this using NagWin on a Windows Server 2012 installation?

As far as I know I must change some of these configuration settings:

# 'notify-host-by-email' command definition
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/blat - -to $CONTACTEMAIL$ -f nagios@localhost -subject "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" -server ???
    }

# 'notify-service-by-email' command definition
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" | /bin/blat - -to $CONTACTEMAIL$ -f nagios@localhost -subject "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" -server ???
    }

What should I use for smtp server? Is it possible to directly send my notifications to the Gmail server?

Best Answer

Do /usr/bin/printf and /bin/blat exist on your Windows box and does blat take an SMTP server parameter?

If not, you'll need an alternative set of commands -- maybe even your own custom script -- to generate the text output and send it to an SMTP server.

In any case, I'd probably point it at an IIS-based virtual mail server installed on the same Windows box, then configure the IIS vSMTP to send all mail to Gmail via the Smart Host feature. This will allow you to queue the mails locally, should a network outage mean you lose connectivity to the Gmail server. You could also use a third-party server like hMailServer

This Amazon blog article gives a good example on how you might set IIS up (substituting Amazon for Google, where appropriate)...