Setup Email Notification through Icinga Director

This forum was archived to /woltlab and is now in read-only mode.
  • Hi,


    I have completed the setup of Icinga Web 2 with Director. I can connect to hosts and monitor their status through the icinga portal. However, I would like to receive email notifications when any of my Host is down, etc. I read through multiple forums but am still not able to get notifications when the host goes down. I will highly appreciate if any one can help me in setting up the SMTP/MTA service to send out the notifications when any host goes down, preferably through the director. I will also appreciate if you can give me a step by step guidance.


    Thanks in advance.


    AQ

  • Please add more details on the current involved versions, your configuration, anything already done/prepared inside the Director (screenshots, etc.).


    More hints on how to collect such: https://monitoring-portal.org/cms/index.php?faq/

  • ashahid,


    It sounds like maybe you want to control notifications through Director, matching how you setup your monitoring. The Icinga2 documentation listed above is great and in-depth, but it does everything with the Icinga config files, not using Director. If you need to get more control and customization down the road you may need to use the config files, but it is possible to do basic notifications with Director.


    High-level for basic Up/Down notifications:

    • In Icinga Director, go to the notifications section
    • Under Director -> Notifications -> Users/Contacts, you need to setup a user
    • Under Director -> Notifications -> Timeperiods, you need to create at least one time period.
      • First create a "generic" timeperiod to use as the template for all future timeperiods you create
      • To start, you can create an "always" timeperiod that is not restricted to days or times.


    Under Director -> Notifications -> Notification Templates, you need to create a template



    Under Director -> Notifications -> Notifications, create a notification using the template you just made. The problem I ran into on this page (and several other users as well when searching online) was that you can't set the filter to say "apply where notifications=true". If you notice in the screen shot, you have to tell it to assign where the host notification flag is NOT FALSE. Winds up being the same as setting it to TRUE, but just the way the system works right now it doesn't recognize TRUE on that value.


    At this point you should start receiving email notifications. If you open a specific host within Icinga web, you'll have a check box to disable notifications on that specific host if you desire.


    If you are not receiving emails, you may need to troubleshoot and make sure that your server itself is able to send out emails - a whole different discussion.



    Edit: Forgot to add step(s) for timeperiods

  • Hello-


    I appologize fore not giving out enough information. I have an update, after going through multiple forums and videos I configured the postfix mail SMTP. the output is stated below:


    Output from vim /etc/postfix/main.cf


    myhostname = contoso.com

    relayhost = [mail.contoso.com]:25

    smtp_use_tls = yes

    smtp_sasl_auth_enable = yes

    smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd

    smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt

    smtp_sasl_security_options = noanonymous

    smtp_sasl_tls_security_options = noanonymous


    I replaced my company’s domain with “contoso” for security purposes.




    However, I receive a bounce back whenever I try to send an email through cli. Results below:


    Output from vim /var/spool/mail/root


    The mail system


    <ashahid@contoso.com>: unknown user: "ashahid"


    --2CAE4EC2EB.1509457728/contoso.com

    Content-Description: Delivery report

    Content-Type: message/delivery-status


    Reporting-MTA: dns; contoso.com

    X-Postfix-Queue-ID: 2CAE4EC2EB

    X-Postfix-Sender: rfc822; root@contoso.com

    Arrival-Date: Tue, 31 Oct 2017 08:48:48 -0500 (CDT)


    Final-Recipient: rfc822; ashahid@contoso.com

    Action: failed

    Status: 5.1.1

    Diagnostic-Code: X-Postfix; unknown user: "ashahid"


    --2CAE4EC2EB.1509457728/contoso.com

    Content-Description: Undelivered Message

    Content-Type: message/rfc822


    Return-Path: <root@contoso.com>

    Received: by contoso.com (Postfix, from userid 0)

    id 2CAE4EC2EB; Tue, 31 Oct 2017 08:48:48 -0500 (CDT)

    Date: Tue, 31 Oct 2017 08:48:48 -0500

    To: ashahid@contoso.com

    Subject: Test Mail

    User-Agent: Heirloom mailx 12.5 7/5/10

    MIME-Version: 1.0

    Content-Type: text/plain; charset=us-ascii

    Content-Transfer-Encoding: 7bit

    Message-Id: <20171031134848.2CAE4EC2EB@contoso.com>

    From: root@contoso.com (root)


    icinga test


    --2CAE4EC2EB.1509457728/contoso.com—


    Similarly, I replaced my company’s domain with contoso.com for security purposes.




    I added the smtp user settings in the sasl_passwd file and the output is shown below:



    Output from vim /etc/postfix/sasl_passwd


    [mail.contoso.com]:25 mon@contoso.com:password123


    Is there any thing I am missing here? Also, do I have to do something to integrate postfix with icinga? (I have already setup notifications)


    I have attached a snapshot of the About page of my Icinga Host.


    Thanks,


    AQ


    Edit: I am using CentOS 7

  • Update:


    After a lot of tweaking and modifications on my postfix config file, I was able to send out emails.


    pillbug22, thank you for the tip on the Director part. Got that working as well.


    Question:


    If I want to update the notifications through the CLI, what is the location for it? I am getting the basic notifications for now, i.e. Host up or down. But, I want to make it even more detailed.


    I will appreciate if anyone can let me know where are the notification settings stored in the config file as i would like to dig deeper.


    Thanks much!

  • pillbug22,


    After following your directions and setting up the notifications through the director, I can receive alerts when the host is down. However, I don't receive an email when the host is back up. I have the same configuration as you.


    Any suggestions?


    Thanks

  • Wolfgang,


    I am using the Director for the notifications. Do you know what is the location for the notification templates if I use the CLI?


    Thanks

  • Thanks for getting back. I am pretty new to Linux that's why I'm not able to figure some stuff out.


    In the documentation, it states the following:


    Code
    1. template Notification "generic-notification" { interval = 15m
    2. command = "mail-service-notification"
    3. states = [ Warning, Critical, Unknown ] types = [ Problem, Acknowledgement, Recovery, Custom, FlappingStart, FlappingEnd, DowntimeStart, DowntimeEnd, DowntimeRemoved ]
    4. period = "24x7"
    5. }


    Now, Where do I have to go to enter this code? and create a notification template and then a notification?


    Sorry if this sounds stupid.


    Thanks

  • The Icinga 2 documentation does not know anything about the Director, and puts focus on modifying the configuration objects on disk with your preferred editor.


    Since you've chosen to use the Icinga Director, you should get familiar with its interface, and where to put notification templates and apply rules via the web interface.

  • I am pretty much familiar with Director now but I believe there are some bugs in it as some features although set correctly does not work correctly.


    I am planning to use the cli and create/modify, etc with nano/vim and setup my hosts and notifications and stop using director altogether.


    I will highly appreciate if you can tell me the icinga directory to create hosts and setup notifications. I read the documentation but it is a bit confusing. I.e. I don't know the location of the config file, where I have to add the code.


    Thanks much

  • You can put it wherever you like. Everything which is included in the main icinga2.conf file (which is read by the daemon on startup/reload) will get compiled into config objects.


    If you are for instance only monitoring remote objects via ping, http, conf.d is sufficient. Or "objects.d" or anything else you can put your own structure on it.

    https://www.icinga.com/docs/ic…nga-2/#your-configuration


    If you're going the way of distributed monitoring where configuration synchronization is involved, head to the respective chapter with zones.d and whatnot.


    TL;DR - it doesn't matter how you call your configuration or where they are in /etc/icinga2 - just ensure that they are included in icinga2.conf

  • Now it makes much more sense. Thanks a lot. I will just start monitoring without the Director. The concept is pretty good for the director but there are some bugs.


    Thanks a lot.


    I will give it a try and will let you know

  • Sorry for the late update.


    So, I played around with the Director for one last time and the notifications started to come through. Yayyy!


    Thanks a lot for all the advice's, much appreciated!