Appear Hostgroup in email (first group in list)

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Shalauras
Posts: 1
Joined: Wed May 20, 2020 5:01 pm

Appear Hostgroup in email (first group in list)

Post by Shalauras »

Hi, I am trying to send an email appearing the first variable HOSTGROUP

define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mailx -r [email protected] -s "** $NOTIFICATIONTYPE$ Alert: $HOSTGROUPNAME$/$HOSTNAME$ state $HOSTSTATE$ **" $CONTACTEMAIL$
}

Actually hosts is added in 2 groups -> AA and Linux
I added " $HOSTGROUPNAME$ ", so I receive email with Hostgroup right but I have 2 group (AA and Linux), as Linux alphabetic is last, I see email with "Linux" and not with "AA", are there any way to send in hostgroupname the first variable?
Now I have Alert: LINUX/HOST state xx
I want: AA/HOST state xx

Any ideas? thanks!
Locked