5 Templates - moudsen/mailGraph GitHub Wiki

MailGraph uses TWIG (https://twig.symfony.com/doc/3.x/) as the template processor, where the following macros are available for your convenience in combination with the flexibility of in-template functions (like "if" statements).

Feel free to adjust the html.template and plain.template files as you see fit for your situation!

Values available from MailGraph:

TWIG macro Description
{{ baseURL }} Base url of the Zabbix system (use for references to API and login).
{{ TRIGGER_ID }} Id of the applicable trigger.
{{ TRIGGER_DESCRIPTION }} Raw trigger description (note: macros are not parsed!).
{{ TRIGGER_COMMENTS }} Comments of the trigger.
{{ TRIGGER_URL }} URL of the trigger form in Zabbix.
{{ ITEM_ID }} Id of the associated item to the trigger.
{{ ITEM_KEY }} Key of the item.
{{ ITEM_NAME }} Item name.
{{ ITEM_DESCRIPTION }} Description of the item.
{{ ITEM_LASTVALUE }} Last value of the item.
{{ ITEM_PREVIOUSVALUE }} The value of the before LASTVALUE.
{{ ITEM_URL }} URL of the item form in Zabbix.
{{ HOST_ID }} Id of the associated host to the item.
{{ HOST_NAME }} The name of the host.
{{ HOST_ERROR }} Last error state of the applicable host.
{{ HOST_DESCRIPTION }} Description of the host.
{{ HOST_URL }} URL of the host form in Zabbix.
{{ EVENT_ID }} Id of the associated event.
{{ EVENT_NAME }} Name of the event (note: macros are parsed!).
{{ EVENT_OPDATA }} Associated operational data of the event.
{{ EVENT_VALUE }} event state (0=Recovered, 1=Triggered/Active).
{{ EVENT_SEVERITY }} Severity of the event.
{{ EVENT_STATUS }} Status of the event.
{{ EVENT_URL }} URL of the event details in Zabbix.
{{ ACK_URL }} URL that jumps straight to the Acknowledge editor for the given event.
{{ GRAPH_ID }} Id of the associated ITEM graph to the Trigger.
{{ GRAPH_NAME }} The (Zabbix) name of this ITEM graph.
{{ GRAPH_MATCH }} Whether the located ITEM graph directly relates to the main trigger item or not ('Exact','Other').
{{ GRAPH_ZABBIXLINK }} URL of the ITEM graph form in Zabbix.
{{ <GRAPHS_I>.PATH }} (Array) Absolute path to the generated ITEM image.
{{ <GRAPHS_I>.URL }} (Array) URL to the ITEM graph (assuming script produces to an accessible location for plain mails).
{{ <GRAPHS_I>.HEADER }} (Array) Header of the ITEM graph.
{{ <GRAPHS_I>.CID }} (Array) IMG embed string (<img src="{{ <GRAPHS_I>.CID }}" />).
{{ TRIGGER_SCREEN }} Screen ID from the defined Trigger tag.
{{ <GRAPHS_T>.PATH }} (Array) Absolute path to the generated TRIGGER image.
{{ <GRAPHS_T>.URL }} (Array) URL to the TRIGGER graph (assuming script produces to an accessible location for plain mails).
{{ <GRAPHS_T>.CID }} (Array) IMG embed string (<img src="{{ <GRAPHS_T>.CID }}" />).
{{ GRAPHS_T_LINK }} URL to the Zabbix SCREEN of the Trigger from which the images were taken.
{{ GRAPHS_T_HEADER }} The Zabbix SCREEN name.
{{ GRAPHS_T_PERIODHEADER }} Header to display representing the time period (defaults to period in config.json or to the mailGraph.screenPeriod Tag of the Trigger).
{{ HOST_SCREEN }} Screen ID from the defined Host tag.
{{ <GRAPHS_H>.PATH }} (Array) Absolute path to the generated HOST image.
{{ <GRAPHS_H>.URL }} (Array) URL to the HOST graph (assuming script produces to an accessible location for plain mails).
{{ <GRAPHS_H>.CID }} (Array) IMG embed string (<img src="{{ <GRAPHS_H>.CID }}" />).
{{ GRAPHS_H_LINK }} URL to the Zabbix SCREEN of the Host from which the images were taken.
{{ GRAPHS_H_HEADER }} The Zabbix SCREEN name.
{{ GRAPHS_H_PERIODHEADER }} Header to display representing the time period (defaults to period in config.json or to the mailGraph.screenPeriod Tag of the Host).
{{ <ACKNOWLEDGES> }} (Array) Contains an array of changes and messages when acknowledging an event. Please refer to the bottom of this page for more detailed information.
{{ LOG_HTML }} Script log in HTML format
{{ LOG_PLAIN }} Script log in PLAIN text format

You can define CUSTOM information that is passed from Zabbix by introducing a Macro in Zabbix in the MailGraph Media type of which the name starts with 'info'. Each infoXXX will be made available for use in the template as {{ infoXXX }} with exactly the same name and will be HTML-escaped automatically.

This allows you to add any other information you want to pass from Zabbix straight into the template ...

ACKNOWLEDGES array detail

The following fields are available for each ACKNOWLEDGES record:

Field name (for use in TWIG) Additional information (and generated fields)
acknowledgeid Acknowledgement ID
userid User ID.
eventid Source Event ID.
clock Unix time when the updated was posted. Use "_clock" for a date/time formatted string.
message Actual message included in the post.
action Bitmask representing the actual changes performed. Use "_actions" for a formatted string.
old_severity Original severity level. Use "_old_severity" for a formatted string.
new_severity New severity level. Use "_new_severity" for a formatted string.
username Username of the person that has posted the update.
name First name of this person.
surname Last name of this person.
⚠️ **GitHub.com Fallback** ⚠️