OMD/Thruk Notifications

22 views
Skip to first unread message

Frederico Paulo

unread,
Feb 27, 2022, 6:16:41 AM2/27/22
to Thruk
Hi Sven,

My company is about to switch off the Local and Unauthenticated email sending. 
So we will need to define a SMTP Server address. 
Sendmail is not capable of doing it in the command line and mailx is a nightmare with email headers. Which leaves us only with Curl as an option.

Curl at first seemed to work perfectly, but later we noticed that the -n option which points to the .netrc file isn´t read.
Or even if we use plain authentication in the address like smtp://{YWTUA}:{=&L=3AE=hov5oX}@example.com it will give a time out.

Here are my configurations:

define command {
    command_name host-notify-by-email-html
    command_line /usr/bin/perl $USER1$/notify-by-email.pl \
        --template=$USER4$/etc/mail-templates/notify-by-email.host.html.basis.tpl \
            --mail='/usr/bin/curl --ssl-reqd smtp://example.com --mail-from example.com --mail-rcpt "$CONTACTEMAIL$" -n --upload-file "/dev/stdin" --silent' \
        -o BASEURL="http://`hostname -f`/$USER3$/" \
        -o NOTIFICATIONTYPE='$NOTIFICATIONTYPE$' \
        -o NOTIFICATIONCOMMENT='$NOTIFICATIONCOMMENT$' \
        -o HOSTNAME='$HOSTNAME$' \
        -o HOSTALIAS='$HOSTALIAS$' \
        -o HOSTSTATE='$HOSTSTATE$' \
        -o CONTACTEMAIL='$CONTACTEMAIL$' \
        -o HOSTADDRESS='$HOSTADDRESS$' \
        -o SHORTDATETIME='$SHORTDATETIME$' \
        -o SERVICEDESC='$SERVICEDESC$' \
        -o SERVICESTATE='$SERVICESTATE$' \
        -o SERVICEOUTPUT='$SERVICEOUTPUT$' \
        -o LONGSERVICEOUTPUT='$LONGSERVICEOUTPUT$' \
        -o SERVICEPERFDATA='$SERVICEPERFDATA$' \
        -o ACKAUTHOR='$SERVICEACKAUTHOR$' \
        -o ACKCOMMENT='$SERVICEACKCOMMENT$' \
        -o DURATION='$SERVICEDURATION$' \
        -o SERVICEEVENTID='$SERVICEEVENTID$' \
        -o LASTSERVICEEVENTID='$LASTSERVICEEVENTID$'
}

Is there any thing in the notify-by-email.pl that can be adapted so it will not break if login details are provided?
Can you point me in the right direction ?

Thanks,
Fred




Frederico Paulo

unread,
Mar 1, 2022, 3:03:34 AM3/1/22
to Thruk
Hi,

Fixed it, the from header from command line and html template did not match so it was refused as the smtp user is bound to a from address.
Running the template from the command line to see the error helped:
/usr/bin/perl /opt/omd/sites/winnagio/etc/naemon/conf.d/Basis/notify-by-email.pl --template=/opt/omd/sites/winnagio/etc/mail-templates/notify-by-email.service.html.basis.tpl.test --mail='/usr/bin/curl --ssl-reqd smtp://example.com --mail-from 'exa...@example.com' --mail-rcpt ' exa...@example.com  ' --upload-file "/dev/stdin" --netrc-file "/export/home/winnagio/.netrc" -v'

Good week,
Fred
Reply all
Reply to author
Forward
0 new messages