Hi Sebastian,
We seem to have different starting points for developing a similar solution to enclose pictures in messages. My initiative was triggered from https://support.zabbix.com/browse/ZBXNEXT-5611 where people are waiting for Zabbix developers to come up with a solution (for over 10 years now ...).
I've read your work and understand the custom alert script mechanism applied opposite to where I've explicitely chosen to use the Zabbix mechanism to separate the alert cause from the alert follow-up while using the Media Type to bind alerts to message sending services (https://www.zabbix.com/documentation.../media/webhook). You could consider doing the same thing which could turn your code into a standard Media Type as well for easy consumption in Zabbix?
My next goal is to separate the Graph get code to become stand-alone to allow other scripts to start using it (look at the ZBXNEXT-5611 where this is asked for Telegraph). My first attempt will be for Slack.
Templating is definitely worth looking into. I've used TWIG for this but that's PHP based, not sure if there is a Python variant for it, but bet there is something similar out there doing the same (like https://wiki.python.org/moin/Templating).
Basically it's about applying MVC modelling approach: separate data (and config) from model and controller.
Best regards, Mark
Ad Widget
Collapse
Graph on email notification
Collapse
X
-
Sure,
Good start is typing in g ogle string "sending-email-and-wechat-alarm-with-pictures-in-zabbix" , how to add graphs it should be on the first return
This runs as custom alertscript,
additionnall there is need to create custom HTML alert template.
There is actually some work to do, and fit somebody needs. -
-
v1.21 released. Optimized graph.get and fixed some minor bugs (mostly log related).Leave a comment:
-
v1.20 released. Responsive html added and fixed some minor bugs. Leaving BETA mode!Leave a comment:
-
Just to let you know I've release v1.19 which is a version very close to my next milestone of v1.20 where I will leave BETA status. If you an earlier version installed, make sure to replace mailGraph.php and the Javascript code (refer to /javascript) within the Media Type in Zabbix to get the latest and greatest functionality!
Enhancements:
- Dynamic variables from Zabbix that you can use in the TWIG template (ultimate flexibility in template based information gathering and processing)
- Direct to specific graph per Trigger
- Different settings per Trigger (width, height, legend, period) thru definition of Tags
- Smarter graph locator (finding an associate graph through the trigger functions)
- Configurable mail server settings, including support for TLS and SSL and username/password (if required)
- Bugfixes and workarounds (i.e. found graph.get issue not returning all associated graphs information requested)
One final thing to do before going out of BETA is to have a Responsive template, although the current table based template is already quite useful!
If you decide to put v1.19 to a wider audience do keep an eye on the DEBUG settings at the beginning of the code (disable cDebugMail for example).
After releasing v1.20 I will focus on getting the graph generator code separated from my code to make it reusable for other webhook/scripts to allow for inclusion in Telegraf, Slack and others and to prepare for the announced API based image call by Zabbix development (and perhaps to give some pointers in what kind of functionality would be nice to have for finding and generating the graph), although one needs to notice that the requested functionality is open sinds 2010 ... :-).
Very interested to learn from anyone if MailGraph add value and to identify further enhancements!Last edited by hoppa; 05-03-2021, 14:12.Leave a comment:
-
Okay, here we go: https://github.com/moudsen/mailGraph. Note that I'm still working on the code and the manual. Appreciate any feedback (also if it works ... :-)).Leave a comment:
-
-
Found several topics across the forum where people are asking for such a function for quite a long time already. Also wanted to have this myself and decided to do some fun coding also to get a better knowledge of the internals of Zabbix.
I've just finished coding a working "proof of concept" PHP Webhook based Media Type called "MailGraph" that picks up the event, finds out if there is a graph associated and sends out an e-mail with the graph.
The PHP script fetches the objects (item, host, event, graphs) via the API, logs in to Zabbix, grabs the graph and composes a template based e-mail.
If you're interested I can post the code/instructions on Git after polishing the code a bit more?Leave a comment:
-
so with this here I get my chart: .../chart.php?from=now%2FM&to=now%2FM&itemids[0]={ITEM.ID}&type=0&profileIdx=web.item.graph.filter&profileId x2={ITEM.ID}&width=800&height=200
Issue with that: You won't see anything because this is a "live chart" and needs authentication.
Any ideas on how to export this URL to a static image which is attached to the notification mail?Leave a comment:
-
Hi there,
I'm also struggeling with the same "problem". It can't be that hard to put a simple graph with tha latest data (last 6hours/24hours/week...) of the triggered sensor into the notification mail?!!?
https://www.zabbix.com/documentation...ed_by_location isn't going to help. I also can't manage to find the right macros/parameters.
Using Zabbix v5
Pls helpLast edited by xibzab; 08-07-2020, 10:13.Leave a comment:
-
Graph on email notification
Hi guys,
I've been trying to include a graph on my notification alert e-mail based on a trigger severity, but without success. I already tried the ad-hoc url graph, but won't accept the {ITEM-ID} macro, only accepts an integer value. Can someone help me?
Zabbix version: 4.0Tags: None
Leave a comment: