Description
This issue respects the following points:
- This is a bug, not a question or a setup/configuration issue.
- This issue is not already reported on Github (I've searched it).
- I use the latest release of the Monitoring Plugins (https://github.com/Linuxfabrik/monitoring-plugins/releases).
- I agree to follow Monitoring Plugins's Code of Conduct.
Which variant of the Monitoring Plugins do you use?
- .rpm/.deb package from repo.linuxfabrik.ch
- Compiled for Linux (.tar/.zip from download.linuxfabrik.ch)
- Compiled for Windows (from download.linuxfabrik.ch)
- Source Code from GitHub
Bug description
When using both host and service notification plugins, sent mails don't have icinga image embedded in html, but rather sent as an attachment (base64 encoded string).
Issue seems to be systems having relatively long hostname (in our case it is a 92 character long name, including multiple hyphens), which results in incorrect Content-ID in the MIME Header, like the following:
Content-Type: icinga/png
Content-Transfer-Encoding: base64
Content-ID: =?utf-8?q?=3C173029044628=2E4046357=2E135608162032178388=40de136?=
=?utf-8?q?1-...SNIP....=3E?=
MIME-Version: 1.0
Content-Disposition: inline
There's however a correct Header for systems with shorter Hostnames (8 characters, without hyphens), such as below:
Content-Type: icinga/png
Content-Transfer-Encoding: base64
Content-ID: <173036783636.3431.18294001565118557038@SHORTER_HOSTNAME>
MIME-Version: 1.0
Content-Disposition: inline
- I believe issue is in the python script where
logo_cid
is generated (notify-host-mail: line 465) - Function
make_msgid()
fromemail.utils
without arguments is usingsocket.getfqdn()
to get the domain, which has a known issue described here
email.utils.make_msgid return ids that break email messages with related content python/cpython#100293
As a workaround, we're currently using the python scripts with make_msgid(domain="<shorter_name>")
, that way images are embedded correctly.
Steps to reproduce - Plugin call
/usr/lib64/nagios/plugins/notifications/notify-host-mail --datetime --host-displayname <host_name> --mail-recipient <recipient_address> --mail-sender <sender_address> --host-state <state_num>
Steps to reproduce - Data
- Execute plugin
Environment
Ubuntu Linux 22.04.5 LTS x86_64
Plugin Version
v2023112901
Python version
No response
List of Python modules
No response
Additional Information
No response