Page 1 of 1

Different Email subjects for different notifications

Posted: Thu Jun 15, 2023 5:06 pm
by DharmaNunna
Hi,

How can I change the email subject for different host notifications?

Example:

Subject of email Notification for Host1 : CRITICAL - Host1 - CPU Usage
Subject of email Notification for Host2 : Host2 - CPU Usage - CRITICAL

Re: Different Email subjects for different notifications

Posted: Fri Jun 16, 2023 9:43 am
by deby23456
Hello,

I got the following prompt straight from google. This isn't a fix to your issue but somewhere to edit and check if you can change it. Check on that and see what you see and edit it for testing.
"
The commands.cfg file is located in the Nagios configuration directory. The default location of the Nagios configuration directory is /etc/nagios/.

To change the subject name of host notification, you need to edit the notify-host-by-email command definition. The notify-host-by-email command definition is located in the commands.cfg file.

The notify-host-by-email command definition has a subject parameter. The subject parameter specifies the subject line of the email notification that is sent when a host alert is triggered.

To change the subject name of host notification, you need to edit the value of the subject parameter. The following is an example of how to change the subject name of host notification:

command_name notify-host-by-email
command_line /usr/bin/printf "%b" "Subject: My Custom Subject\n******* Nagios *****\n\nNotification Type: NOTIFICATIONTYPE\nHost: HOSTNAME\nState: HOSTSTATE\n\nAdditional Info: HOSTOUTPUT\n"

In the example above, the subject line of the email notification is changed to "My Custom Subject".

Once you have edited the notify-host-by-email command definition, you need to restart the Nagios service. The Nagios service can be restarted by running the following command:


service nagios restart

Use code with caution. Learn more

After you have restarted the Nagios service, the new subject name of host notification will be used."


:D :D :D :D

Re: Different Email subjects for different notifications

Posted: Fri Jun 16, 2023 9:58 am
by DharmaNunna
So the issue with this is it would change the subject for all nottifications. I want to change the subject line only for a few server notifications.

Re: Different Email subjects for different notifications

Posted: Fri Jun 16, 2023 11:06 am
by bv406
DharmaNunna wrote: Fri Jun 16, 2023 9:58 am So the issue with this is it would change the subject for all nottifications. I want to change the subject line only for a few server notifications.
Maybe refer to this document on how to customize notification messages
https://answerhub.nagios.com/support/s/ ... s-b902c496

Re: Different Email subjects for different notifications

Posted: Sun Jun 25, 2023 11:33 pm
by Marilian
The problem is that doing so would divert the focus of all notifications. I'd like to customize the subject line for certain server alerts.
puppet hockey