Page 2 of 2

Re: Hostgroup within a hostgroup

Posted: Mon Mar 28, 2016 10:31 am
by derekb
Sorry for the delay... been swamped lately. I found 2 hosts/hostgroups that produced alerts 1 day apart. 1 good, 1 bad. I'll list them here, but I'm going to try to scape out any of the clients info.

Example 1:
Host produces an alert, but in the alert I received it showed hostgroup information for the OVERALL host group.

Host:

Code: Select all


define host {
	host_name			Company 1 - Windsor - Smart RG
	address				10.40.100.246
	hostgroups			Company 1 - Windsor
	check_command			check-host-alive!!!!!!!!
	max_check_attempts		3
	check_interval			1
	retry_interval			1
	check_period			24x7
	contacts			nagiosadmin
	contact_groups			PPPoE Customers
	notification_interval		15
	notification_period		24x7
	notification_options		d,u,r,
	notifications_enabled		1
	icon_image			cable_modem.png
	statusmap_image			cable_modem.png
	register			1
	}	
Hostgroup:

Code: Select all

define hostgroup {
	hostgroup_name                		Company 1 - Windsor
	alias                         		1234 Main Street, Windsorr, ON
	notes                         		Bell Order #: EMC-151-01
	notes_url                     		https://mywebsite.com
	}	
This is how the email/alert was received - you will see it shows Host Group info from the group "PPPoE CUSTOMERS"

Code: Select all

Nagios has detected a problem with this host.

Notification Type: PROBLEM

Customer Information:
Hostgroup: PPPoE Customers
Site Address: PPPoE Customers
Sharepoint URL: 
Notes: 

Host Information:
Host: Company 1 - Windsor - SmartRG
State: DOWN
Address: 10.40.100.246
Info: CRITICAL - 10.40.100.246: rta nan, lost 100%
Date/Time: 2016-03-26 05:28:20
Now, here is EXample 2, where the alert showed the correct hostgroup information inside of it:

Host:

Code: Select all

define host {
	host_name			Company 2
	use				xiwizard_passive_host
	address				Company 2
	hostgroups			Company 2
	check_command			check_freshness_host!!!!!!!!
	max_check_attempts		5
	check_interval			5
	retry_interval			1
	passive_checks_enabled		1
	check_period			xi_timeperiod_24x7
	check_freshness			1
	freshness_threshold		120
	contacts			nagiosadmin,tech
	notification_interval		20
	notification_period		xi_timeperiod_24x7
	notification_options		d,u,r,
	notifications_enabled		1
	icon_image			passiveobject.png
	statusmap_image			passiveobject.png
	_xiwizard			passiveobject
	register			1
	}	
Hostrgroup:

Code: Select all

define hostgroup {
	hostgroup_name                		Company 2
	alias                         		5555 Centre Street, Scarborough, ON
	notes                         		Bell Order #: EMC-174-01, Rogers Internet Primary WAN
	notes_url                     		https://somedomain.com
	}	
And finally, how the email/alert was received -- contains correct info from host group "Company 2"

Code: Select all


Nagios has detected a problem with this service.

Notification Type: PROBLEM

Customer Information:
Hostgroup: Company 2
Site Address: 5555 Centre Street, Scarborough, ON
Sharepoint URL: https://somedomain.com
Notes: Bell Order #: EMC-174-01, Rogers Internet Primary WAN

Service Information:
Service: Outside Ping
Host: Company 2
Address: Company 2
State: CRITICAL

Info:
PING CRITICAL - Packet loss = 100%
Date/Time: 2016-03-27 17:14:38
---------------------

This is how I have the Host to Hostgroup relationship setup:
Open Host1, click MANAGE HOSTGROUPS, and add the host to Hostgroup COMPANY 1. Then I go to the 'overall' hostgroup "PPPoE Customers" and click MANAGE HOSTGROUPS. Here, I add each customers Host Group.

Summary of problem:
Sometimes the alert shows the data from hostgroup "Company X", which is what is desired. But other times, it will show data from hostgroup "PPPoE Customers", which is not desired as I'm simply using that as a way to 'group' customers with a similar paid-service from me.

I hope this helps.

Re: Hostgroup within a hostgroup

Posted: Mon Mar 28, 2016 12:54 pm
by lmiltchev
Summary of problem:
Sometimes the alert shows the data from hostgroup "Company X", which is what is desired. But other times, it will show data from hostgroup "PPPoE Customers", which is not desired as I'm simply using that as a way to 'group' customers with a similar paid-service from me.
Are both notifications received by the same user? What macro is being used for the hostgroup? Show the "Notification Messages" settings for this user.

Depending on the macro used, you may have a different hostgroup(s) in the output.

Example 1:
In the notification handler, you have:

Code: Select all

--hg="$HOSTGROUPNAME$"
In the Notification Messages, you have:

Code: Select all

Hostgroup: %hg%
You will see ONLY one hostgroup.

Example 2:
In the notification handler, you have:

Code: Select all

--hg="$HOSTGROUPNAMES$"
In the Notification Messages, you have:

Code: Select all

