Time saving advice

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
greyclear
Posts: 27
Joined: Tue Sep 09, 2014 7:50 am

Time saving advice

Post by greyclear »

I am looking for a way to save time on this. I am doing check_ping on 40 different networks is there a way I can just define this all in one line? Trying to follow this http://nagios.sourceforge.net/docs/3_0/ ... ricks.html but I have mostly everything already in groups so how would I define a group and group defs for this?

So when I try this

Code: Select all


###############################################
## HOST DEFINITIONS
###############################################
define host{
	use		generic-network					
	host_name	*	
	alias		Our Network			

	hostgroups	Network			
	}
	
################################################
## HOST GROUP DEFINITIONS
################################################

define hostgroup{
	hostgroup_name		Host1 10.1.1.1, Host2 10.2.2.1, Host3 10.3.3.1		
	alias				Network				
	}
	
#################################
# This is just checking to see if the connection is alive
#################################
define service{
	use						generic-service
	host_name				Host1 10.1.1.1, Host2 10.2.2.1, Host3 10.3.3.1
	service_description		PING
	check_command			check_ping!200.0,20%!600.0,60%
	normal_check_interval	1
	retry_check_interval	1
	}

Error: Could not find any hostgroup matching 'Network' (config file '/usr/local/nagios/etc/objects/network.cfg', starting on line 4)
Error: Failed to process hostgroup names for host '*' (config file '/usr/local/nagios/etc/objects/network.cfg', starting at line 4)
Error processing object config files!


I'm guessing I can't use a * for host_name
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

Re: Time saving advice

Post by jolson »

You are correct - a hostname will need to be defined. The quickest way to accomplish what you're trying to do is to:
1. Tie all services to a hostgroup instead of individual hosts. Make hostgroups like 'generic-linux-checks.cfg, apache-http-checks.cfg, etc.' Attach hosts to the hostgroups and they will inherit the services.
2. Use host and service templates to define check periods. It looks like you already have this under control.

The confusion likely comes from the following entry:
All Hosts:
If you want to create identical services that are assigned to all hosts that are defined in your configuration files, you can use a wildcard in the host_name directive. The definition below would create a service called SOMESERVICE on all hosts that are defined in your configuration files. All the instances of the SOMESERVICE service would be identical (i.e. have the same check command, max check attempts, notification period, etc.).


define service{

host_name *

service_description SOMESERVICE

other service directives ...

}
Please note that here it is a service being defined, not a host. When a service is defined like this, it will be added to all hosts. I believe that hostgroups have some advantages over this method, as it's easier to make changes in the future. For example, if you wanted a remove this check from a host in the future, it would be simple to drop it out of a hostgroup - not so simple to drop it out of a wildcard. :)

Edit: Clarification
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
greyclear
Posts: 27
Joined: Tue Sep 09, 2014 7:50 am

Re: Time saving advice

Post by greyclear »

ok thanks
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

Re: Time saving advice

Post by jolson »

No problem. I edited my above post to be more clear.

If you have no further questions, would it be alright if I locked this thread and marked it as resolved? Thanks!
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
Locked