2 Configuration - moudsen/mailGraph GitHub Wiki

MailGraph

  • Goto your /config directory you've created in the Installation step.
  • Two ways to configure the config.json file:
    • with config.php or
    • with your favorite text editor (note that you must have knowledge of JSON format to use this option! You can validate your code by executing the LIST command with config.php as per below)

Using config.php

Command Description
php config.php config.json list List the configured options
php config.php config.json replace 'key_name' 'new_value' Change any option (note the usage of the single quotes!)
php config.php add 'key_name' 'new_value' Add options with (note the usage of the single quotes!)

Please note that for using the API token method (available in Zabbix 7.0 onwards) to login to Zabbix you need to add the "zabbix_api_token" element to config.json. After defining a token, the "zabbix_api_user" and "zabbix_api_pwd" are not used/ignored. For mailGraph to pick up the actual grahps from Zabbix, the "zabbix_user" and "zabbix_user_pwd" are still required as this section in the Zabbix library does not support the use of an API token (yet?).

Configurable options in config.json (v2.20)

Options Description
script_baseurl Should point to the URL of your directory where MailGraph is installed (ie. "https://mydomain.com/"). Note the ending '/'!
zabbix_user and zabbix_user_pwd Required for fetching the Zabbix graphs. Must be a Zabbix SuperAdmin user/password you need to have/create to login to Zabbix.
zabbix_api_user and zabbix_api_pwd Required to login into Zabbix API to grab the actual information of an event and related records. Must also be a Zabbix SuperAdmin user/password. When ommitted zabbix_user and zabbix_user_pwd will be used.
zabbix_api_token Zabbix 7 and onwards now support API bearer token login. If configured, zabbix_api_user and zabbix_api_pwd are ignored.
mail_from Must be a valid e-mail address which represents the 'from' address in the mails that are sent (ie. "[email protected]") that is acceptable by your mail server. Note: replaced by smtp_from_address but remains in place for backward compatibility. If smtp_from_address is defined mail_from will be ignored.
period Must be a valid Zabbix period (like "1d", "1w" or "48h") that will be applied to the graph. Default is "48h" when not specified.
period_header Is the header displayed above the graph. For example "Last 48 hours". Defaults to 'period' when not specified.
graph_match Is the matching method while searching for graphs ('Exact','Other').
item_value_truncate Enables or disables ITEM value truncing (set to zero to disable). Refer to Tags for configuration for specific Triggers only.
smtp_server and smtp_port To define the SMTP server and port to be used.
smtp_security To define the SMTP transport methode ('none','starttls','smtps'; defaults to 'none').
smtp_strict Is TLS certificate checking strict? ('yes','no'; defaults to 'yes').
smtp_username and smtp_password To define the username and password used for accessing the SMTP server.
smtp_from_address To define the sender e-mail address from mailGraph. If not set the default user e-mail address as configured for the mailer system will be used. If not set mail_from will be used (this allows for backward compatibility when using mail_from with mailGraph<v2.14.
smtp_from_name To define the sender identification name. If not set the default "mailGraph" will be used.
smtp_reply_address To define the e-mail address to send responses to when replying to a mailGraph message. Does not generate a reply-to if not set.
smtp_reply_name To define a name with the reply-to address. Default to "mailGraph feedback" if not defined.
retention_logs and retention_images To define the number of days before old LOG and IMAGES files are removed (details in A- Cleaning up LOG and IMAGES directory)

Note that config.json can also hold entries starting with "cli_". Such entries are used in case of 8- Troubleshooting.

Load the Media Type "MailGraph" into Zabbix

  • Login to your Zabbix instance
  • Goto "Administration" => "Media types"
  • Import the "mailGraph.xml" file
  • Edit the new media type
  • Configure some of the parameters associated
Parameter Description
baseURL Must contain your Zabbix URL (ie. "https://mydomain.com/zabbix/"). Note the ending '/'!
graphWidth and GraphHeight To size the graph to your convenience (defaults to 450,120).
showLegend You can switch the graph legend on or off (1=on, 0=off).
subject You can change the subject of the e-mail that is sent (note that the markup can be a combination of Zabbix MACRO and/or TWIG notation!).
URL Is the url to the mailGraph script (ie. "https://mydomain.com/mailGraph.php").
HTTPProxy Proxy URL (i.e. 10.20.30.40:8080) that will be used by MailGraph to reach Zabbix.
period Define the period of a Graph (Zabbix time notation, i.e. "4h" for 4 hours).
period_header Define the header that will be displayed above the Graph (i.e. "4 hours").
periods Define multiple periods (max 4) for embedding multiple periods of the same graph in the message (i.e. "10m,4h,1d,7d").
periods_header Headers associated to these periods (i.e. "Last 10 minutes,Last 4 hours,Last day,Last 7 days").
debug To attach debug logging to the mail message (0=off,1=on).

Save your configuration with "Update".

Some of the defined default parameters (like {EVENT.ID}) are important to MailGraph functioning correctly. Please do not touch or change these parameters!

Zabbix Actions configuration

At this point the Media type is ready for configuration under "actions" as per the regular way of Zabbix alert processing. Please refer to the manual how to configure.