6 Commits
v2.16 ... v2.17

Author SHA1 Message Date
Mark Oudsen
bf7927a0c3 v2.17 - Several bugfixes - PHP8 confirmed testing - Preparations for release 3 2024-12-30 11:26:28 +01:00
moudsen
b43611588a Merge pull request #44 from WMP/patch-1
Fix config.json.template
2024-12-30 09:18:24 +01:00
WMP
b1f635ab36 Fix config.json.template 2024-06-20 14:56:05 +02:00
Mark Oudsen
dce6f57876 mailGraph v3.x announcement and Zabbix 5 and older maintenance stop 2023-11-02 12:24:24 +01:00
moudsen
74e8a79e4c mailGraph v3.x accouncement and Zabbix 5 and older maintenance stop 2023-11-02 12:15:09 +01:00
Mark Oudsen
ba3e860fe0 mailGraph v3.x announcement and Zabbix 5 and older maintenance stop 2023-11-02 12:14:01 +01:00
4 changed files with 56 additions and 104 deletions

View File

@@ -20,72 +20,20 @@ More information can be found in the Wiki.
## Installation ## ## Installation ##
Please refer to the Wiki how to get mailGraph installed and configured on your system. Please refer to the Wiki how to get mailGraph installed and configured on your system.
## mailGraph v2.16 release ## ## Announcement - Zabbix 5.x maintenance for mailGraph end-of-life - mailGraph 3.x development in progress ##
_(2023/08/16)_ _(2023/11/01)_
_This version has been verified with Zabbix 5.4 and 6.0 LTS and is expected to work with 6.4 and later (based on v2.10 testing)_ As per November 2023 the maintenance on mailGraph v2.x for Zabbix 5.x will stop in conjunction with the Zabbix lifecycle policy (https://www.zabbix.com/life_cycle_and_release_policy) as Zabbix 5 is nearing it's end of life.
Release notes In conjunction mailGraph v2.x is now frozen and I'm setting up a roadmap for mailGraph v3.x starting new development in Alfa mode as November 2023. This new code is not expected to be published until start of 2024.
- Adding [ACKNOWLEDGES] message information for processing in the TWIG template to allow inclusion of "Action" information in the mail messages (eg. who acknowledged/changed problem status). Refer to the Wiki "Templates" section for more detailed information.
## mailGraph v2.15 release ## Principal bug fixing on mailGraph v2.x (logic failure or similar) will continue but only for Zabbix 6.x onwards.
_(2023/08/16)_
_This version has been verified with Zabbix 5.4 and 6.0 LTS and is expected to work with 6.4 and later (based on v2.10 testing)_ I'm open to new feature requests - please raise an issue for this in this Github space.
Release notes
- Fixed issue with Zabbix 5.4.12 where parameters that are blank or zero did no longer get passed to the Javascript hence causing basic checks to fail. Javascript and parameter checks in mailGraph.php have been adjusted and optimized.
- Refactored the Javascript error handling to get rid of the "Invalid JSON offset" message and to deal with individual error conditions while presenting a better error message on the root cause of the concerning issue.
## mailGraph v2.14 release ##
_(2023/07/10)_
_This version has been verified with Zabbix 5.4 and 6.0 LTS and is expected to work with 6.4 and later (based on v2.10 testing)_
Release notes
- Adding the ability to define FROM details for the emails generated by mailGraph
- `smtp_from_address` to set the from mail address (if not set uses mailing system default). Note: obsolete `mail_from` but retained for backwards compatibility.
- `smtp_from_name` to set the name that goes with the mail address (if not set uses "mailGraph").
- Adding the ability to define REPLY_TO details for the emails generated by mailGraph
- `smtp_reply_address` to set the reply-to mail address (if not set, no reply-to will be added to the message).
- `smtp_reply_name` to set the reply-to name of the mailbox (if not set defaults to "mailGraph feedback").
- Adding a new URL for use in the template:
- `ACK_URL` points to the function in Zabbix for editing and submitting an Acknowledge statement.
## mailGraph v2.13 release ##
_(2023/07/03)_
_This version has been verified with Zabbix 5.4 and 6.0 LTS and is expected to work with 6.4 and later (based on v2.10 testing)_
Release notes
- Fixed references into Zabbix
- Trigger was missing "context" parameter
- Item was missing "context" parameter
- Problems reference to this host was not generated at all
## mailGraph v2.12 release ##
_(2023/07/02)_
_This version has been verified with Zabbix 5.4 and 6.0 LTS and is expected to work with 6.4 and later (based on v2.10 testing)_
Release notes
- Replaced Swiftmailer with PHPMailer
- Configuration option "smtp_transport" removed (using PHPMailer AutoTLS)
- Code cleanup (markup and obsolete related parts)
- Addressed any PHP message (deprecation or error) - mailGraph debug output is now "clean" in PHP 7.4.x and PHP 8.2.x
- Increased maximum number of graphs from 4 to 8
**Please consider to move to PHPMailer as soon as possible as Swiftmailer is abandoned. Installation instructions are included on the wiki.**
Principal approach: `composer require phpmailer/phpmailer`, install mailGraph v2.12 or higher.
In case Swiftmailer is no longer used elsewhere you can consider to remove this package with `swiftmailer/swiftmailer`.
## Special thank you ## ## Special thank you ##
I would like to express my gratitude to the following people that have actively contributed to bring bugs and improvements to my attention: I would like to express my gratitude to the following people that have actively contributed to bring bugs and improvements to my attention:
- [pqvindesland](https://github.com/pqvindesland) - [pqvindesland](https://github.com/pqvindesland)
## IMPORTANT NOTE for users of mailGraph v1 and Zabbix versions under 5.4 ## ## IMPORTANT NOTE for users of mailGraph v2 and older and Zabbix versions under 6.0 ##
As a result of a major functional change in Zabbix 5.4 (Screens no longer exist and are all moved into Dashboards) the mailGraph.screen macro no longer functions under Zabbix 5.4+. A code rewrite is in progress to deal with detecting the Zabbix version and to pick dashboard.get instead of screen.get as a source list for the graphs that should be included in the mail message. As per November 2023, mailGraph is no longer maintained for Zabbix 5 and older.
**v1.x is no longer supported; please upgrade to the current v2 release**

View File

@@ -20,7 +20,7 @@
"smtp_from_address": "mailgraph@mydomain.com", "smtp_from_address": "mailgraph@mydomain.com",
"smtp_from_name": "mailGraph", "smtp_from_name": "mailGraph",
"smtp_reply_address": "feedback@mydomain.com", "smtp_reply_address": "feedback@mydomain.com",
"smtp_from_name": "mailGraph response mailbox", "smtp_reply_name": "mailGraph response mailbox",
"smtp_strict": "yes", "smtp_strict": "yes",
"graph_match": "any", "graph_match": "any",
"period": "20m", "period": "20m",

View File

@@ -17,11 +17,11 @@
"smtp_server": "localhost", "smtp_server": "localhost",
"smtp_port": 25, "smtp_port": 25,
"smtp_transport": "none", "smtp_transport": "none",
"smtp_strict": "yes",
"smtp_from_address": "mailgraph@mydomain.com", "smtp_from_address": "mailgraph@mydomain.com",
"smtp_from_name": "mailGraph", "smtp_from_name": "mailGraph",
"smtp_reply_address": "feedback@mydomain.com", "smtp_reply_address": "feedback@mydomain.com",
"smtp_from_name": "mailGraph response mailbox", "smtp_reply_name": "mailGraph response mailbox",
"smtp_strict": "yes",
"graph_match": "any", "graph_match": "any",
"periods": "10m,4h,2d,7d", "periods": "10m,4h,2d,7d",
"periods_headers": "Last 10 minutes,Last 4 hours,Last 2 days,Last 7 days", "periods_headers": "Last 10 minutes,Last 4 hours,Last 2 days,Last 7 days",

View File

@@ -8,39 +8,7 @@
// upon an alert message. // upon an alert message.
// //
// ------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------
// Release 1 tested with Zabbix 5.4 and 6.0 LTS // Release 1 tested with Zabbix 5.4 and 6.0 LTS (history available on GitHub)
// ------------------------------------------------------------------------------------------------------
// 1.00 2021/02/26 - Mark Oudsen - MVP version, ready for distribution
// 1.01 2021/02/27 - Mark Oudsen - Enhanced search for associated graphs to an item // bug fixes
// 1.10 2021/02/27 - Mark Oudsen - Moved all configuration outside code
// 1.11 2021/02/28 - Mark Oudsen - Bugfixes
// 1.12 2021/03/01 - Mark Oudsen - Bugfixes
// Adding mail server configuration via config.json
// 1.13 2021/03/01 - Mark Oudsen - Added smtp options to encrypt none,ssl,tls
// 1.14 2021/03/01 - Mark Oudsen - Added smtp strict certificates yes|no via config.json
// 1.15 2021/03/01 - Mark Oudsen - Revised relevant graph locator; allowing other item graphs if current
// item does not have a graph associated
// 1.16 2021/03/02 - Mark Oudsen - Found issue with graph.get not returning graphs to requested item ids
// Workaround programmed (fetch host graphs, search for certain itemids)
// 1.17 2021/03/02 - Mark Oudsen - Added ability to specify period of time displayed in the graph
// 1.18 2021/03/04 - Mark Oudsen - Added ability to specify Tags per trigger
// Shorten long "lastvalue" or "prevvalue"
// 1.19 2021/03/05 - Mark Oudsen - Added ability to pass Zabbix 'infoXXX' parameters for TWIG template
// 1.20 2021/03/07 - Mark Oudsen - Production level version - leaving BETA from here on ...
// 1.21 2021/03/09 - Mark Oudsen - Reverted graph.get code back to original code as it was not a bug but
// a wrongly typed requested (should be ARRAY, not comma separated)!
// 1.22 2021/03/10 - Mark Oudsen - Added ability to embed multiple periods (1-4) of the same graph
// 1.23 2021/03/12 - Mark Oudsen - Added graph support for 'Stacked', 'Pie' and 'Exploded'
// 1.24 2021/03/12 - Mark Oudsen - Added support for HTTP proxy
// 1.25 2021/03/16 - Mark Oudsen - Refactoring for optimized flow and relevant data retrieval
// 1.26 2021/03/19 - Mark Oudsen - Bugfixes after refactor (wrong itemId and incorrect eventValue)
// Suppressing Zabbix username-password in log
// 1.27 2021/03/19 - Mark Oudsen - Added ability to define "mailGraph.screen" tag to embed graphs from
// Added PHP informational and warnings to log for easier debug/spotting
// 1.28 2021/03/24 - Mark Oudsen - Added ability to specify username/password for TLS/SSL
// 1.29 2021/04/03 - Mark Oudsen - Bugfix due to stricter JSONRPC version check since Zabbix 5.0.10
// 2021/07/05 - Mark Oudsen - Minor detail added: CLI debug mode now also outputs version
// 2021/07/07 - Mark Oudsen - Fixed HTTPProxy typo in code (instead of HTTPPRoxy)
// ------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------
// Release 2 tested with Zabbix 5.4, 6.0 LTS and 6.4 - tested with latest Composer libraries // Release 2 tested with Zabbix 5.4, 6.0 LTS and 6.4 - tested with latest Composer libraries
// ------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------
@@ -61,6 +29,16 @@
// 2.15 2023/08/16 - Mark Oudsen - Bugfix for Zabbix 5.4 where empty or zeroed variables are no longer // 2.15 2023/08/16 - Mark Oudsen - Bugfix for Zabbix 5.4 where empty or zeroed variables are no longer
// passed by Zabbix (hence resulting in weird errors) // passed by Zabbix (hence resulting in weird errors)
// 2.16 2023/08/16 - Mark Oudsen - Adding ability to use ACKNOWLEDGE messages in the mail message // 2.16 2023/08/16 - Mark Oudsen - Adding ability to use ACKNOWLEDGE messages in the mail message
// 2.17 2024/12/30 - Mark Oudsen - Fixed #47 mailData initializaton (wrong location) - BernardLinz
// Fixed #46 invalid GraphId on trigger tag - BernardLinz
// Fixed #44 config.json.template wrong var name - WMP
// Fixed #45 handling of international characters - Dima-online
// Tested with latest PHPMailer (6.9.3) and TWIG (3.11.3), PHP 7.4
// Tested with PHP 8.3, TWIG (3.18.0)
// ------------------------------------------------------------------------------------------------------
// Release 3 placeholder for Zabbix 7.0 LTS and 7.2
// ------------------------------------------------------------------------------------------------------
// v2.17 Testing on Zabbix 7.0 LTS (in progress), Zabbix 7.2 (in progress)
// ------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------
// //
// (C) M.J.Oudsen, mark.oudsen@puzzl.nl // (C) M.J.Oudsen, mark.oudsen@puzzl.nl
@@ -69,6 +47,25 @@
///////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Notes
// -----
// 1) mailGraph is following the environmental requirements from Zabbix, supporting PHP 7.4-8.3 ad per
// - https://www.zabbix.com/documentation/6.0/en/manual/installation/requirements
// - https://www.zabbix.com/documentation/6.4/en/manual/installation/requirements
//
// 2) TWIG 3.18.0 is available on PHP 8 only (seemless upgrade when using composer update)
//
// 3) Testing of composer libraries updates is limited to every 6 to 12 months
// - In case you encounter an issue, please raise an issue on GitHub
// https://github.com/moudsen/mailGraph/issues
//
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
@@ -88,14 +85,14 @@
// MAIN SEQUENCE // MAIN SEQUENCE
// ------------- // -------------
// 1) Fetch trigger, item, host, graph, event information via Zabbix API via CURL // 1) Fetch trigger, item, host, graph, event information via Zabbix API via CURL
// 2) Fetch Graph(s) associated to the item/trigger (if any) via Zabbix URL login via CURL // 2) Fetch Graph(s) associated to the item/trigger (if any) via Zabbix URL via CURL
// 3) Build and send mail message from template using Swift/TWIG // 3) Build and send mail message from template using PHPmailer//TWIG
// //
///////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////
// CONSTANTS // CONSTANTS
$cVersion = 'v2.16'; $cVersion = 'v2.17';
$cCRLF = chr(10).chr(13); $cCRLF = chr(10).chr(13);
$maskDateTime = 'Y-m-d H:i:s'; $maskDateTime = 'Y-m-d H:i:s';
$maxGraphs = 8; $maxGraphs = 8;
@@ -114,7 +111,6 @@
// INCLUDE REQUIRED LIBRARIES (Composer) // INCLUDE REQUIRED LIBRARIES (Composer)
// (configure at same location as the script is running or load in your own central library) // (configure at same location as the script is running or load in your own central library)
// -- phpmailer/phpmailer https://github.com/PHPMailer/PHPMailer // -- phpmailer/phpmailer https://github.com/PHPMailer/PHPMailer
// -- swiftmailer/swiftmailer https://swiftmailer.symfony.com/docs/introduction.html
// -- twig/twig https://twig.symfony.com/doc/3.x/templates.html // -- twig/twig https://twig.symfony.com/doc/3.x/templates.html
// Change only required if you decide to use a local/central library, otherwise leave as is // Change only required if you decide to use a local/central library, otherwise leave as is
@@ -513,6 +509,10 @@
_log('# Configuration taken from config.json'.$cCRLF. _log('# Configuration taken from config.json'.$cCRLF.
json_encode(maskOutputFields($config),JSON_PRETTY_PRINT|JSON_NUMERIC_CHECK)); json_encode(maskOutputFields($config),JSON_PRETTY_PRINT|JSON_NUMERIC_CHECK));
// --- MAIL DATA ---
$mailData = array();
// --- POST DATA --- // --- POST DATA ---
// Read POST data // Read POST data
@@ -740,8 +740,6 @@
// Fetch information via API //////////////////////////////////////////////////////////////////////////// // Fetch information via API ////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////
$mailData = array();
$mailData['BASE_URL'] = $p_URL; $mailData['BASE_URL'] = $p_URL;
$mailData['SUBJECT'] = $p_subject; $mailData['SUBJECT'] = $p_subject;
@@ -877,7 +875,7 @@
} }
// --- Collect and attach acknowledge messages for this event // --- Collect and attach acknowledge messages for this event
if (isset($thisEvent['result'][0]['acknowledges'])) { if (sizeof($thisEvent['result'][0]['acknowledges']>0)) {
foreach($thisEvent['result'][0]['acknowledges'] as $aCount=>$anAck) { foreach($thisEvent['result'][0]['acknowledges'] as $aCount=>$anAck) {
$mailData['ACKNOWLEDGES'][$aCount] = $anAck; $mailData['ACKNOWLEDGES'][$aCount] = $anAck;
$mailData['ACKNOWLEDGES'][$aCount]['_clock'] = zabbixTStoString($anAck['clock']); $mailData['ACKNOWLEDGES'][$aCount]['_clock'] = zabbixTStoString($anAck['clock']);
@@ -1370,7 +1368,7 @@
{ {
if ($forceGraph>0) if ($forceGraph>0)
{ {
$theGraph = $forceGraphInfo; $theGraph = $forceGraphInfo['result'][0];
$theType = 'Forced'; $theType = 'Forced';
} }
else else
@@ -1518,8 +1516,14 @@
try try
{ {
// If debugging is required change to '1'
$mail->SMTPDebug = 0; $mail->SMTPDebug = 0;
// Initialize for international characters
$mail->CharSet = "UTF-8";
$mail->Encoding = "base64";
// Inialize SMTP parameters
$mail->isSMTP(); $mail->isSMTP();
$mail->Host = $p_smtp_server; $mail->Host = $p_smtp_server;
$mail->Port = $p_smtp_port; $mail->Port = $p_smtp_port;