Page 1 of 1

Change epoch time to date in nagios.log

Posted: Sun Jun 04, 2017 3:51 am
by reincarne
Hi,
Is there a way to change the the way Nagios writes the date in nagios.log file instead of epoch to a human date?

[1493793917] Event broker module 'NERD' deinitialized successfully.
[1493793917] ndomod: Shutdown complete.
[1493793917] Event broker module '/usr/local/nagios/bin/ndomod.o' deinitialized successfully.

Re: Change epoch time to date in nagios.log

Posted: Mon Jun 05, 2017 9:42 am
by lmiltchev
Try using perl -pe 's/(\d+)/localtime($1)/e' to convert the time to a "human readable" format.

Example:

Code: Select all

tail -50 /usr/local/nagios/var/nagios.log | perl -pe 's/(\d+)/localtime($1)/e'

Re: Change epoch time to date in nagios.log

Posted: Tue Jun 06, 2017 7:05 am
by reincarne
this does the trick, is there a way to force NAgios save it inside the logs to avoid from using such long command everytime?
I also don't want to create alias for this command.

Re: Change epoch time to date in nagios.log

Posted: Tue Jun 06, 2017 9:37 am
by avandemore
No there is not a way which will not break things.

Re: Change epoch time to date in nagios.log

Posted: Sun Jun 11, 2017 3:20 am
by reincarne
ok thanks

Re: Change epoch time to date in nagios.log

Posted: Mon Jun 12, 2017 9:20 am
by tmcdonald
Did you have any further (related) questions or are we okay to close this thread?