Posted a previous thread a while back about using the REST API (it's here if you're curious: https://support.nagios.com/forum/viewto ... 16&t=37510 )
Still trying to figure out a workaround to this - Here's my situation:
We currently have an AWS account where we spin up and burn down tens of VMs every day. Most of the new hosts need to be added to Nagios and most of the VMs burned down need to be removed from Nagios. Currently, the way we've been adding the hosts is to bulk host clone and import and removing them is a pain in the a$$ (delete the services, then delete the hosts).
So my thought was to generate a config file for every host that is spun up and send that config file to the Nagios server in the /usr/local/nagios/etc/import directory and then when we do an Apply Config, it would pick up the hosts (along with the services assigned to the host group). I've got the script and transfer the file to Nagios part working.
Where I'm struggling is trying to figure out how to add these hosts to a host group that inherit the pre-determined services for that particular VM type where each host has a predefined group based on function (some use apache, some use java, some use MySQL, etc, etc, etc and that's how we group them). Most of the hosts share the same types of checks, but each have specific checks added based on what they do.
For whatever reason, I'm truly not understanding the OO piece of setting up a host group with services... Maybe I'm just making it way harder than I need to?
Is there a step-by-step tutorial on setting this up? Or can someone walk me through this?
More automation help needed
Re: More automation help needed
I might not be understanding your requirements, but doesn't this just boil down to assigning a service to a hostgroup?highness wrote:Where I'm struggling is trying to figure out how to add these hosts to a host group that inherit the pre-determined services for that particular VM type
https://assets.nagios.com/downloads/nag ... ml#service
The hostgroup_name line in the service definition will accomplish this for you, then any host added to that group gets the check.
Former Nagios employee
Re: More automation help needed
I think I may be making this harder than I need to.
I was thinking that I need to create a service group (with the associated service checks) and then assign the service group to a host group, then assign hosts to that host group.
Am I wrong?
I was thinking that I need to create a service group (with the associated service checks) and then assign the service group to a host group, then assign hosts to that host group.
Am I wrong?
Re: More automation help needed
This cannot currently be done directly. You will want to add the hosts to a host group, then assign whatever services directly to that host group.highness wrote:I was thinking that I need to create a service group (with the associated service checks) and then assign the service group to a host group
Former Nagios employee
Re: More automation help needed
The other dilema that I have is that I have two types of hosts (with different configurations and different types of checks) and I really need to group into the same logical group - similar to this:
Web Portal
API Portal
Is there an easy way to group those together as a host group? If I'm understanding this correctly, is that if I put these different hosts into the same host group, they will share the same checks (and some won't apply to each other).
Does that make sense?
Web Portal
Code: Select all
Hostname Server Type
box1.ourcompany.com tomcat
box2.ourcompany.com tomcat
box3.ourcompany.com tomcat
box4.ourcompany.com tomcat
lbal1.ourcompany.com load balancer
lbal2.ourcompany.com load balancer
Code: Select all
Hostname Server Type
box5.ourcompany.com jboss
box6.ourcompany.com jboss
box7.ourcompany.com jboss
box8.ourcompany.com jboss
lbal10.ourcompany.com load balancer
lbal12.ourcompany.com load balancer
Does that make sense?
Re: More automation help needed
You can use multiple hostgroups:
If you had a generic set of services that you would like applied to ALL load balancers you could create a new one:
Then when you add a new host you could just set their hostgroup to the bottom level and they would inherit all of the proper services.
Code: Select all
Name: portals
Members: web_portal, api_portal
Services attached: All services that both web_portal and api_portal hostgroups should getCode: Select all
Name: web_portal
Members: wp_tomcat, wp_lb
Services attached: All services that both wp_tomcat and wp_lb should getCode: Select all
Name: wp_tomcat
Members: All Web Portal tomcat hosts
Services attached: All the tomcat servicesCode: Select all
Name: wp_lb
Members: All Web Portal load balancer hosts
Services attached: All the web portal load balancer servicesCode: Select all
Name: api_portal
Members: api_jboss, api_lb
Services attached: All services that API portal hosts should getCode: Select all
Name: api_jboss
Members: All API portal jboss hosts
Services attached: All API portal jboss servicesCode: Select all
Name: api_lb
Members: All API Portal load balancer hosts
Services attached: All the API portal load balancer servicesCode: Select all
Name: generic_lb
Members: wp_lb, api_lb, etc
Services attached: All the generic load balancer services