Added debugging references to Zabbix problem templates to support easy debugging - v1.10

This commit is contained in:
Mark Oudsen 2021-02-27 17:36:06 +01:00
parent 38da0bcfd3
commit bb2e8278c1

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<zabbix_export> <zabbix_export>
<version>5.0</version> <version>5.0</version>
<date>2021-02-27T12:14:57Z</date> <date>2021-02-27T16:34:16Z</date>
<media_types> <media_types>
<media_type> <media_type>
<name>MailGraph</name> <name>MailGraph</name>
@ -9,7 +9,7 @@
<parameters> <parameters>
<parameter> <parameter>
<name>baseURL</name> <name>baseURL</name>
<value>https://mydomain.com/zabbix</value> <value>https://zbx.puzzl.nl/zabbix/</value>
</parameter> </parameter>
<parameter> <parameter>
<name>duration</name> <name>duration</name>
@ -57,159 +57,148 @@
</parameter> </parameter>
<parameter> <parameter>
<name>URL</name> <name>URL</name>
<value>https://mydomain.coml/mailGraph.php</value> <value>https://zbx.puzzl.nl/mailGraph.php</value>
</parameter> </parameter>
</parameters> </parameters>
<script>try { <script>try {&#13;
// Pickup parameters // Pickup parameters&#13;
params = JSON.parse(value), params = JSON.parse(value),&#13;
req = new CurlHttpRequest(), req = new CurlHttpRequest(),&#13;
fields = {}, fields = {},&#13;
resp = '', resp = '',&#13;
result = { tags: {} }; result = { tags: {} };&#13;
&#13;
// Set HTTP proxy if required // Set HTTP proxy if required&#13;
if (typeof params.HTTPProxy === 'string' &amp;&amp; params.HTTPProxy.trim() !== '') { req.setProxy(params.HTTPProxy); } if (typeof params.HTTPProxy === 'string' &amp;&amp; params.HTTPProxy.trim() !== '') { req.setProxy(params.HTTPProxy); }&#13;
&#13;
// Declare output type // Declare output type&#13;
req.AddHeader('Content-Type: application/json'); req.AddHeader('Content-Type: application/json');&#13;
&#13;
// Must have fields // Must have fields&#13;
fields.itemId = params.itemId; fields.itemId = params.itemId;&#13;
fields.triggerId = params.triggerId; fields.triggerId = params.triggerId;&#13;
fields.eventId = params.eventId; fields.eventId = params.eventId;&#13;
fields.eventValue = params.eventValue; fields.eventValue = params.eventValue;&#13;
fields.recipient = params.recipient; fields.recipient = params.recipient;&#13;
fields.baseURL = params.baseURL; fields.baseURL = params.baseURL;&#13;
fields.duration = params.duration; fields.duration = params.duration;&#13;
&#13;
// Optional fields // Optional fields&#13;
if (typeof params.graphWidth === 'string') { fields.graphWidth = params.graphWidth; } if (typeof params.graphWidth === 'string') { fields.graphWidth = params.graphWidth; }&#13;
if (typeof params.graphHeight === 'string') { fields.graphHeight = params.graphHeight; } if (typeof params.graphHeight === 'string') { fields.graphHeight = params.graphHeight; }&#13;
if (typeof params.subject === 'string') { fields.subject = params.subject; } if (typeof params.subject === 'string') { fields.subject = params.subject; }&#13;
if (typeof params.showLegend === 'string') { fields.showLegend = params.showLegend; } if (typeof params.showLegend === 'string') { fields.showLegend = params.showLegend; }&#13;
&#13;
// Post information to the processing script // Post information to the processing script&#13;
Zabbix.Log(4, '[MailGraph Webhook] Sending request: ' + params.URL + '?' + JSON.stringify(fields)); Zabbix.Log(4, '[MailGraph Webhook] Sending request: ' + params.URL + '?' + JSON.stringify(fields));&#13;
var resp = req.Post(params.URL,JSON.stringify(fields)); var resp = req.Post(params.URL,JSON.stringify(fields));&#13;
Zabbix.Log(4, '[Mailgraph Webhook] Receiving response:' + resp); Zabbix.Log(4, '[Mailgraph Webhook] Receiving response:' + resp);&#13;
&#13;
// If there was an error, report it // If there was an error, report it&#13;
if (req.Status() != 200) { throw JSON.parse(resp).errors[0]; } if (req.Status() != 200) { throw JSON.parse(resp).errors[0]; }&#13;
&#13;
// We expect the message id back from the processing script // We expect the message id back from the processing script&#13;
resp = JSON.parse(resp); resp = JSON.parse(resp);&#13;
result.tags.__message_id = resp.messageId; result.tags.__message_id = resp.messageId;&#13;
&#13;
// Pass the result back to Zabbix // Pass the result back to Zabbix&#13;
return JSON.stringify(result); return JSON.stringify(result);&#13;
} }&#13;
catch (error) catch (error)&#13;
{ {&#13;
// In case something went wrong in the processing, pass the error back to Zabbix // In case something went wrong in the processing, pass the error back to Zabbix&#13;
Zabbix.Log(127, 'MailGraph notification failed : '+error); Zabbix.Log(127, 'MailGraph notification failed : '+error);&#13;
throw 'MailGraph notification failed : '+error; throw 'MailGraph notification failed : '+error;&#13;
}</script> }</script>
<process_tags>YES</process_tags> <process_tags>YES</process_tags>
<description>The &quot;URL&quot; must point to the location of the processing script. If a proxy is required, define &quot;HTTPProxy&quot; for the proxy address. <description>The &quot;URL&quot; must point to the location of the processing script. If a proxy is required, define &quot;HTTPProxy&quot; for the proxy address.&#13;
&#13;
Customization: Customization:&#13;
- &quot;graphWidth&quot; and &quot;graphWidth&quot; can be defined for the image size - &quot;graphWidth&quot; and &quot;graphWidth&quot; can be defined for the image size&#13;
- &quot;showLegend&quot; can be defined to show or hide the legend of the graph - &quot;showLegend&quot; can be defined to show or hide the legend of the graph&#13;
- &quot;subject&quot; can be defined for a customized subject for the mail message - &quot;subject&quot; can be defined for a customized subject for the mail message&#13;
&#13;
The html.template and plain.template files can be adjusted (TWIG format). The html.template and plain.template files can be adjusted (TWIG format).&#13;
&#13;
Values available: Values available:&#13;
{{ baseURL }} - base url of the Zabbix system (use for references to API and login) {{ baseURL }} - base url of the Zabbix system (use for references to API and login)&#13;
{{ TRIGGER_ID }} - id of the applicable trigger {{ TRIGGER_ID }} - id of the applicable trigger&#13;
{{ TRIGGER_DESCRIPTION }} - raw trigger description (note: macros are not parsed!) {{ TRIGGER_DESCRIPTION }} - raw trigger description (note: macros are not parsed!)&#13;
{{ TRIGGER_COMMENTS }} - comments of the trigger {{ TRIGGER_COMMENTS }} - comments of the trigger&#13;
{{ TRIGGER_URL }} - url of the trigger form {{ TRIGGER_URL }} - url of the trigger form&#13;
{{ ITEM_ID }} - id of the associated item to the trigger {{ ITEM_ID }} - id of the associated item to the trigger&#13;
{{ ITEM_KEY }} - key of the item {{ ITEM_KEY }} - key of the item&#13;
{{ ITEM_NAME }} - item name {{ ITEM_NAME }} - item name&#13;
{{ ITEM_DESCRIPTION }} - description of the item {{ ITEM_DESCRIPTION }} - description of the item&#13;
{{ ITEM_LASTVALUE }} - last value of the item {{ ITEM_LASTVALUE }} - last value of the item&#13;
{{ ITEM_PREVIOUSVALUE }} - the value of the before LASTVALUE {{ ITEM_PREVIOUSVALUE }} - the value of the before LASTVALUE&#13;
{{ ITEM_URL }} - url of the item form {{ ITEM_URL }} - url of the item form&#13;
{{ HOST_ID }} - id of the associated host to the item {{ HOST_ID }} - id of the associated host to the item&#13;
{{ HOST_NAME }} - name of the host {{ HOST_NAME }} - name of the host&#13;
{{ HOST_ERROR }} - last error state of the applicable host {{ HOST_ERROR }} - last error state of the applicable host&#13;
{{ HOST_DESCRIPTION }} - description of the host {{ HOST_DESCRIPTION }} - description of the host&#13;
{{ HOST_URL }} - url of the host form {{ HOST_URL }} - url of the host form&#13;
{{ EVENT_ID }} - id of the associated event {{ EVENT_ID }} - id of the associated event&#13;
{{ EVENT_NAME }} - name of the event (note: macros are parsed!) {{ EVENT_NAME }} - name of the event (note: macros are parsed!)&#13;
{{ EVENT_OPDATA }} - associated operational data of the vent {{ EVENT_OPDATA }} - associated operational data of the vent&#13;
{{ EVENT_VALUE }} - event state (0=Recovered, 1=Triggered/Active) {{ EVENT_VALUE }} - event state (0=Recovered, 1=Triggered/Active)&#13;
{{ EVENT_SEVERITY }} - severity of the event {{ EVENT_SEVERITY }} - severity of the event&#13;
{{ EVENT_STATUS }} - status of the event {{ EVENT_STATUS }} - status of the event&#13;
{{ EVENT_URL }} - url of the event details {{ EVENT_URL }} - url of the event details&#13;
{{ GRAPH_ID }} - id of the (first) associated graph that contains the item {{ GRAPH_ID }} - id of the (first) associated graph that contains the item&#13;
{{ GRAPH_NAME }} - name of this graph {{ GRAPH_NAME }} - name of this graph&#13;
{{ GRAPH_URL }} - URL to this graph (assuming script produces to an accessible location) {{ GRAPH_URL }} - URL to this graph (assuming script produces to an accessible location)&#13;
{{ GRAPH_CID }} - IMG embed string (&lt;img src=&quot;{{ GRAPH_CID }}&quot; /&gt;) {{ GRAPH_CID }} - IMG embed string (&lt;img src=&quot;{{ GRAPH_CID }}&quot; /&gt;)&#13;
{{ LOG_HTML }} - script log in HTML format {{ LOG_HTML }} - script log in HTML format&#13;
{{ LOG_PLAIN }} - script log in PLAIN text format</description> {{ LOG_PLAIN }} - script log in PLAIN text format</description>
<message_templates> <message_templates>
<message_template> <message_template>
<event_source>TRIGGERS</event_source> <event_source>TRIGGERS</event_source>
<operation_mode>PROBLEM</operation_mode> <operation_mode>PROBLEM</operation_mode>
<subject>Problem: {EVENT.NAME}</subject> <subject>Problem: {EVENT.NAME}</subject>
<message>Problem started at {EVENT.TIME} on {EVENT.DATE} <message>Problem started at {EVENT.TIME} on {EVENT.DATE}&#13;
Problem name: {EVENT.NAME} Problem name: {EVENT.NAME}&#13;
Host: {HOST.NAME} Host: {HOST.NAME}&#13;
Severity: {EVENT.SEVERITY} Severity: {EVENT.SEVERITY}&#13;
Operational data: {EVENT.OPDATA} Operational data: {EVENT.OPDATA}&#13;
Original problem ID: {EVENT.ID} Original problem ID: {EVENT.ID}&#13;
{TRIGGER.URL}</message> {TRIGGER.URL}&#13;
&#13;
eventId: {EVENT.ID}&#13;
TriggerId: {TRIGGER.ID}&#13;
itemId: {ITEM.ID]</message>
</message_template> </message_template>
<message_template> <message_template>
<event_source>TRIGGERS</event_source> <event_source>TRIGGERS</event_source>
<operation_mode>RECOVERY</operation_mode> <operation_mode>RECOVERY</operation_mode>
<subject>Resolved in {EVENT.DURATION}: {EVENT.NAME}</subject> <subject>Resolved in {EVENT.DURATION}: {EVENT.NAME}</subject>
<message>Problem has been resolved at {EVENT.RECOVERY.TIME} on {EVENT.RECOVERY.DATE} <message>Problem has been resolved at {EVENT.RECOVERY.TIME} on {EVENT.RECOVERY.DATE}&#13;
Problem name: {EVENT.NAME} Problem name: {EVENT.NAME}&#13;
Problem duration: {EVENT.DURATION} Problem duration: {EVENT.DURATION}&#13;
Host: {HOST.NAME} Host: {HOST.NAME}&#13;
Severity: {EVENT.SEVERITY} Severity: {EVENT.SEVERITY}&#13;
Original problem ID: {EVENT.ID} Original problem ID: {EVENT.ID}&#13;
{TRIGGER.URL}</message> {TRIGGER.URL}&#13;
&#13;
eventId: {EVENT.ID}&#13;
TriggerId: {TRIGGER.ID}&#13;
itemId: {ITEM.ID]</message>
</message_template> </message_template>
<message_template> <message_template>
<event_source>TRIGGERS</event_source> <event_source>TRIGGERS</event_source>
<operation_mode>UPDATE</operation_mode> <operation_mode>UPDATE</operation_mode>
<subject>Updated problem in {EVENT.AGE}: {EVENT.NAME}</subject> <subject>Updated problem in {EVENT.AGE}: {EVENT.NAME}</subject>
<message>{USER.FULLNAME} {EVENT.UPDATE.ACTION} problem at {EVENT.UPDATE.DATE} {EVENT.UPDATE.TIME}. <message>{USER.FULLNAME} {EVENT.UPDATE.ACTION} problem at {EVENT.UPDATE.DATE} {EVENT.UPDATE.TIME}.&#13;
{EVENT.UPDATE.MESSAGE} {EVENT.UPDATE.MESSAGE}&#13;
&#13;
Current problem status is {EVENT.STATUS}, age is {EVENT.AGE}, acknowledged: {EVENT.ACK.STATUS}.</message> Current problem status is {EVENT.STATUS}, age is {EVENT.AGE}, acknowledged: {EVENT.ACK.STATUS}.&#13;
</message_template> &#13;
<message_template> eventId: {EVENT.ID}&#13;
<event_source>DISCOVERY</event_source> TriggerId: {TRIGGER.ID}&#13;
<operation_mode>PROBLEM</operation_mode> itemId: {ITEM.ID]</message>
<subject>Discovery: {DISCOVERY.DEVICE.STATUS} {DISCOVERY.DEVICE.IPADDRESS}</subject>
<message>Discovery rule: {DISCOVERY.RULE.NAME}
Device IP: {DISCOVERY.DEVICE.IPADDRESS}
Device DNS: {DISCOVERY.DEVICE.DNS}
Device status: {DISCOVERY.DEVICE.STATUS}
Device uptime: {DISCOVERY.DEVICE.UPTIME}
Device service name: {DISCOVERY.SERVICE.NAME}
Device service port: {DISCOVERY.SERVICE.PORT}
Device service status: {DISCOVERY.SERVICE.STATUS}
Device service uptime: {DISCOVERY.SERVICE.UPTIME}</message>
</message_template>
<message_template>
<event_source>AUTOREGISTRATION</event_source>
<operation_mode>PROBLEM</operation_mode>
<subject>Autoregistration: {HOST.HOST}</subject>
<message>Host name: {HOST.HOST}
Host IP: {HOST.IP}
Agent port: {HOST.PORT}</message>
</message_template> </message_template>
</message_templates> </message_templates>
</media_type> </media_type>
</media_types> </media_types>
</zabbix_export> </zabbix_export>