I don't have any "Notification Command" option to choose from

This forum was archived to /woltlab and is now in read-only mode.
  • I have managed to get notifications working through Director using the guide from unixe.de/icinga2-director-notifications/ (via google translate) but for some reason notifications are working only for Hosts and not Services, I'm working on figuring out why now.

    Tried that guide but the service-by-mail.sh script don't seem to be there anymore. And also, don't truly understand the "Notification" section therefore still can get hosts notifications to work either. :/ ---feeling 100% noobie

  • Still not understanding hoy to get notifications to work. Don't know which files I should modify.
    Only the preconfigured notifications for backup downtime are being sent.

  • Hi isuarezm,
    If you still having problems, I will try to explain to you how I did myself.
    I'm not sure that this is the best way, but it works for me right now. I'm still testing some components.

    The steps are:

    • Download and extract the send e-mail script from here to /opt/sendemail. I prefer this tool more that the one Icinga2 provides by default.
    • Icinga2 Director doesn't (I will probably won't in the future) use environment variables from Icinga2 core, so you will need to use a special command script that works with parameters instead. You can read more about this at this blog (Use Google translate).
    • I changed and cleaned up the two scripts to fit my needs the following way:

    Inside the director you will need to create the custom commands as notification type commands.
    Object type => Object , Command type => Notfication Plugin Command

    Then fill the details as described in the blog screenshot to map the parameters into run-time macros of Icinga2.
    Eventually, it should look like this:

    Then, when we defined out command, we need to use them for out notifications.
    Create a time period inside the Director (see details in the blog) like:

    Now we can use the notification commands and the time period to apply them to a notification rule.
    Go to notification settings inside the Director and create notification object for host and for service (remember we have two commands).
    Create one template for host and one for services, where you use your custom command and time period.
    Next step is to assign and apply rule. Just use the "Enable notification => True" system it globally.
    This way we send notification for all our hosts that we defined to notification true in the host template (and service template too).

    Now create a failing service and see if you get any e-mail.

  • Wao, thanks for that YevgenyTr!! Will try it out as soon as possible and give my feedback!
    Don't think I need the screenshots for now. You explained it very well I think.

  • I can confirm that YevgenyTr's method works. The only thing I don't have working or don't properly understand out of his scripts is the Comment by lines. I put a test comment into a host I am getting an alert on and I am not getting any comments passed into the scripts. But the rest is all working. It could just be that I don't understand where these comments are supposed to be pulled from.

  • Hi Yevgeny,

    I followed most of your instructions, and finally i got it working. But two things i had to work around..

    1. "Go to notification settings inside the Director and create notification object for host and for service (remember we have two commands)."
    Here i found finally that we don't need objects, but templates. (see also https://dev.icinga.org/issues/12671 #3)

    2. When i add the apply rule as you stated: "Enable notification = true" i get the following warning when i apply:
    warning/ApplyRule: Apply rule 'service-apply-rule' (in notification_apply.conf: 9:1-9:50) for type 'Notification' does not match anywhere!

    So i worked around this by setting the rule to "Enable notification != false", but i wonder why it doesn't work... What did you mean by 'system it globally.' ?

  • Hi,
    Sorry for the late response.

    1. There are both template and object that is related to the template (not confusing enough, eh?). The notification object is an apply rule.

    Code: zones.d/icinga2.orbotech.org/notification_templates.conf
    1. template Notification "service-alert" {
    2. command = "service-by-mail"
    3. period = "always"
    4. }

    Then the apply rule:

    2. "enable_notification => true" should work as it is. What is the full error you get?

    "system it" was probably a typo I made. I meant assign it. :)

  • Hi Yevgeny,

    Thanks for your reply. In the notification_apply.conf i had the following:

    1. apply Notification "service-apply-rule" to Service {
    2. import "generic-service-alarm"
    3. user_groups = [ "Admins" ]
    4. assign where host.enable_notifications == "true"
    5. }

    It looks like i first need to match the host before i can match any other rule? (If i understand it right.)
    I added the match * for the host.name, and it works now.

    I found in the Icinga docs that multiple assignment rules are read as 'or', so i guess for me the host.enable_notifications rule is not working at all.. :-(
    For now this is working, but i have to dive into that deeper..

    Gerrit Doornenbal.