Zabbix Documentation 2.0

1.8  
2.0
  2.2  2.4  3.0  3.2  3.4

User Tools

Site Tools


Sidebar

manual:config:notifications:media:script

5 Custom alertscripts

Overview

If you are not satisfied with existing media types for sending alerts there is an alternative way to do that. You can create a script that will handle the notification your way. These scripts are located in the directory defined in the Zabbix server configuration file AlertScriptsPath variable. When alert script is executed it gets 3 command-line variables (as $1, $2 and $3 respectively):

  • To
  • Subject
  • Message

Alert scripts are executed on the Zabbix server.

The recipient (“To”) is specified in user media properties. Here is an example alert script:

#!/bin/bash
 
to=$1
subject=$2
body=$3
 
cat <<EOF | mail -s "$subject" "$to"
$body
EOF

Environment variables are not preserved or created for the script, so they should be handled explicitly.

Configuration

To configure custom alertscripts as the media type:

  • Go to Administration→Media types
  • Click on Create media type

Media type attributes:

ParameterDescription
Description Name of the media type.
Type Select Script as the type.
Script name Enter the name of the script.

User media

To assign custom alertscripts to the user:

  • Go to Administration→Users
  • Open the user properties form
  • In Media tab, click on Add

User media attributes:

ParameterDescription
Type Select the custom alertscripts media type.
Send to Specify the recipient to receive the alerts.
When active You can limit the time when alertscripts are executed, for example, the working days only (1-5,09:00-18:00).
See the Time period specification page for description of the format.
Use if severity Mark the checkboxes of trigger severities that you want to activate the alertscript for.
Status Status of the user media.
Enabled - is in use.
Disabled - is not being used.