This GitHub repository contains a script for integrating Gotify to be able send notifications with Zabbix. Follow these instructions to set up and use the script with your Zabbix and Gotify instances.
- Zabbix Server (version 5.0 or later recommended)
- Access to the Zabbix server with admin privileges
- A ready-to-use Gotify instance
Before setting up the script, you will need to create an application in Gotify to generate an API token.
-
Log into your Gotify server:
- Login to the Gotify UI via your web browser.
-
Create a new application:
- Navigate to the
Appssection; - Press on
Create App; - Enter the name for your application, for example
Zabbix Notifications; - Press
Create.
- Navigate to the
-
Copy the API Token:
- Once the application is created, you'll see an API Token.
- Copy this token as it will be used in the
gotify.shscript.
-
Clone the repository or download
gotify.shfrom this repository. -
Edit
gotify.shto set up your Gotify server details:- Replace
http://change.mewith your Gotify server URL. For example,http://10.94.1.198orhttps://gotify.example.com.
- Replace
-
Copy the script to the Zabbix alertscripts directory, typically located at
/usr/lib/zabbix/alertscripts/.sudo cp gotify.sh /usr/lib/zabbix/alertscripts/
-
Make the script executable:
sudo chmod +x /usr/lib/zabbix/alertscripts/gotify.sh
-
Log into your Zabbix frontend.
-
Navigate to
Administration > Media Typesand clickCreate Media Type. -
Select
Scriptas the type and add a name, likeGotify. -
For the script name, enter
gotify.sh. -
Define the following parameters:
{ALERT.SENDTO}- Gotify API Token{ALERT.SUBJECT}- Notification subject{ALERT.MESSAGE}- Notification message{TRIGGER.SEVERITY}- Trigger severity (used to determine priority in Gotify)
-
Configure Message Templates:
- Navigate to the
Message templatestab. - Create templates for the different conditions under which notifications should be sent. Each template should specify the message format for the subject and body.
- Navigate to the
-
Save the new Media Type.
-
In Zabbix frontend, go to
Administration > Users. -
Edit the user who should receive Gotify notifications.
-
Under the
Mediatab, add the Gotify media type. -
In the
Send tofield, enter your Gotify API Token. -
Save the changes.
Create a test trigger or wait for an actual alert to verify that notifications are being sent correctly to Gotify.
- Ensure, that you have replaced
http://change.mein thegotify.shscript with your actual Gotify server URL. - The mapping between Zabbix severity levels and Gotify priorities can be adjusted within the script as per your requirements.
