Zabbix triggers

Create an item

Let's create a dummy item. Navigate to the desired host or template and select Items > Create Item.

The Zabbix trapper item type enables an agent (or in our case zabbix_sender) to submit an item value to the Zabbix server at any time; without waiting for polling intervals or active check batch sends. We’ll use a simple Text value type for storing an arbitrary timestamp as follows:

*Name: Test timestamp

*Type: Zabbix trapper

*Key: test.timestamp

*Type of information: Text

*Enabled: checked

*Click Add to save

Create a trigger

Next, create a trigger that will fire each time the value of the timestamp item changes. On your host or template, navigate to Triggers > Create trigger.

Use the diff() trigger function to identify a change in value. Also, ensure Multiple PROBLEM events generation is checked to ensure an event (and subsequent notification) is created every time the item value changes; not just the first time.

*Name: Timestamp changed

*Expression: {[host/template]:test.timestamp.diff()}>0 (replace host/template)

*Multiple PROBLEM events generation: checked

*Severity: Any (except Not classified)

*Click Add to save

Create a media type

If you intend to call a custom alert script when your trigger changes state, first define a new media type (under Administration > Media types > Create media type) with the name of your script as follows:

*Type: Script

*Script name: [Filename of your script]

*Enabled: checked

*Click Add to save

Create an action

Navigate to Configuration > Actions > Create action and enter a desirable name, default subject, and message for your action. Select the Conditions tab and add a new condition with:

*New condition: Trigger = [dummy trigger]

*Click Add to save the condition

Select the Operations tab and add a new operation as follows:

Send to Users: [user with custom media type]

Send only to: [custom media type]

Click Add to save to the operation

Add an item

Finally, click Add to save the action.

Toggle the trigger

To put the trigger into a PROBLEM state, simply submit a value for your test item using zabbix_sender that is different to the previous value. The simplest way to generate a new value on each command line call is to embed a timestamp using $(date --rfc-3339=ns). Send a new value to the Zabbix server with the following (taking care to replace all argument values with the correct values for your environment)

$ VALUE="$(date --rfc-3339=ns)"; zabbix_sender \

  --zabbix-server= \

  --host="Zabbix server" \

  --key="test.timestamp" \


To put the trigger back into an OK state (and cause a ‘Recovery message’ to be sent), simply resubmit the same item value by running the zabbix_sender command again without making a change to the VALUE environment variable:

$ zabbix_sender \

  --zabbix-server= \

  --host="Zabbix server" \

  --key="test.timestamp" \


Recent Comments

No comments

Leave a Comment