Hostgroup: %hg%
You will see ALL hostgroups linked to your host.
example01.PNG
https://assets.nagios.com/downloads/nag ... tgroupname

Re: Hostgroup within a hostgroup

Posted: Mon Mar 28, 2016 1:07 pm
by derekb
There's really just 1 user that receives the emails, nagiosadmin, which goes to my inbox. On some of the hosts, I have a contact group 'PPPoE Customers' that contains nagiosadmin and another user. But all of my examples are alerts sent to nagiosadmin > my inbox.

User nagiosadmin uses the following notification macros:

Code: Select all

define command {
       command_name                  		xi_host_notification_handler
       command_line                  		/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$" --notes="$HOSTNOTES$" --hostgroup="$HOSTGROUPNAME$" --hostgroupnotes="$HOSTGROUPNOTES$" --hostgroupnotesurl="$HOSTGROUPNOTESURL$" --hostgroupalias="$HOSTGROUPALIAS$"
}

define command {
       command_name                  		xi_service_notification_handler
       command_line                  		/usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=service --contact="$CONTACTNAME$" --contactemail="$CONTACTEMAIL$" --type=$NOTIFICATIONTYPE$ --escalated="$NOTIFICATIONISESCALATED$" --author="$NOTIFICATIONAUTHOR$" --comments="$NOTIFICATIONCOMMENT$" --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hostalias="$HOSTALIAS$" --hostdisplayname="$HOSTDISPLAYNAME$" --service="$SERVICEDESC$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --servicestate=$SERVICESTATE$ --servicestateid=$SERVICESTATEID$ --lastservicestate=$LASTSERVICESTATE$ --lastservicestateid=$LASTSERVICESTATEID$ --servicestatetype=$SERVICESTATETYPE$ --currentattempt=$SERVICEATTEMPT$ --maxattempts=$MAXSERVICEATTEMPTS$ --serviceeventid=$SERVICEEVENTID$ --serviceproblemid=$SERVICEPROBLEMID$ --serviceoutput="$SERVICEOUTPUT$" --longserviceoutput="$LONGSERVICEOUTPUT$" --datetime="$LONGDATETIME$" --hostgroup="$HOSTGROUPNAME$" --hostgroupnotes="$HOSTGROUPNOTES$" --hostgroupnotesurl="$HOSTGROUPNOTESURL$" --hostgroupalias="$HOSTGROUPALIAS$" --servicenotes="$SERVICENOTES$" --servicenotesurl="$SERVICENOTESURL$" --serviceactionurl="$SERVICEACTIONURL$"
}
Also, the notification messages settings for 'nagiosadmin' are as follows:

Host Alerts:

Code: Select all

***** Empire Monitoring Alert *****

%alertsummary%

Notification Type: %type%

Customer Information:
Hostgroup: %hostgroup%
Site Address: %hostgroupalias%
Sharepoint URL: %hostgroupnotesurl%
Notes: %hostgroupnotes%

Host Information:
Host: %host%
State: %hoststate%
Address: %hostaddress%
Info: %hostoutput%
Date/Time: %datetime%

Respond: %responseurl%
Nagios URL: %xiserverurl%
Services:

Code: Select all

***** Empire Monitoring Alert *****

%alertsummary%

Notification Type: %type%

Customer Information:
Hostgroup: %hostgroup%
Site Address: %hostgroupalias%
Sharepoint URL: %hostgroupnotesurl%
Notes: %hostgroupnotes%

Service Information:
Service: %service%
Host: %host%
Address: %hostaddress%
State: %servicestate%

Info:
%serviceoutput%
Date/Time: %datetime%

Respond: %responseurl%
Nagios URL: %xiserverurl%

Re: Hostgroup within a hostgroup

Posted: Mon Mar 28, 2016 2:32 pm
by lmiltchev
Do you see all of the hostgroups that your host belongs to when you change your host & service notification handlers from this:
define command {
command_name xi_host_notification_handler
command_line /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$" --notes="$HOSTNOTES$" --hostgroup="$HOSTGROUPNAME$" --hostgroupnotes="$HOSTGROUPNOTES$" --hostgroupnotesurl="$HOSTGROUPNOTESURL$" --hostgroupalias="$HOSTGROUPALIAS$"
}

define command {
command_name xi_service_notification_handler
command_line /usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=service --contact="$CONTACTNAME$" --contactemail="$CONTACTEMAIL$" --type=$NOTIFICATIONTYPE$ --escalated="$NOTIFICATIONISESCALATED$" --author="$NOTIFICATIONAUTHOR$" --comments="$NOTIFICATIONCOMMENT$" --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hostalias="$HOSTALIAS$" --hostdisplayname="$HOSTDISPLAYNAME$" --service="$SERVICEDESC$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --servicestate=$SERVICESTATE$ --servicestateid=$SERVICESTATEID$ --lastservicestate=$LASTSERVICESTATE$ --lastservicestateid=$LASTSERVICESTATEID$ --servicestatetype=$SERVICESTATETYPE$ --currentattempt=$SERVICEATTEMPT$ --maxattempts=$MAXSERVICEATTEMPTS$ --serviceeventid=$SERVICEEVENTID$ --serviceproblemid=$SERVICEPROBLEMID$ --serviceoutput="$SERVICEOUTPUT$" --longserviceoutput="$LONGSERVICEOUTPUT$" --datetime="$LONGDATETIME$" --hostgroup="$HOSTGROUPNAME$" --hostgroupnotes="$HOSTGROUPNOTES$" --hostgroupnotesurl="$HOSTGROUPNOTESURL$" --hostgroupalias="$HOSTGROUPALIAS$" --servicenotes="$SERVICENOTES$" --servicenotesurl="$SERVICENOTESURL$" --serviceactionurl="$SERVICEACTIONURL$"
}
to this:
define command {
command_name xi_host_notification_handler
command_line /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$" --notes="$HOSTNOTES$" --hostgroup="$HOSTGROUPNAMES$" --hostgroupnotes="$HOSTGROUPNOTES$" --hostgroupnotesurl="$HOSTGROUPNOTESURL$" --hostgroupalias="$HOSTGROUPALIAS$"
}

define command {
command_name xi_service_notification_handler
command_line /usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=service --contact="$CONTACTNAME$" --contactemail="$CONTACTEMAIL$" --type=$NOTIFICATIONTYPE$ --escalated="$NOTIFICATIONISESCALATED$" --author="$NOTIFICATIONAUTHOR$" --comments="$NOTIFICATIONCOMMENT$" --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hostalias="$HOSTALIAS$" --hostdisplayname="$HOSTDISPLAYNAME$" --service="$SERVICEDESC$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --servicestate=$SERVICESTATE$ --servicestateid=$SERVICESTATEID$ --lastservicestate=$LASTSERVICESTATE$ --lastservicestateid=$LASTSERVICESTATEID$ --servicestatetype=$SERVICESTATETYPE$ --currentattempt=$SERVICEATTEMPT$ --maxattempts=$MAXSERVICEATTEMPTS$ --serviceeventid=$SERVICEEVENTID$ --serviceproblemid=$SERVICEPROBLEMID$ --serviceoutput="$SERVICEOUTPUT$" --longserviceoutput="$LONGSERVICEOUTPUT$" --datetime="$LONGDATETIME$" --hostgroup="$HOSTGROUPNAMES$" --hostgroupnotes="$HOSTGROUPNOTES$" --hostgroupnotesurl="$HOSTGROUPNOTESURL$" --hostgroupalias="$HOSTGROUPALIAS$" --servicenotes="$SERVICENOTES$" --servicenotesurl="$SERVICENOTESURL$" --serviceactionurl="$SERVICEACTIONURL$"
}
and apply configuration?

Re: Hostgroup within a hostgroup

Posted: Mon Mar 28, 2016 3:33 pm
by derekb
Changed commands to show 'HOSTGROUPS' -- plural.

Changed the IP to something invalid so the check would fail. It DOES show it belonging to 2 hostgroups. But again, this one displays the PPPoE Customers hostgroup data in the alert, when another host/hostgroup set up identically shows the alert with the OTHER hostgroup data. Very odd...

Alert as follows:

Code: Select all

***** Empire Monitoring Alert *****

Nagios has detected a problem with this host.

Notification Type: PROBLEM

Customer Information:
Hostgroup: PPPoE Customers,Company 1 - Windsor
Site Address: PPPoE Customers
Sharepoint URL: 
Notes: 

Host Information:
Host: Company 1 - Windsor - SmartRG
State: DOWN
Address: 10.40.100.24666
Info: check_icmp: Failed to resolve 10.40.100.24666
Date/Time: 2016-03-28 16:30:39

Re: Hostgroup within a hostgroup

Posted: Mon Mar 28, 2016 3:58 pm
by lmiltchev
Are you talking about the "Site Address" data? You have:

Code: Select all

Site Address: %hostgroupalias%
which most probably displays only the primary hostgroup associated with this particular host.

https://assets.nagios.com/downloads/nag ... groupalias

Re: Hostgroup within a hostgroup

Posted: Mon Mar 28, 2016 4:01 pm
by derekb
lmiltchev wrote:Are you talking about the "Site Address" data? You have:

Code: Select all

Site Address: %hostgroupalias%
which most probably displays only the primary hostgroup associated with this particular host.

https://assets.nagios.com/downloads/nag ... groupalias
Well, whatever it is doing... it's not consistent. How do I change the 'primary hostgroup' of these hosts then? They've all been setup identically as you can see from the config output. I'm stumped on this one...

Re: Hostgroup within a hostgroup

Posted: Mon Mar 28, 2016 4:45 pm
by lmiltchev
I would recommend that you open a new support ticket in our email ticketing system. Please email us the profile.zip to [email protected]. Thank you!

Re: Hostgroup within a hostgroup

Posted: Mon Mar 28, 2016 6:49 pm
by derekb
Email sent per your request

Re: Hostgroup within a hostgroup

Posted: Tue Mar 29, 2016 9:05 am
by tmcdonald
Received. I'll be locking this thread now, and we will continue in the ticket.