Nagios Log, epoch to human readable format

  16 Jan 2014


At the moment I’ve got a few servers to monitor and Nagios is a great tool for this task.

When I’d like to see what’s the current status of Nagios, I do

tail -f  /usr/local/nagios/var/nagios.log

Then I saw

[1389833196] Auto-save of retention data completed successfully.

What the heck is the number in []? Ok, it’s unixtimestamp. Because Nagios needs a unix timestamp in order to make the report work, then it makes sense.

As a Perl programmer, repution of Perl one-liner has come to be quite handy :P take a look at

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

the output has transformed to be

[Thu Jan 16 00:46:36 2014] Auto-save of retention data completed successfully.

yay! \o/ /me <- human can read it now…

comments powered by Disqus