Page 2 of 2

Re: nagios.log (null)

Posted: Tue Oct 15, 2013 5:17 pm
by MichaelMoritz

Code: Select all

ls -la /usr/local/nagios/var/nagios.log
-rw-r--r--  1 nagios  nagios  4200 Oct 15 16:41 /usr/local/nagios/var/nagios.log

Re: nagios.log (null)

Posted: Wed Oct 16, 2013 10:43 am
by abrist
lets make sure the nagios group has write permissions:

Code: Select all

chmod g+w /usr/local/nagios/var/nagios.log

Re: nagios.log (null)

Posted: Wed Oct 16, 2013 12:20 pm
by MichaelMoritz

Code: Select all

vc70:/usr/local/nagios/var>ll nagios.log
-rw-rw-r--  1 nagios  nagios  5040 Oct 16 12:17 nagios.log

vc70:/usr/local/nagios/var>sudo /etc/rc.d/nagios restart
Running configuration check...done.
Stopping nagios: .done.
Starting nagios: done.

vc70:/usr/local/nagios/var>tail -4 nagios.log
[1381943945] (null)
[1381943945] (null)
[1381943945] (null)
[1381943945] (null)


Re: nagios.log (null)

Posted: Thu Oct 17, 2013 10:49 am
by slansing
I know it worked in the past but have not had a need to check the logs for some time. I've done some upgrades since.
What were these upgrades that you did? Did you make any changes to the system such as adding a new logging system?

Re: nagios.log (null)

Posted: Thu Oct 17, 2013 11:05 am
by MichaelMoritz
I upgraded the OS from NetBSD 5.1.2 to 6.1.2 in June 2013. Looking back through my archives I don't have any of the nagios logs prior to the OS upgrade, so it does seem logical that this may have broke then.

I find it interesting though that I can log to syslog but not to nagios.log. Well [timestamp] (null) gets logged.

When I realized logging was broken I tried to upgraded to Nagios 4.0.0 but encountered compile failures. I posted the problem to this forum but have not found a solution. http://support.nagios.com/forum/viewtop ... =7&t=21531 FYI I also tried compiling 4.0.1 with the same failures.

Re: nagios.log (null)

Posted: Thu Oct 17, 2013 1:04 pm
by MichaelMoritz
I think if found something. If I add a line to logging.c, removing the printing of the log_time, I get the expected output.

Code: Select all

        /* write the buffer to the log file */
        fprintf(fp, "[%lu] %s\n", log_time, buffer);
        fprintf(fp, "here %s\n", buffer);
I'm not a C programmer and do not know what the %lu is but I do notice the following warnings when I compile:

Code: Select all

#make nagios
cd ./base && make
gcc -Wall -g -O2 -DHAVE_CONFIG_H -DNSCORE  -c logging.c
logging.c: In function 'write_to_log':
logging.c:235:2: warning: format '%lu' expects type 'long unsigned int', but argument 3 has type 'time_t'
logging.c:235:2: warning: format '%lu' expects type 'long unsigned int', but argument 3 has type 'time_t'
logging.c: In function 'log_debug_info':
logging.c:558:2: warning: format '%lu' expects type 'long unsigned int', but argument 3 has type 'time_t'
logging.c:558:2: warning: format '%06lu' expects type 'long unsigned int', but argument 4 has type 'suseconds_t'
logging.c:558:2: warning: format '%lu' expects type 'long unsigned int', but argument 3 has type 'time_t'
logging.c:558:2: warning: format '%06lu' expects type 'long unsigned int', but argument 4 has type 'suseconds_t'
gcc -Wall -g -O2 -DHAVE_CONFIG_H -DNSCORE -o nagios nagios.c broker.o nebmods.o ../common/shared.o checks.o config.o commands.o events.o flapping.o logging.o macros-base.o netutils.o notifications.o sehandlers.o skiplist.o utils.o retention-base.o xretention-base.o comments-base.o xcomments-base.o objects-base.o xobjects-base.o statusdata-base.o xstatusdata-base.o perfdata-base.o xperfdata-base.o downtime-base.o xdowntime-base.o    -Wl,-export-dynamic   -lm  -lpthread

Re: nagios.log (null)

Posted: Thu Oct 17, 2013 1:30 pm
by MichaelMoritz
google tells me that NetBSD 6 time_t is 64 bit and %lu is 32. I changed the print to %llu and logging is working.

Code: Select all

        fprintf(fp, "[%llu] %s\n", log_time, buffer);
I'm sure this is not the *right* way to do it for portability, but hopefully this can put someone knowledgeable in C on the right track. :-)

Re: nagios.log (null)

Posted: Thu Oct 17, 2013 2:14 pm
by abrist
could you submit a bug report to http://tracker.nagios.org with your solution?

Re: nagios.log (null)

Posted: Thu Oct 17, 2013 3:33 pm
by MichaelMoritz
Done, ID 512.

Thanks for your help in troubleshooting.
Mike

Re: nagios.log (null)

Posted: Thu Oct 17, 2013 3:36 pm
by abrist
I also opened an internal bug report as well. It should catch Eric's attention. I presume the proper place to follow the bug will now be on tracker.