Page 2 of 4

Re: SMTP connect() failed on new setup

Posted: Thu Feb 10, 2022 12:44 am
by jpdl
ok thank you for the feedback, I will follow the guide and advise how it went.
Thank you

Re: SMTP connect() failed on new setup

Posted: Thu Feb 10, 2022 2:26 am
by jpdl
Ok I can confirm that my test emails are now being sent and received, thank you very much for the help!

I have detected that no notifications are being sent to my contacts, I have tested with sending custom notifications, and nothing is being received, so the email address is correct in the contact section and email settings are correct.

Please advise what I can do to check why the notifications are not being sent to my contacts when there are any issues on any hosts/services?
I will attach the profile, please advise what else you need from me

Re: SMTP connect() failed on new setup

Posted: Thu Feb 10, 2022 6:49 am
by jpdl
Ok I managed to get the notifications working, now the only problem I have is the "from" address is not correct,
currently it is showing [email protected] as the from address, I have attached it also.

It needs to be changed to [email protected].
I have tried numerous suggestions on the forum and none of them work:
I will post our current Host and Services email commands:

Host:
/usr/bin/printf "%b" "***** Nagios Host Notification*****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n\nPerformance Host Data: $HOSTPERFDATA$" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$ -r [email protected]

Services:
/usr/bin/printf "%b" "***** Nagios Service Notification*****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info: $SERVICEOUTPUT$\n\nPerformance Service Data: $SERVICEPERFDATA$" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ -r [email protected]

if you can please advise what I need to change to have it send from the [email protected] and not the above email as we have stated in the email smtp setting the correct email address and it is still not working.

Re: SMTP connect() failed on new setup

Posted: Thu Feb 10, 2022 5:07 pm
by ssax
You can change the commands to:

Hosts:

Code: Select all

/usr/bin/printf "%b" "***** Nagios Host Notification*****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n\nPerformance Host Data: $HOSTPERFDATA$" | /bin/mail -r 'Nagios XI <[email protected]>' -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
Services:

Code: Select all

/usr/bin/printf "%b" "***** Nagios Service Notification*****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info: $SERVICEOUTPUT$\n\nPerformance Service Data: $SERVICEPERFDATA$" | /bin/mail -r 'Nagios XI <[email protected]>' -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
Then apply configuration and let me know if that resolves it.

If it doesn't, we may need to adjust your /etc/postfix/main.cnf to add your mail server as a relay.

Re: SMTP connect() failed on new setup

Posted: Fri Feb 11, 2022 1:45 am
by jpdl
Thank you for your steps provided, we have made the changes provided and now no notifications are being received, it does not look like it is sending anything at the moment.
Host
/usr/bin/printf "%b" "***** Nagios Host Notification*****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n\nPerformance Host Data: $HOSTPERFDATA$" | /bin/mail -r 'Nagios XI <[email protected]>' -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$

Services
/usr/bin/printf "%b" "***** Nagios Service Notification*****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info: $SERVICEOUTPUT$\n\nPerformance Service Data: $SERVICEPERFDATA$" | /bin/mail -r 'Nagios XI <[email protected]>' -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$

Re: SMTP connect() failed on new setup

Posted: Fri Feb 11, 2022 5:19 pm
by ssax
Try this:

Host:

Code: Select all

/usr/bin/printf "%b" "***** Nagios Host Notification*****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n\nPerformance Host Data: $HOSTPERFDATA$" | /bin/mail -r '[email protected]' -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
Services:

Code: Select all

/usr/bin/printf "%b" "***** Nagios Service Notification*****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info: $SERVICEOUTPUT$\n\nPerformance Service Data: $SERVICEPERFDATA$" | /bin/mail -r '[email protected]' -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
If those don't work just remove the -r '[email protected]' from both commands, Apply Configuration, and let me know if they start working.

I know some systems that use sendmail mail command links to a different binary that uses -f or the from:

Re: SMTP connect() failed on new setup

Posted: Sat Feb 12, 2022 5:28 am
by jpdl
I have tried these and also when that line is in it does not send any notifications.
The moment I remove it and do a custom notification it sends it but is coming from the wrong email.
Can this be the admin email? if so how can we change it, or do you have any other methods we can try and force it to use the correct "from" email

Re: SMTP connect() failed on new setup

Posted: Mon Feb 14, 2022 4:14 am
by jpdl
I think we are getting closer to getting this resolved, as please see attached the email received from Nagios, so it is sending to the wrong recipients and also it is coming from the wrong address.

point 1: should send only to [email protected] (there is these two -- after the email that should be removed, don't know where to edit that), if you can please help
point 2: it is sending to nagios@kironinteractive(this is what the from address should be, and should not be sending to it)
point 3: it is sending to it to the from address which it also should not do.
point 4: I changed the admin_email in the config file to nagios@kironinteractive, and added the admin commands to hosts and services and no luck still(as below)

I will past below all the command lines that we have it at the moment.
Host by email:
/usr/bin/printf "%b" "***** Nagios Host Notification*****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n\nPerformance Host Data: $HOSTPERFDATA$" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$-- -r $ADMINEMAIL$

Service by email:
/usr/bin/printf "%b" "***** Nagios Host Notification*****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n\nPerformance Host Data: $HOSTPERFDATA$" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$-- -r $ADMINEMAIL$

so currently with the top configs it is sending to Email address that should be the "from" address, it is sending to the local email(the one that is the from address that we want changed) and sending to the correct email that is assigned to the contact(but has two -- at the end of the email causing it to not send to the recipient, we only want it to send to the contact, and use the "from" address [email protected]

Re: SMTP connect() failed on new setup

Posted: Mon Feb 14, 2022 4:24 am
by jpdl
please see attached screenshots of all contacts and their settings:
contacts.jpg
Admin.jpg
admin alert settings.jpg
notification contact.jpg
notification contact alert settings.jpg

Re: SMTP connect() failed on new setup

Posted: Mon Feb 14, 2022 4:25 am
by jpdl
notification contact assigned profile 1.jpg
notification contact assigned profile 2.jpg