Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

[dev.icinga.com #2879] resource.cfg verify NULL #1031

Closed
icinga-migration opened this Issue Jul 20, 2012 · 10 comments

Comments

Projects
None yet
1 participant
Member

icinga-migration commented Jul 20, 2012

This issue has been migrated from Redmine: https://dev.icinga.com/issues/2879

Created by pdeneu on 2012-07-20 20:19:42 +00:00

Assignee: mfriedrich
Status: Resolved (closed on 2012-08-09 15:06:21 +00:00)
Target Version: 1.8
Last Update: 2012-08-09 15:06:21 +00:00 (in Redmine)

Icinga Version: 1.7.1
OS Version: Debian

Hello,
i think it would be good to check content of resource.cfg during the verify.
If theres a macro in resource.cfg with NULL in icinga.log comes following error:

Error: NULL variable value - Line 76 of resource file '/var/lib/icinga/global/etc/resource.cfg'

And instance hangs...

Changesets

2012-07-31 10:47:50 +00:00 by mfriedrich 2c5c54a

core: bail out early with config error if resource.cfg macros contain NULL values #2879

plus
core: fix logical bug on icinga.cfg detection on config read #2879
core: add hint on icinga.cfg package location, and tip to read
Changelog CHANGES on upgrades #2879

refs #2879

2012-08-19 17:38:57 +00:00 by mfriedrich efaf0fe

core: bail out early with config error if resource.cfg macros contain NULL values #2879

plus
core: fix logical bug on icinga.cfg detection on config read #2879
core: add hint on icinga.cfg package location, and tip to read
Changelog CHANGES on upgrades #2879

refs #2879

Conflicts:
	Changelog
Member

icinga-migration commented Jul 23, 2012

Updated by pdeneu on 2012-07-23 08:23:25 +00:00

After deleting retention.dat the icinga instance runs normaly... Deleting the retention.dat ist not the best way to resolve problems!

Member

icinga-migration commented Jul 23, 2012

Updated by mfriedrich on 2012-07-23 08:49:30 +00:00

i have no idea what you are talking about. is this now a wishlist for null-'d-macro checks, or a problem with retention.dat?

btw - who puts config files below /var/lib/...?

Member

icinga-migration commented Jul 23, 2012

Updated by pdeneu on 2012-07-23 08:57:42 +00:00

My resource.cfg had a NULL variable ($USER14$= ). After restarting i get no verification errors but in log i get the message i wrote in first post.
After this my instance stopped working, it was not possible to restart the instance succesfull...
Every restart stopped in strace at this position:

write(4, "\n213:\n1=1202\n2=0\n3=0\n4=134280669"..., 425) = 425
write(4, "\n213:\n1=1202\n2=0\n3=0\n4=134280669"..., 487) = 487
write(4, "\n213:\n1=1202\n2=0\n3=0\n4=134280669"..., 535) = 535
write(4, "\n213:\n1=1202\n2=0\n3=0\n4=134280669"..., 594) = 594
write(4, "\n213:\n1=1202\n2=0\n3=0\n4=134280669"..., 588) = 588
write(4, "\n213:\n1=1202\n2=0\n3=0\n4=134280669"..., 549) = 549
write(4, "\n213:\n1=1202\n2=0\n3=0\n4=134280669"..., 393

After i deleted the retentation.dat my restart works successful....

My idea ist to check the resource.cfg macros of null values in icinga verify...

Member

icinga-migration commented Jul 23, 2012

Updated by mfriedrich on 2012-07-23 09:10:53 +00:00

i'm leaving soon, but i'll propose that diff for testing.

diff --git a/base/config.c b/base/config.c
index 6158d30..5ce4132 100644
--- a/base/config.c
+++ b/base/config.c
@@ -346,7 +346,10 @@ int read_main_config_file(char *main_config_file) {
                        mac->x[MACRO_RESOURCEFILE] = (char *)strdup(value);

                        /* process the resource file */
-                       read_resource_file(value);
+                       if (read_resource_file(value) == ERROR) {
+                               error = TRUE;
+                               break;
+                       }
                }

                else if (!strcmp(variable, "log_file")) {
Member

icinga-migration commented Jul 24, 2012

Updated by pdeneu on 2012-07-24 08:47:44 +00:00

Hello Michael,
works, thanks.
Little adaptation, the message comes twice and at third position is an information that theres an error in icinga.cfg too...

Reading configuration data...
Error: NULL variable value - Line 30 of resource file '/usr/local/icinga/etc/resource.cfg'
Error: NULL variable value - Line 30 of resource file '/usr/local/icinga/etc/resource.cfg'
Error in configuration file '/usr/local/icinga/etc/icinga.cfg' - Line 66 (NULL)
   Error processing main config file!
Member

icinga-migration commented Jul 27, 2012

Updated by mfriedrich on 2012-07-27 21:09:31 +00:00

  • Category set to Configuration
  • Status changed from New to Assigned
  • Assigned to set to mfriedrich
Member

icinga-migration commented Jul 31, 2012

Updated by mfriedrich on 2012-07-31 10:41:30 +00:00

i canjnot reproduce that output from yours. with my patch, my config errors out correctly, hinting to the correct line where the first error occured.

 icinga-dev /etc/icinga # cat resource.cfg 
###########################################################################
# RESOURCE.CFG
###########################################################################

# Sets $USER1$ to be the path to the plugins
$USER1$=/usr/lib/nagios/plugins

# 2879
$USER16$=
$USER17$= 

Jul 31 12:20:58 icinga-dev icinga: Error: NULL variable value - Line 9 of resource file '/etc/icinga/resource.cfg'

icinga-dev /etc/icinga # service icinga restart
Running configuration check...CONFIG ERROR! Restart aborted. See /var/icinga/icinga.chk for details.
icinga-dev /etc/icinga # service icinga show-errors
Running configuration check...
Icinga 1.8.0dev
Copyright (c) 2009-2012 Icinga Development Team (http://www.icinga.org)
Copyright (c) 2009-2012 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 10-17-2012
License: GPL

Reading configuration data...
Error: NULL variable value - Line 9 of resource file '/etc/icinga/resource.cfg'
Error in configuration file '/etc/icinga/icinga.cfg' - Line 87 (NULL)
   Error processing main config file!



***> 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/icinga/etc/icinga.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 definitions.  If you are upgrading from a previous
     version of Icinga, 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.

Result saved to /var/icinga/icinga.chk

line 87 in my icinga.cfg

resource_file=/etc/icinga/resource.cfg

so imho this is to be resolved, as the message shows 2 things

  • your resource.cfg is broken
  • icinga.cfg include on the resource.cfg path

i've added an error_message as well. and while i am at it, i found a logical error on the check of the main config file - it should not be OR, but AND - if none of icinga.cfg or nagios.cfg is passed, the error msg must show.

after correcting this too, the output looks fine again.

icinga-dev /etc/icinga # service icinga show-errors
Running configuration check...
Icinga 1.8.0dev
Copyright (c) 2009-2012 Icinga Development Team (http://www.icinga.org)
Copyright (c) 2009-2012 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 10-17-2012
License: GPL

Reading configuration data...
Error: NULL variable value - Line 9 of resource file '/etc/icinga/resource.cfg'
Error in configuration file '/etc/icinga/icinga.cfg' - Line 87 (Resource file parsing failed)
   Error processing main config file!



***> 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 definitions.  If you are upgrading from a previous
     version of Icinga, 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.

Result saved to /var/icinga/icinga.chk
Member

icinga-migration commented Jul 31, 2012

Updated by mfriedrich on 2012-07-31 10:43:37 +00:00

  • Target Version set to 1.8

and while i am at it, added a hint on the package location for icinga.cfg too. plus a hint to read the changelog CHANGES section.

Member

icinga-migration commented Jul 31, 2012

Updated by mfriedrich on 2012-07-31 10:48:19 +00:00

  • Status changed from Assigned to Feedback
  • Done % changed from 0 to 100
Member

icinga-migration commented Aug 9, 2012

Updated by mfriedrich on 2012-08-09 15:06:21 +00:00

  • Status changed from Feedback to Resolved
  • Icinga Version set to 1
  • OS Version set to Debian

i guess this is working fine now.

@icinga-migration icinga-migration added this to the 1.8 milestone Jan 17, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment