Hi, i’m using icinga2 and i want to get notified by mail when something is on critical, i already have postfix and a mailserver for my network.
i can send mail from my icinga server to any address on my network, so i’m asking what configuration i do need to get notified.
thank you
Hi,
I’d suggest following the documentation on the monitoring basics and learn about notifications. Once you have created some User and Notification objects/apply rules, please share them in case they are not working as expected.
Cheers,
Michael
thank you for the documentation, i did this in my users.conf:
But now even with the docs i don’t really know what to do.
My goal is o get notified when something is on critical, i would like to know what i got to to like commands or something else in my conf to get it.
thank you
You’ll also need a Notification object/apply rule, which defines the notification for a host/service object, and links the users and the executed command (you can use the pre-defined one shown in the docs).
Cheers,
Michael
I need to create a notification object for each host/service ? or is there a possibility to make them all in one ?
thanks
I’d suggest learning more about apply rules which can help creating these objects based on patterns.
As I am adding quite a few docs links here, can you shed some light on the problems you’re having with the docs, are they unclear, or is it more of a general understanding issue?
Cheers,
Michael
ok, now i got this:
users.conf :
The mail adress i put in there is the mail from the sender or the one who will receive the mail .
notification.conf:
command.conf:
but i got an error message that says code is wrong and i don’t know where
and in my hosts;conf:

and it still doesn’t .
thank you
Please share the output of icinga2 daemon -C
being the full config validation.
Also, please do not take screenshots of your terminal. It is barely readable and if we want to copy some config blocks to show you how things are done, we just can’t. I for myself won’t re-type the things.
Instead, use the code blocks to copy the text output in here, and let it format with surrounding 3 back ticks like so
```
log line 1
log line 2
```
You can find more details in this howto: Create topics and master Markdown formatting
Cheers,
Michael
Oh wait this is the real output sorry
root@srv-supervision:/etc/icinga2/conf.d# icinga2 daemon -C
[2020-02-07 09:52:42 +0100] information/cli: Icinga application loader (version: r2.11.2-1)
[2020-02-07 09:52:42 +0100] information/cli: Loading configuration file(s).
[2020-02-07 09:52:42 +0100] critical/config: Error: syntax error, unexpected / (T_DIVIDE_OP), expecting $end
Location: in /etc/icinga2/conf.d/commands.conf: 147:1-147:1
/etc/icinga2/conf.d/commands.conf(145):
/etc/icinga2/conf.d/commands.conf(146):
/etc/icinga2/conf.d/commands.conf(147): /
^
/etc/icinga2/conf.d/commands.conf(148): object NotificationCommand “mail-host-notification” {
/etc/icinga2/conf.d/commands.conf(149): command = [ ConfigDir + “/scripts/mail-host-notification.sh” ]
[2020-02-07 09:52:42 +0100] critical/cli: Config validation failed. Re-run with ‘icinga2 daemon -C’ after fixing the config.
Seems you have a single /
character in the mentioned line. Icinga expects //
being a comment, similar to #
. You can learn more about the language and especially comments here.
Cheers,
Michael
root@srv-supervision:/etc/icinga2/conf.d# icinga2 daemon -C
[2020-02-07 10:31:33 +0100] information/cli: Icinga application loader (version: r2.11.2-1)
[2020-02-07 10:31:33 +0100] information/cli: Loading configuration file(s).
[2020-02-07 10:31:33 +0100] critical/config: Error: Object ‘mail-host-notification’ of type ‘NotificationCommand’ re-defined: in /etc/icinga2/conf.d/commands.conf: 148:1-148:51; previous definition: in /etc/icinga2/conf.d/commands.conf: 9:1-9:51
Location: in /etc/icinga2/conf.d/commands.conf: 148:1-148:51
/etc/icinga2/conf.d/commands.conf(146):
/etc/icinga2/conf.d/commands.conf(147):
/etc/icinga2/conf.d/commands.conf(148): object NotificationCommand “mail-host-notification” {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/etc/icinga2/conf.d/commands.conf(149): command = [ ConfigDir + “/scripts/mail-host-notification.sh” ]
/etc/icinga2/conf.d/commands.conf(150):
[2020-02-07 10:31:33 +0100] critical/cli: Config validation failed. Re-run with ‘icinga2 daemon -C’ after fixing the config.
root@srv-supervision:/etc/icinga2/conf.d#
now i have this and i can’t see the mistake
It says that the object has been re-defined.
- /etc/icinga2/conf.d/commands.conf: in line:character 148:1-148:51
- /etc/icinga2/conf.d/commands.conf: in line:character 9:1-9:51
Remove one or the other.
Cheers,
Michael
Thanks, no erro messages now but notifications still aren’t sen even when i do manual notifs on my icinga web i don’t get them.
What is wrong ?
thanks
Here’s some steps you can follow: https://icinga.com/docs/icinga2/latest/doc/15-troubleshooting/#notifications-troubleshooting
Cheers,
Michael
object User “icingaadmin” {
import “generic-user”
display_name = “Icinga 2 Admin”
groups = [ “icingaadmins” ]
enable_notifications = true
states = [Critical]
types = [Problem]
email = “tournus@supervision.com”
}
I have a question, the mail address i put here is the one who will send the email or the one witch the mail will be sent to ?
user.email is the recipient. This will be evaluated inside the NotificationCommand as runtime macro, and passed to the mail notification scripts. Whenever a notification is triggered, the command gets executed. If there are failures, this can be seen in the icinga2.log. Some common ones are the missing mail binary, or a wrong configured MTA.
Cheers,
Michael
When i try to use the command in the shell i get this error message, what do i have to install ?
root@srv-supervision:/etc/icinga2/scripts# ./mail-service-notification.sh
mail not found in $PATH. Consider installing it.
root@srv-supervision:/etc/icinga2/scripts#
Thanks
You need to install a mail client (MUA). For Debian/Ubuntu we use bsd-mailx.
i have postfix and it works with my mail server isn’t that enough ?
No, it’s not enough. You need to have a mail client which handover mails to postfix.