Postfix for nagios email notification alerts problem
-
- Posts: 70
- Joined: Mon Aug 07, 2017 4:19 am
Postfix for nagios email notification alerts problem
Hi,
I wanted to configure nagios to use postfix and mailutils to send email alerts but ran into a problem, so i tried to remove both but if I try to install them now, I'm getting package error, i.e, no file or directory for postfix.functions and other postfix related files. I further complicated things by removing postfix.functions and other postfix related files and tried to reinstall postfix again. But, not able to install or configure them.
How to properly remove and reinstall postfix and mailutils and configure it to send email notifications alerts?
Thanks in advance for the suggestions.
I wanted to configure nagios to use postfix and mailutils to send email alerts but ran into a problem, so i tried to remove both but if I try to install them now, I'm getting package error, i.e, no file or directory for postfix.functions and other postfix related files. I further complicated things by removing postfix.functions and other postfix related files and tried to reinstall postfix again. But, not able to install or configure them.
How to properly remove and reinstall postfix and mailutils and configure it to send email notifications alerts?
Thanks in advance for the suggestions.
-
- Former Nagios Staff
- Posts: 4583
- Joined: Wed Sep 21, 2016 10:29 am
- Location: NoLo, Minneapolis, MN
- Contact:
Re: Postfix for nagios email notification alerts problem
Can you PM me your Profile? You can download it by going to Admin > System Config > System Profile and click the ***Download Profile*** button towards the top. If for whatever reason you *cannot* download the profile, please put the output of View System Info (5.3.4+, Show Profile if older) in the thread (that will at least get us some info). This will give us access to many of the logs we would otherwise ask for individually. If security is a concern, you can unzip the profile take out what you like, and then zip it up again. We may end up needing something you remove, but we can ask for that specifically.
You can also generate a profile manually using the script at /usr/local/nagiosxi/html/includes/components/profile/getprofile.sh
That should generate a profile in /usr/local/nagiosxi/var/components/ which you can get off the server with an application such as FileZilla.
After you PM the profile, please update this thread. Updating this thread is the only way for it to show back up on our dashboard.
If you get an error that PROFILE BUILD FAILED, please see https://support.nagios.com/kb/article.p ... ategory=44
You can also generate a profile manually using the script at /usr/local/nagiosxi/html/includes/components/profile/getprofile.sh
That should generate a profile in /usr/local/nagiosxi/var/components/ which you can get off the server with an application such as FileZilla.
After you PM the profile, please update this thread. Updating this thread is the only way for it to show back up on our dashboard.
If you get an error that PROFILE BUILD FAILED, please see https://support.nagios.com/kb/article.p ... ategory=44
-
- Posts: 70
- Joined: Mon Aug 07, 2017 4:19 am
Re: Postfix for nagios email notification alerts problem
Hi @dwhitfield,
I thrashed that server and installed nagios in new ubuntu 16.04 server. But i still need your help
Nagios Installation:
https://www.digitalocean.com/community/ ... requisites
Postfix:
https://www.digitalocean.com/community/ ... untu-16-04
I have used above link for installations of both nagios and postfix
Changed in commands.cfg /usr/sbin/sendmail but still not getting mail/alerts.
Error :
My main.cf
My commands.cfg
Please let me know if anything else is required.
I thrashed that server and installed nagios in new ubuntu 16.04 server. But i still need your help
Nagios Installation:
https://www.digitalocean.com/community/ ... requisites
Postfix:
https://www.digitalocean.com/community/ ... untu-16-04
I have used above link for installations of both nagios and postfix
Changed in commands.cfg /usr/sbin/sendmail but still not getting mail/alerts.
Error :
Code: Select all
$ mail
s-nail version v14.8.6. Type ? for help.
"/home/siddarth/Maildir": 4 messages 1 new 4 unread
U 1 Mail Delivery Syst Thu Jan 1 00:00 69/3099 Undelivered Mail Returned to Sender
U 2 Mail Delivery Syst Thu Jan 1 00:00 72/3371 Undelivered Mail Returned to Sender
U 3 Mail Delivery Syst Thu Jan 1 00:00 69/3105 Undelivered Mail Returned to Sender
>N 4 Mail Delivery Syst Thu Jan 1 00:00 69/3115 Undelivered Mail Returned to Sender
? q
Held 4 messages in /home/siddarth/Maildir
You have mail in /home/siddarth/Maildir
Code: Select all
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
readme_directory = no
# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = nagios.o1zkamsez5eetnxrffcr0yyteh.jx.internal.cloudapp.net
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, nagios.o1zkamsez5eetnxrffcr0yyteh.jx.internal.cloudapp.net, localhost.o1zkamsez5eetnxrffcr0yyteh.jx.internal.cloudapp.net, , localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = localhost
inet_protocols = all
home_mailbox = Maildir/
virtual_alias_maps = hash:/etc/postfix/virtual
Code: Select all
# '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" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}
# '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" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
Please let me know if anything else is required.
Re: Postfix for nagios email notification alerts problem
Can you look in the /var/log/maillog file for any errors and post them here?
That file is where postfix logs all of the email transactions when it is send them and there should be some error on why it is not sending.
That file is where postfix logs all of the email transactions when it is send them and there should be some error on why it is not sending.
Be sure to check out our Knowledgebase for helpful articles and solutions!
-
- Posts: 70
- Joined: Mon Aug 07, 2017 4:19 am
Re: Postfix for nagios email notification alerts problem
Hi @tgriep,
This is what shows in /var/log/maillog after i try to send a mail
I changed main.cf
and tried to send mail, but still got Undelivered Mail Returned to Sender
This is what shows in /var/log/maillog after i try to send a mail
Code: Select all
$sudo tail -f mail.log
Jan 16 05:54:04 nagios postfix/pickup[1740]: 0E2834111D: uid=1000 from=<from_field_account>
Jan 16 05:54:04 nagios postfix/cleanup[2714]: 0E2834111D: message-id=<20180116055404.0E2834111D@nagios.o1zkamsez5eetnxrffcr0yyteh.jx.internal.cloudapp.net>
Jan 16 05:54:04 nagios postfix/qmgr[1741]: 0E2834111D: from=<from_field_account@nagios.o1zkamsez5eetnxrffcr0yyteh.jx.internal.cloudapp.net>, size=528, nrcpt=1 (queue active)
Jan 16 05:54:04 nagios postfix/local[2718]: 0E2834111D: to=<siddu@nagios.o1zkamsez5eetnxrffcr0yyteh.jx.internal.cloudapp.net>, orig_to=<siddarth@wittyparrot.com>, relay=local, delay=0.21, delays=0.18/0.01/0/0.02, dsn=5.1.1, status=bounced (unknown user: "siddu")
Jan 16 05:54:04 nagios postfix/cleanup[2714]: 2109E4111E: message-id=<20180116055404.2109E4111E@nagios.o1zkamsez5eetnxrffcr0yyteh.jx.internal.cloudapp.net>
Jan 16 05:54:04 nagios postfix/bounce[2720]: 0E2834111D: sender non-delivery notification: 2109E4111E
Jan 16 05:54:04 nagios postfix/qmgr[1741]: 2109E4111E: from=<>, size=3035, nrcpt=1 (queue active)
Jan 16 05:54:04 nagios postfix/qmgr[1741]: 0E2834111D: removed
Jan 16 05:54:04 nagios postfix/local[2718]: 2109E4111E: to=<from_field_account@nagios.o1zkamsez5eetnxrffcr0yyteh.jx.internal.cloudapp.net>, relay=local, delay=0.09, delays=0.03/0/0/0.06, dsn=5.1.1, status=bounced (unknown user: "from_field_account")
Jan 16 05:54:04 nagios postfix/qmgr[1741]: 2109E4111E: removed
Code: Select all
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
readme_directory = no
# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = nagios.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = localhost, localhost.o1zkamsez5eetnxrffcr0yyteh.jx.internal.cloudapp.net, $myhostname, nagios.o1zkamsez5eetnxrffcr0yyteh.jx.internal.cloudapp.net
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = loopback-only
inet_protocols = all
home_mailbox = Maildir/
virtual_alias_maps = hash:/etc/postfix/virtual
Code: Select all
siddarth@nagios:/var/log$ sudo tail -f mail.log
Jan 16 07:08:17 nagios postfix/pickup[10224]: DB07B4112A: uid=1000 from=<siddarth>
Jan 16 07:08:17 nagios postfix/cleanup[10261]: DB07B4112A: message-id=<20180116070817.DB07B4112A@nagios.com>
Jan 16 07:08:17 nagios postfix/qmgr[10225]: DB07B4112A: from=<siddarth@nagios.com>, size=308, nrcpt=1 (queue active)
Jan 16 07:08:17 nagios postfix/local[10265]: DB07B4112A: to=<siddu@nagios.com>, orig_to=<siddu>, relay=local, delay=0.08, delays=0.06/0/0/0.02, dsn=5.1.1, status=bounced (unknown user: "siddu")
Jan 16 07:08:17 nagios postfix/cleanup[10261]: E9A484112B: message-id=<20180116070817.E9A484112B@nagios.com>
Jan 16 07:08:17 nagios postfix/qmgr[10225]: E9A484112B: from=<>, size=2033, nrcpt=1 (queue active)
Jan 16 07:08:17 nagios postfix/bounce[10267]: DB07B4112A: sender non-delivery notification: E9A484112B
Jan 16 07:08:17 nagios postfix/qmgr[10225]: DB07B4112A: removed
Jan 16 07:08:18 nagios postfix/local[10265]: E9A484112B: to=<siddarth@nagios.com>, relay=local, delay=0.06, delays=0.03/0/0/0.03, dsn=2.0.0, status=sent (delivered to maildir)
Jan 16 07:08:18 nagios postfix/qmgr[10225]: E9A484112B: removed
Re: Postfix for nagios email notification alerts problem
The mydestination parameter in the mail.cf file specifies what domains this machine will deliver locally, instead of forwarding to another machine.
After you changed that line, the postfix daemon is trying to send an email to the siddu@nagios.com account on the localhost (The server running postfix) and since that account is not valid, it will reject it.
One question, you you have access to a relay host to forward emails to?
If so, add that to the relayhost= option in the main.cf file so the server will forward email using that host instead if sending them to the local server where the accounts do not exist.
After you changed that line, the postfix daemon is trying to send an email to the siddu@nagios.com account on the localhost (The server running postfix) and since that account is not valid, it will reject it.
One question, you you have access to a relay host to forward emails to?
If so, add that to the relayhost= option in the main.cf file so the server will forward email using that host instead if sending them to the local server where the accounts do not exist.
Be sure to check out our Knowledgebase for helpful articles and solutions!
-
- Posts: 70
- Joined: Mon Aug 07, 2017 4:19 am
Re: Postfix for nagios email notification alerts problem
Hi @tgriep,
I got my nagios and postfix to send email alerts.
I removed postfix, mailutils and reinstalled postfix and installed heirloom-mailx. But this time, I did not change anything in postfix files but I made a change in my commands.cfg file.
I changed /usr/bin/mail -s to /usr/bin/mailx -s in # 'notify-host-by-email' command definition and # 'notify-service-by-email' command definition
Now notifications are coming.
I do however have one more thing I need your help with,
For 3 services, I'm getting this error
I followed this link https://github.com/harisekhon/nagios-plugins
But still error is displayed
Can I know how to resolve this? I'm using ubuntu 14.04 server
Thank You.
I got my nagios and postfix to send email alerts.
I removed postfix, mailutils and reinstalled postfix and installed heirloom-mailx. But this time, I did not change anything in postfix files but I made a change in my commands.cfg file.
I changed /usr/bin/mail -s to /usr/bin/mailx -s in # 'notify-host-by-email' command definition and # 'notify-service-by-email' command definition
Now notifications are coming.
I do however have one more thing I need your help with,
For 3 services, I'm getting this error
Code: Select all
(No output on stdout) stderr: Cant locate HariSekhonUtils.pm in @INC (you may need to install the HariSekhonUtils module)
But still error is displayed
Can I know how to resolve this? I'm using ubuntu 14.04 server
Thank You.
Re: Postfix for nagios email notification alerts problem
Glad that the emails are working for you now.
The service issue, it looks like there is a missing perl modules that the plugins need and it looks like you can get it at this site.
https://github.com/HariSekhon/lib
The service issue, it looks like there is a missing perl modules that the plugins need and it looks like you can get it at this site.
https://github.com/HariSekhon/lib
Be sure to check out our Knowledgebase for helpful articles and solutions!
-
- Posts: 70
- Joined: Mon Aug 07, 2017 4:19 am
Re: Postfix for nagios email notification alerts problem
Hi @tgriep,
I downloaded and ran these according to link but the issue still persists. Is there any specific folder I should download and run these? or is there any command which I should run to link these or make them look at the place I ran them (/home/siddarth)?
Also, I need to check disk space, mounted drive disk space, memory and load in my hosts. Some host servers have multiple disks attached/mounted to them which have to monitored and notified.
I don't have those commands in my commands.cfg . Where and how should i define them? How to make them work?
I downloaded and ran these according to link but the issue still persists. Is there any specific folder I should download and run these? or is there any command which I should run to link these or make them look at the place I ran them (/home/siddarth)?
Also, I need to check disk space, mounted drive disk space, memory and load in my hosts. Some host servers have multiple disks attached/mounted to them which have to monitored and notified.
I don't have those commands in my commands.cfg . Where and how should i define them? How to make them work?
Re: Postfix for nagios email notification alerts problem
In the folder where you downloaded the HariSekhon library, should be a perl module called HariSekhonUtils.pm
The documentation I found say all you need to do it to copy that module in to a folder in the PATH so the plugins can find it.
You can try and see if it works by putting it in the /usr/local/nagios/libexec folder but it id still doesn't work, you may need to contact the author.
About creating the commands, sometimes in the plugin are instructions on how to create the commands, take a look at them and see if the information is in them.
Or, if they are binary plugins, run them with the --help option and they should display the plugin's options.
These links may help.
https://nagios-plugins.org/doc/man/index.html
https://assets.nagios.com/downloads/nag ... ugins.html
The documentation I found say all you need to do it to copy that module in to a folder in the PATH so the plugins can find it.
You can try and see if it works by putting it in the /usr/local/nagios/libexec folder but it id still doesn't work, you may need to contact the author.
About creating the commands, sometimes in the plugin are instructions on how to create the commands, take a look at them and see if the information is in them.
Or, if they are binary plugins, run them with the --help option and they should display the plugin's options.
These links may help.
https://nagios-plugins.org/doc/man/index.html
https://assets.nagios.com/downloads/nag ... ugins.html
Be sure to check out our Knowledgebase for helpful articles and solutions!