Setup Email notifications



The best monitoring system can be useless, if it is not possible to send notifications.

A basic notification method you definitely should set up on your installation is, notifying by email. Most companies already have their own mail server. To keep things simple, we will show you, how to use the existing mail server as relay host.

Install Postfix mail server

We recommend to use Postfix as layer between your existing company mail server, and the monitoring system.

apt-get install postfix

Now we are going to set the ip address of your companies mail server at /etc/postfix/main.cf.

relayhost = 192.168.1.1

To enable the new configuration, just restart postfix.

systemctl restart postfix

Set email configuration for openITCOCKPIT

The mail configuration for openITCOCKPIT will be set in the file /etc/openitcockpit/app/Config/email.php

The configuration for a local Postfix is very simple. Just set 127.0.0.1 as host, port to 25 and username and passwordto null.

You can also just use the following configuration:

<?php
class EmailConfig {
    public $default = array(
        "transport" => "Smtp",
        "host" => "127.0.0.1",
        "port" => 25,
        "username" => null,
        "password" => null,
    );

    public $fast = array(
        "from" => "you@localhost",
        "sender" => null,
        "to" => null,
        "cc" => null,
        "bcc" => null,
        "replyTo" => null,
        "readReceipt" => null,
        "returnPath" => null,
        "messageId" => true,
        "subject" => null,
        "message" => null,
        "headers" => null,
        "viewRender" => null,
        "template" => false,
        "layout" => false,
        "viewVars" => null,
        "attachments" => null,
        "emailFormat" => null,
        "transport" => "Smtp",
        "host" => "localhost",
        "port" => 25,
        "timeout" => 30,
        "username" => "user",
        "password" => "secret",
        "client" => null,
        "log" => true
    );
}

Change Sender address

If you want to change the email sender address, go to Administration System Settings:

Create a new contact

To test your new mail system, you need to create a new contact with your email address.

Now assign the contact to a host or service.

To enable the new configuration, you need to "Refresh the monitoring configuration".

Test email notification

Select the host or service on which you have added your contact. In this example, we added the contact to the Ping service. Now click on "Send custom service notification"

Go with the default settings and press on "Send".

Check your inbox for the mail.

Email not received?

Run the command oitc debug --tailf to get more information from the logs.

[31.01.2018 - 12:22:51] SERVICE NOTIFICATION: Demo Contact[376a2dcf-ba7c-40be-b5ef-1b46c59a85cf];My first Linux host[c963e9f2-a1cb-43f6-8ad6-0babe02294c9];Ping[80ff370a-deff-4b8b-a37c-677a22d2e7a6];CUSTOM (OK);service-notify-by-cake[a517bbb6-f299-4b57-9865-a4e0b70597e4];PING OK - Packet loss = 0%, RTA = 0.28 ms;John Doe;test notification