Assume we have a nagios-logfile(nagios.log) like this:
[1416415259] PASSIVE HOST CHECK: server1;0;PING OK - Packet loss = 0%, RTA = 0.04 ms
[1416415259] PASSIVE HOST CHECK: server2;0;PING OK - Packet loss = 0%, RTA = 0.04 ms
[1416415259] EXTERNAL COMMAND: PROCESS_HOST_CHECK_RESULT;server3;0;PING OK - Packet loss = 0%, RTA = 0.15 ms
Then we can convert the UNIX-Timestamp using the following command:
perl -n -e 'if ($_ =~ m/^\[(\d+)\] (.*)$/g){ print scalar localtime($1) . " $2" ."\n"; }' nagios.log
This would be our output then:
Wed Nov 19 17:40:59 2014 PASSIVE HOST CHECK: server1;0;PING OK - Packet loss = 0%, RTA = 0.04 ms
Wed Nov 19 17:40:59 2014 PASSIVE HOST CHECK: server2;0;PING OK - Packet loss = 0%, RTA = 0.04 ms
Wed Nov 19 17:40:59 2014 EXTERNAL COMMAND: PROCESS_HOST_CHECK_RESULT;server3;0;PING OK - Packet loss = 0%, RTA = 0.15 ms