Re: [Nagios-devel] Empty hostgroup check in
Posted: Tue Dec 02, 2008 12:42 pm
--=-EKwZirer2BHy1Pe9H2Vr
Content-Transfer-Encoding: 7bit
Content-Type: text/plain
Hi all,
> Actually, what you want is that services linking to empty but
> existing hostgroups should not warn. Empty hostgroups are already
> valid in Nagios, but they cannot (currently) be used for assigning
> services in such a way that the service definition is ignored.
I've sometimes reached to this "limitation" also.
> In order to make the patch queueable, you'll have to make sure that
> it still errors out in the following conditions:
> * a hostgroup_name is given but not found
> * a host_name is given but not found
> * neither host_name nor hostgroup_name is given, and "register" is 1
A simple solution would be to add a new value to the register keyword.
The appended patch-stub prevents registering services with empty
memberlists as long as "register" is set to -1. Thus backward
compatibility is still provided.
There might also be other object types that could make use of this.
Matthias
--=-EKwZirer2BHy1Pe9H2Vr
Content-Transfer-Encoding: 7bit
Content-Type: text/x-patch; name=register.patch; charset=utf-8
Content-Disposition: attachment; filename=register.patch
--- old/nagios-3.0.5/xdata/xodtemplate.c 2008-06-23 23:43:22.000000000 +0200
+++ nagios-3.0.5/xdata/xodtemplate.c 2008-12-01 23:54:22.000000000 +0100
@@ -4107,7 +4107,13 @@
temp_service->have_retain_nonstatus_information=TRUE;
}
else if(!strcmp(variable,"register"))
- temp_service->register_object=(atoi(value)>0)?TRUE:FALSE;
+ if (atoi(value)>0)
+ temp_service->register_object = TRUE;
+ else if (atoi(value) == -1)
+ temp_service->register_object = -1;
+ else
+ temp_service->register_object = FALSE;
+
else if(variable[0]=='_'){
/* get the variable name */
@@ -5154,6 +5160,8 @@
/* get list of hosts */
temp_memberlist=xodtemplate_expand_hostgroups_and_hosts(temp_service->hostgroup_name,temp_service->host_name,temp_service->_config_file,temp_service->_start_line);
if(temp_memberlist==NULL){
+ if(temp_service->register_object==-1)
+ continue;
#ifdef NSCORE
logit(NSLOG_CONFIG_ERROR,TRUE,"Error: Could not expand hostgroups and/or hosts specified in service (config file '%s', starting on line %d)\n",xodtemplate_config_file_name(temp_service->_config_file),temp_service->_start_line);
#endif
--=-EKwZirer2BHy1Pe9H2Vr--
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]