nagios -v not counting all warnings

Ton Voon ton.voon at opsera.com
Wed Dec 30 18:33:08 CET 2009


Hi Jim,

On 21 Dec 2009, at 15:59, Jim Avery wrote:

> define service
>  host_name             test
>  use                   generic-service
>  service_description   test
>  check_command         check_dummy!0 "test always succeeds"
> }
> define service
>  host_name             test
>  use                   generic-service
>  service_description   test
>  check_command         check_dummy!0 "test always succeeds"
> }

Thanks. This is basically just a service duplicated.

>
> When I run nagios -v against a nagios.cfg which reads this config, I  
> get:
>
>  Warning: Duplicate definition found for service 'test' on host
> 'test' (config file '/usr/local/nagios/etc/objects/test/services.cfg',
> starting on line 1)
>
> which is fair enough as the service is indeed defined twice, but in
> the totals at the end I get:
>
>  Total Warnings: 0
>  Total Errors:   0
>
> Note this behaves the same whether the second service is defined using
> directive "host_name test" or "hostgroup_name test".

I've got a minimal config that causes this error, and as you say, it  
prints a warning but then just continues.

Looking through the code, it is setting up skip lists for the objects,  
but doesn't correctly propagate errors back up. The specific change I  
made is this:

@@ -5264,7 +5269,7 @@ int xodtemplate_duplicate_services(void){
  #ifdef NSCORE
                          logit(NSLOG_CONFIG_WARNING,TRUE,"Warning:  
Duplicate definition found for service '%s' on host '%s' (config file  
'%s', starting on line %d)\n",temp_service
  #endif
-                        result=ERROR;
+                       return ERROR;
                          break;
                  case SKIPLIST_OK:
                          result=OK;



The result=ERROR was getting changed by the next loop through the list  
of services. Changing to a return now errors from the nagios -v with  
the message:

#    Read main config file okay...
# Processing object config file '/Users/tonvoon/git/nagios/t/etc/ 
duplicated-services.cfg'...
# Warning: Duplicate definition found for service 'Dummy service' on  
host 'host1' (config file '/Users/tonvoon/git/nagios/t/etc/duplicated- 
services.cfg', starting on line 12)
#    Error processing object config files!
#
#
# ***> The name of the main configuration file looks suspicious...
#
#      Make sure you are specifying the name of the MAIN configuration  
file on
#      the command line and not the name of another configuration  
file.  The
#      main configuration file is typically '/usr/local/nagios/etc/ 
nagios.cfg'
#
# ***> One or more problems was encountered while processing the  
config files...
#
#      Check your configuration file(s) to ensure that they contain  
valid
#      directives and data defintions.  If you are upgrading from a  
previous
#      version of Nagios, you should be aware that some variables/ 
definitions
#      may have been removed or modified in this version.  Make sure  
to read
#      the HTML documentation regarding the config files, as well as the
#      'Whats New' section to find out what has changed.


This function doesn't contain warnings/errors counters, so it is not  
straightforward to just increment the counters and continue.

So the question becomes: should, in the case of this duplicated  
object, nagios -v fail completely? All the current tests pass expect  
for this case. My feeling is yes since there is something  
fundamentally wrong in your configuration if you have duplicated  
objects (which is the "right" one for Nagios to use?).

Ton


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 




More information about the Developers mailing list