Notifications
Introduction
Notifications are used to be informed about the status of services in the event of problems. You can set up in detail which status a notification is sent for.
In order for notifications to work, configuration must be made in various places in the WebGUI. These are
- Message services
- Contacts
- Contact groups
Message services
The sending type of notifications is defined via message services. There are three variants to choose from in the WebGUI:
- Sendmail
- HTTP
- Script
Sendmail
As the name implies, the Sendmail variant is used to send notifications via e-mail. The sendmail program is used to send the e-mail, which can be installed and set up with an MTA such as Postfix or Exim. It is important to define a valid sender. You can use the MTA to control whether e-mails are to be sent via a relay or directly via user/password via SMTP.
HTTP
This message service is used to send notifications via HTTP. The post data can be sent URL-encoded or in JSON format. In this way, messages can be sent to a variety of message services, such as SMS, chats and ticket systems, if they have an HTTP interface.
Script
If the functionality of the other message services is not sufficient, it is also possible to develop your own script for sending messages and integrate it into the WebGUI.
To do this, the script must be stored under the path that is set up with the parameter message_service_script_path in the Bloonix server configuration.
We would like to demonstrate this with a small example. For example, let’s say you have a script called test.py. Save the script under the path /usr/local/lib/bloonix/message-service. The script could have the following content:
#> cat /usr/local/lib/bloonix/message-service/test.py
#!/usr/bin/python3
import json
import sys
lines = ""
while True:
try:
line = input()
except EOFError:
break
lines += line
param = json.loads(lines)
f = open("/tmp/test.log", "w")
f.write(json.dumps(param))
f.close()
sys.exit(0)
Now create a new message service of type Script via the WebGUI and enter the following values as an example:
What happens when an alarm is triggered is that the parameters defined in the WebGUI are passed to the script via STDIN in JSON format. The exit code tells the Bloonix server whether sending the message was successful: 0 = ok, 1 = not successful.
After successful execution, the file /tmp/test.log should contain the following entry:
{
"message": "a long message generated from the message template ...",
"send_to": "contact address ...",
"foo": "bar",
}
Contacts
Contacts are used to set up people to whom notifications will ultimately be sent. Any number of message services can be assigned to a contact. In addition, each message service can be used to define time periods when notifications are sent. The syntax for this is as follows:
Syntax: DAY RANGE TIME RANGE DAY RANGE EXAMPLES ------------------------------------------------------------ Weekday Monday Weekday - Weekday Monday - Friday Month Januar Month - Month Januar - July Month Day Januar 1 Month Day - Month Day Januar 1 - July 15 Year 2010 Year - Year 2010 - 2012 YYYY-MM-DD 2010-01-01 YYYY-MM-DD - YYYY-MM-DD 2010-01-01 - 2012-06-15 TIME RANGE EXAMPLES ------------------------------------------------------------ HH:MM - HH:MM 09:00 - 17:00 HH:MM - HH:MM, HH:MM - HH:MM 00:00 - 08:59, 17:01 - 23:59
Contact groups
In the final step, contacts are linked to hosts and services via contact groups. This allows you to define exactly which contacts should be contacted if certain hosts and services fail.
You should make sure that each host is assigned to at least one contact group so that if problems occur, someone is informed of the status of the hosts.