Skip to content

notify-{service,host}-mail: Icinga logo cannot be displayed #790

Open
@bence-haris

Description

@bence-haris

This issue respects the following points:

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
  1. I believe issue is in the python script where logo_cid is generated (notify-host-mail: line 465)
  2. Function make_msgid() from email.utils without arguments is using socket.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

  1. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions