Department host group

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
ccordero103175
Posts: 2
Joined: Wed Mar 29, 2017 5:07 pm

Department host group

Post by ccordero103175 »

I want to create a host group for a department with both Linux and Windows servers, but I can't seem to resolve which services to check with what host type in my cfg file. Anyone have a template for this situation. I want to have something like:

Host Group 'department-hosts'

Code: Select all

WindowsHost1
  WindowsService1
  WindowsService2
WindowsHost2
  WindowsService1
  WindowsService2
LinuxHost1
  LinuxService1
  LinuxService2
LinuxHost2
  LinuxService1
  LinuxService2
I tried defining this in my cfg file, but windows hosts end up checking linux services and vice-versa. So far I have:

Code: Select all

define host {
  use generic-host
  name department-linux-host
  check_interval 5
  check_command
  contact_groups department-contacts
  notification_interval 30
  check_command check_tcp!22
  hostgroups department-hosts
  register 0
}

define host {
  use generic-host
  name department-windows-host
  check_interval 5
  check_command
  contact_groups department-contacts
  notification_interval 30
  check_command check-host-alive
  hostgroups department-hosts
  register 0
}

define hostgroup {
  hostgroup_name department-hosts
  alias Department Hosts
}

define host {
  use department-linux-host
  host_name LinuxHost1
  address LinuxHost1.domain.edu
}

define host {
  use department-linux-host
  host_name LinuxHost2
  address LinuxHost2.domain.edu
}

define host {
  use department-windows-host
  host_name WindowsHost1
  address WindowsHost1.domain.edu
}

define host {
  use department-windows-host
  host_name WindowsHost2
  address WindowsHost2.domain.edu
}

define service {
  name department-linux-service
  use generic-service
  check_interval 15
  retry_interval 5
  notification_interval 30
  max_check_attempts 3
  register 0
  contact_groups department-contacts
  hostgroup_name department-hosts
  host_name LinuxHost1,LinuxHost2
}

define service {
  use department-linux-service
  service_description LinuxService1
  check_command checknrpe_ip4!service1
}

define service {
  use department-linux-service
  service_description LinuxService2
  check_command checknrpe_ip4!service2
}

define service {
  name department-windows-service
  use generic-service
  check_interval 15
  retry_interval 5
  notification_interval 30
  max_check_attempts 3
  register 0
  contact_groups department-contacts
  hostgroup_name department-hosts
  host_name WindowsHost1,WindowsHost2
}

define service {
  use department-windows-service
  service_descriptions WindowsService1
  check_command check_nscp!service1
}

define service {
  use department-windows-service
  service_descriptions WindowsService2
  check_command check_nscp!service2
}
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Department host group

Post by mcapra »

If your goal is to assign the Services to the Hostgroup, rather than defining a bunch of duplicate services for each host, the best way to structure it would depend on which agents you're leveraging since they may have different syntax for their check commands.

If everything is using NCPA, you probably wouldn't need to distinguish your Linux machines from your Windows machines. You could define a "department-hosts" Hostgroup like so and assign some hosts to it:

Code: Select all

define hostgroup {
	hostgroup_name                		department-hosts
	alias                         		Hosts for some department
	members                       		192.168.67.101,192.168.67.103,192.168.67.105,192.168.67.106,192.168.67.107
	}	
Then, if I wanted all those machines in department-hosts to use the same basic "CPU Usage" check, I could write my Service definition like so:

Code: Select all

define service {
	service_description		CPU Usage
	hostgroup_name			department-hosts
	check_command			check_xi_ncpa!-t 'welcome123' -P 5693 -M cpu/percent -w 20 -c 40 -q 'aggregate=avg'!!!!!!!
	max_check_attempts		5
	check_interval			5
	retry_interval			1
	check_period			24x7
	notification_interval		60
	notification_period		24x7
	contacts			nagiosadmin
	}	
With the hostgroup_name being the key component that distributes the Service across all members of the Hostgroup.
Former Nagios employee
https://www.mcapra.com/
ccordero103175
Posts: 2
Joined: Wed Mar 29, 2017 5:07 pm

Re: Department host group

Post by ccordero103175 »

My goal is to display Windows and Linux servers in one hostgroup so I can see them in Nagios together on one page. The problem is my Linux and Windows servers respond to different commands from Nagios. I thought by creating two service templates, department-linux-service and department-windows-service, and defining the which hosts were in which template I'd be able to tell Nagios which commands to send to which server type. This does not appear to be the case.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Department host group

Post by mcapra »

You could probably do it that way, but if you have separate checks for your Linux and Windows machines you could also just define subgroups of the "department-hosts" Hostgroup. Something like "department-hosts-linux" and "department-hosts-windows".

Here's a sample configuration set I did:

Code: Select all

define hostgroup {
	hostgroup_name                		department-hosts
	alias                         		Hosts for some department
	hostgroup_members             		department-hosts-linux,department-hosts-windows
	}	

define hostgroup {
	hostgroup_name                		department-hosts-linux
	alias                         		Linux
	members                       		192.168.67.101,192.168.67.103,192.168.67.105,192.168.67.106,192.168.67.107,192.168.67.4
	}	

define hostgroup {
	hostgroup_name                		department-hosts-windows
	alias                         		Windows
	members                       		192.168.67.99
	}	
In this case, department-hosts-windows could be assigned all my Windows/NSClient++ based Service checks and department-hosts-linux could be assigned all my Linux/NRPE based Service checks. But, if I wanted a single point of visibility/contact, I could just look at the department-hosts Hostgroup since that contains both department-hosts-linux and department-hosts-windows as members.

Just for the sake of visualization, here's how the status overview would look in Nagios XI:
2017_03_30_15_47_48_Dashboards_Nagios_XI.png
Former Nagios employee
https://www.mcapra.com/
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Department host group

Post by rkennedy »

Check out this document I wrote a while ago which helps explain the whole process of hostgroups / services / templates. It makes for an easy deployment.
Nagios-Automating-with-Nagios-XI.pdf
(341.48 KiB) Downloaded 314 times
Former Nagios Employee
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Department host group

Post by tmcdonald »

Thanks for the assist, @rkennedy!
Former Nagios employee
Locked