Page 1 of 1

HostGroupName Macro not send in Trap

Posted: Mon Jul 19, 2021 11:01 pm
by oslec
Hi,

I want to display the HostGroupName in Notifications and Traps
Nagios XI 5.8.4

I modify :

XI Host Handler
/usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=host --contact="$CONTACTNAME$" --contactemail="$CONTACTEMAIL$" --type=$NOTIFICATIONTYPE$ --escalated="$NOTIFICATIONISESCALATED$" --author="$NOTIFICATIONAUTHOR$" --comments="$NOTIFICATIONCOMMENT$" --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hostalias="$HOSTALIAS$" --hostdisplayname="$HOSTDISPLAYNAME$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --lasthoststate=$LASTHOSTSTATE$ --lasthoststateid=$LASTHOSTSTATEID$ --hoststatetype=$HOSTSTATETYPE$ --currentattempt=$HOSTATTEMPT$ --maxattempts=$MAXHOSTATTEMPTS$ --hosteventid=$HOSTEVENTID$ --hostproblemid=$HOSTPROBLEMID$ --hostoutput="$HOSTOUTPUT$" --longhostoutput="$LONGHOSTOUTPUT$" --datetime="$LONGDATETIME$" --hostgroupname="$HOSTGROUPNAME$"

nHostEvent NOTIFICATION-TYPE
OBJECTS { nHostname, nHostStateID, nHostStateType, nHostAttempt,
nHostDurationSec, nHostGroupName, nHostLastCheck, nHostLastChange,
nHostOutput }

*** GLOBAL HANDLER (snmptrapsender)...
Array
(
[event_id] => 500711
[event_source] => 2
[event_type] => 1
[event_time] => 2021-07-19 22:50:51
[event_meta] => Array
(
[handler-type] => host
[host] => mxmsotl01em000
[hostaddress] => 10.32.224.153
[hoststate] => DOWN
[hoststateid] => 1
[lasthoststate] => UP
[lasthoststateid] => 0
[hoststatetype] => HARD
[currentattempt] => 1
[maxattempts] => 5
[hosteventid] => 5282756
[hostproblemid] => 2572223
[hostoutput] => test
[longhostoutput] =>
[hostdowntime] => 0
)

[logging_enabled] => 1
)
PROCESSING:
PROCESSING:
Array
(
[address] => 10.150.10.73
[port] => 162
[hoststateid] => 0
[servicestateid] => 0
[statetype] => HARD
[snmpversion] => 2c
[community] => public
)
PHP Notice: Undefined index: contact in /usr/local/nagiosxi/html/includes/utils-notifications.inc.php on line 0
PHP Notice: Undefined variable: _SESSION in /usr/local/nagiosxi/html/includes/utils-users.inc.php on line 1980
RUNNING COMMAND: /usr/bin/snmptrap -v 2c -c public 10.150.10.73:162 '' NAGIOS-NOTIFY-MIB::nHostEvent nHostname s "mxmsotl01em000" nHostStateID i 1 nHostGroupName s "%hostgroupname%" nHostOutput s "test" nHostAlias s "mxmsotl01em000"
PROCESS EVENT: ID=500712, SOURCE=2, TYPE=2, TIME=2021-07-19 22:50:51

No hostgroup Name in the Trap variable...

But in the notifications command i see the hostgroupname

*** GLOBAL HANDLER...
Array
(
[event_id] => 500712
[event_source] => 2
[event_type] => 2
[event_time] => 2021-07-19 22:50:51
[event_meta] => Array
(
[notification-type] => host
[contact] => nagiosadmin
[contactemail] => @domain.com
[type] => PROBLEM
[escalated] => 0
[author] =>
[comments] =>
[host] => mxmsotl01em000
[hostaddress] => 10.32.224.153
[hostalias] => EMS
[hostdisplayname] => mxmsotl01em000
[hoststate] => DOWN
[hoststateid] => 1
[lasthoststate] => UP
[lasthoststateid] => 0
[hoststatetype] => HARD
[currentattempt] => 1
[maxattempts] => 5
[hosteventid] => 5282756
[hostproblemid] => 2572223
[hostoutput] => test
[longhostoutput] =>
[datetime] => Mon Jul 19 22:50:11 CDT 2021
[hostgroupname] => EMS
)

[logging_enabled] => 1
)

Got XI user id for contact 'nagiosadmin': 18
An email notification will be sent...

Email Notification Data:

Array
(
[meta] => Array
(
[notification-type] => host
[contact] => nagiosadmin
[contactemail] => @domain.com
[type] => PROBLEM
[escalated] => 0
[author] =>
[comments] =>
[host] => mxmsotl01em000
[hostaddress] => 10.32.224.153
[hostalias] => EMS
[hostdisplayname] => mxmsotl01em000
[hoststate] => DOWN
[hoststateid] => 1
[lasthoststate] => UP
[lasthoststateid] => 0
[hoststatetype] => HARD
[currentattempt] => 1
[maxattempts] => 5
[hosteventid] => 5282756
[hostproblemid] => 2572223
[hostoutput] => test
[longhostoutput] =>
[datetime] => Mon Jul 19 22:50:11 CDT 2021
[hostgroupname] => EMS
)

[referer] => includes/components/xicore/xicore.inc.php > Event Handler Notification Email
[to] => dc869n
[subject] => PROBLEM Host Alert - mxmsotl01em000 is DOWN
[high_priority] => 0
[message] => ***** Nagios XI Alert *****

Re: HostGroupName Macro not send in Trap

Posted: Tue Jul 20, 2021 9:50 am
by oslec
Hi,

Solved.
Edit the Host Handler & Service Handler and add the field hostgroupname and start showing in the array.


Regards,