-
Notifications
You must be signed in to change notification settings - Fork 5
6 MailGraph logic
Let's start with the idea that there is no immediate relationship between a trigger and a graph. This is why the script uses the following technique to find graphs to are associated to the trigger:
- The Event API call returns the Event information and holds the "relatedObject" referring to the Trigger that caused the Event. The Value and TriggerId are obtained from this object.
- The trigger API call returns a list of "functions". Each functions holds an "item id".
- Via the graph API call we can figure out which graphs are associated to the "host id" and to any of the items we've found in the previous step.
- Traversing this set of grahps, we are looking for graphs that have the actual "item id" associated. If there is no association found, we can still use any graph as it is still relevant to the trigger, but it will have an indirect relationship.
- Most ideally we pick the (first) graph that has the actual "item id" matched. If not, we pick the first graph we've managed to find in our "functions" list.
In reality this may means that there are items (like simple "interface up/down" configured) that have no graphs defined. In this occasion there is no graph attached to the message.
If no graph appears or if you wish a specific graph to appear at this point, just add a new graph using that item and next time this graph will show in the message. If you want a specific graph to appear add the tag mailGraph.graph
to the trigger pointing at a graph you would like to display for this trigger.
Next to adding "item" related graphs, you can also direct MailGraph to add additional graphs for a specific Trigger and/or Host. To make this work you need to setup a "Screen" that has the graphs defined you wish to add to the e-mail message.
When done, pickup the Screen ID (look at the URLs displayed on the "Screens" list) and configure a Tag named mailGraph.screen
to the Trigger or Host. You can also define mailGraph.screenPeriod
to set the time period that will be displayed for the graphs of this Screen and mailGraph.screenPeriodHeader
to set a more readable period header (defaults to mailGraph.screenPeriod
).
To ensure the graphs are embedded you need to process the GRAPHS_T
(Trigger) and GRAPHS_H
(Host) arrays in TWIG (take a look at html.template
). Take a look at 5- Templates for additional fieldd that are available if you decide to use these Tags.