How to add agent name to email notification sent by icinga

Hi,
I’m trying to modify mail-service-notification.sh and mail-host-notification.sh located at /etc/icinga2/scripts and add Agent Host Name to the email get sent by icinga but I can’t find a way to do it. I haven’t customized scripts yet so it’s still the default one.

***** Service Monitoring on ~~~~~~.com *****

[Service Name] on [Host Diplay name] is OK!

Info: DISK OK - free space: / 48372 MB (67.51% inode=98%); /data 462118 MB (99.98% inode=100%);

When: 2020-07-23 09:42:44 +0000
Service: [Service Name]
Host: [Master Common Name]

I want to add [Client Common Name]

Hi & welcome to the icinga community,

Hmm, sounds like your check is executed on your master instead on your agent as the host in any notification is the corresponding host by default.Therefore, I’d assume your service object(s) does not have

command_endpoint = host.name

included?

Hi Roland,
Thanks :slight_smile:
I had command_endpoint = host.name set for all my services except check_command=http and check_command=ssh.

The only time I see agent name is when it can’t connect to agent something like

Info: Remote Icinga instance [agent name]’ is not connected to '[Master Name

I don’t think that this is possible. At least I don’t know that something like “this check result was received by that agent” is stored anywhere.

Out of interest: Why is it necessary for you to have the information in the notification? If it is an agent the host name is equal to the agent name?!

This is another issue which needs your attention.

I think this was just an example and the checks are working ok in general.

What he wants is to have something like “instance [agent name]” in the notification text.

True that was an example . I need “instance [agent name]” in the notification text.

One person other than me who is managing our servers doesn’t know all Machine display name. He wants to know what machine name it is to be able to fix it when I’m away without knowing the purpose of the machine. I fixed the issue by including Host name when I setup agent in Display name. Thanks for all comments
ie:
Host Name: Computer1
Display Name: Build Machine (Computer1)

1 Like