| Dieser Inhalt in deutsch |

Debian Squeeze - Icinga and Postfix

Situation

Icinga is installed and working properly.

Goal

The system will send an e-mail if one of the monitored devices or services is something wrong.

Solution

A 'simple' solution is it to install 'qpopper' to retriieve e-mails from the local user itself. That worked in a test immediately. The obvious drawback is that it depends on the retrieving the e-mail if and when the message is known about a problem.

The better way st it to configure the system in a way that Icinga sends a message itself to the mail server of the domain and windows domain. I did it with Postfix. The configuration is similar to that which is described in the instructions to a mail relay on this website here.

Install Postfix

Input:

# apt-get install postfix

If asked choose Internet-Site.

Example: /etc/postfix/main.cf

# 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 (Debian/GNU)
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.

# deaktivating myhostname, using mydomain, main.cf can be used more flexible
# mac be copied on different computer.
# Postfix istself looks for myhostname in the system
#myhostname = icinga.domainname.local
mydomain = domainname.local
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
#myorigin = /etc/mailname
myorigin = $mydomain
# changed mydestination - final determination of the emails
# mydestination = mailrelay.domainname.local, localhost.domainname.local, , localhost
mydestination = $mydomain
$myhostname
relayhost = [123.123.123.123]
mynetworks = 123.123.123.123/32,
127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
#inet_interfaces = loopback-only
inet_interfaces = all
# the transport file has to be configured seperatly.
transport_maps = hash:/etc/postfix/transport
unknown_local_recipient_reject_code = 550
relay_domains = domainname.de

Create and mount transport entry

Postfix has to know to which internal mail server the e-mails shoul be forwarded. Here the domain name (domainname.de) is specified as found on the Internet.

Input:

# touch /etc/postfix/transport

Content in the first line of this file:

domainname.de smtp:[ip-address]

The brackets [] have to be in the file.

Creating the transport.db.

Input:

# postmap hash:/etc/postfix/transport

Sure, there will be a problem if icinga or the mailserver himself don't work correct.

Let changes tak effect
# /etc/init.d/postfix reload