Change epoch time to date in nagios.log

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
reincarne
Posts: 146
Joined: Wed Jun 26, 2013 4:39 am

Change epoch time to date in nagios.log

Post 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.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Change epoch time to date in nagios.log

Post 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'
Be sure to check out our Knowledgebase for helpful articles and solutions!
reincarne
Posts: 146
Joined: Wed Jun 26, 2013 4:39 am

Re: Change epoch time to date in nagios.log

Post 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.
avandemore
Posts: 1597
Joined: Tue Sep 27, 2016 4:57 pm

Re: Change epoch time to date in nagios.log

Post by avandemore »

No there is not a way which will not break things.
Previous Nagios employee
reincarne
Posts: 146
Joined: Wed Jun 26, 2013 4:39 am

Re: Change epoch time to date in nagios.log

Post by reincarne »

ok thanks
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Change epoch time to date in nagios.log

Post by tmcdonald »

Did you have any further (related) questions or are we okay to close this thread?
Former Nagios employee
Locked