| 49 | |
| 50 | === Enable Email Notifications from Director === |
| 51 | |
| 52 | On Icinga2, we can define custom scripts to execute different notifications. We use this feature to send emails and other notifications. For the simplicity we have created few scripts so it will enable us to put notifications when host or service category makes alerts. |
| 53 | |
| 54 | Download email scripts to the scripts directory. |
| 55 | |
| 56 | {{{ |
| 57 | #!sh |
| 58 | cd /etc/icinga2/scripts |
| 59 | |
| 60 | wget https://raw.githubusercontent.com/LEARN-LK/Tutorials/master/Scripts/ICINGA2/icinga2-mail-host.sh |
| 61 | |
| 62 | wget https://raw.githubusercontent.com/LEARN-LK/Tutorials/master/Scripts/ICINGA2/icinga2-mail-service.sh |
| 63 | |
| 64 | chmod +x icinga2-mail-host.sh |
| 65 | |
| 66 | chmod +x icinga2-mail-service.sh |
| 67 | }}} |
| 68 | |
| 69 | |
| 70 | Next, on Icinga Director go to Commands |
| 71 | |
| 72 | [[Image(Ici-Di-Commands.png, 400px, nolink)]] |
| 73 | |
| 74 | Click `Add` to Add new Icinga Command with the following details. |
| 75 | |
| 76 | * Command Type: `Notification Plugin Command` |
| 77 | * Command Name: `Host Alarm By Email` |
| 78 | * Command: `/etc/icinga2/scripts/host-by-mail.sh` |
| 79 | |
| 80 | and click add. Now go to the `Arguments` tab of the created command. Then add an Argument like, |
| 81 | |
| 82 | Argument name: `-4`[[br]] |
| 83 | (Make sure you put the - symbol)[[br]] |
| 84 | Value type: `String`[[br]] |
| 85 | Value: `$address$`[[br]] |
| 86 | Required: `Yes` |
| 87 | |
| 88 | and Click `Add`. |
| 89 | |
| 90 | Next Click Back button [[Image(BackBtn.png, 100px, nolink)]] just below the command name on Top of the tab. |
| 91 | |
| 92 | Repeat above step and add following arguments as well |
| 93 | |
| 94 | [[Image(HostEmail.png, 400px, nolink)]] |
| 95 | |
| 96 | |
| 97 | |