nagios.log (null)

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.
MichaelMoritz
Posts: 20
Joined: Tue Oct 01, 2013 1:49 pm

Re: nagios.log (null)

Post 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
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: nagios.log (null)

Post by abrist »

lets make sure the nagios group has write permissions:

Code: Select all

chmod g+w /usr/local/nagios/var/nagios.log
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
MichaelMoritz
Posts: 20
Joined: Tue Oct 01, 2013 1:49 pm

Re: nagios.log (null)

Post 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)

slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: nagios.log (null)

Post 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?
MichaelMoritz
Posts: 20
Joined: Tue Oct 01, 2013 1:49 pm

Re: nagios.log (null)

Post 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.
MichaelMoritz
Posts: 20
Joined: Tue Oct 01, 2013 1:49 pm

Re: nagios.log (null)

Post 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
MichaelMoritz
Posts: 20
Joined: Tue Oct 01, 2013 1:49 pm

Re: nagios.log (null)

Post 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. :-)
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: nagios.log (null)

Post by abrist »

could you submit a bug report to http://tracker.nagios.org with your solution?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
MichaelMoritz
Posts: 20
Joined: Tue Oct 01, 2013 1:49 pm

Re: nagios.log (null)

Post by MichaelMoritz »

Done, ID 512.

Thanks for your help in troubleshooting.
Mike
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: nagios.log (null)

Post 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.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Locked