The following link has the answer you need:
http://support.nagios.com/knowledgebase/faqs/index.php?option=com_content&view=article&id=52&catid=35&faq_id=70&expand=false&showdesc=true
But, I'll post it here as well:
To quote:
-----8<-----
#!/usr/bin/perl
# nagios-log-print
# taken from the faqs section FAQID: F0070 on the www.nagios.org website
#
if (!...@argv[0]) {
print "Usage: {jumi [knowledge-based/faq/viewfaq.php]} <logfile name>\n";
print "\n";
print "prints the specified Nagios-logfile with timestamps\n";
print "converted to human readable time\n";
exit 1;
}
open(LOG,@ARGV[0]) || die "no Nagios log file named >>>>>>@ARGV[0]<<<<<<";
while (<LOG>) {
($part1, $part2) = split(/\s+/, $_, 2);
$part1 =~ s/\[//;
$part1 =~ s/\]//;
print "[", scalar localtime($part1), "]\;$part2\n";
};
close(LOG);
Alternatively, if you want to display the log from the command line use;
perl -pe 's/(\d+)/localtime(jumi)/e' nagios.log
From: rmp dmd [mailto:[email protected]]
Sent: Tuesday, May 25, 2010 3:27 PM
To: [email protected]
Subject: [Nagios-users] Reading Nagios Alerts
The nagios log files have different time stamps. How can this be converted to
the normal time stamp? Can nagios config be changed to output the normal time
stamp on the log files?
Thanks!
Roehl
[1274760000] LOG ROTATION: DAILY
[1274760000] LOG VERSION: 2.0
[1274760000] CURRENT HOST STATE: anchor;DOWN;HARD;1;CRITICAL - Host Unreachable
[1274760000] CURRENT HOST STATE: axis;UP;HARD;1;PING OK - Packet loss = 0%, RTA
= 0.67 ms
------------------------------------------------------------------------------
_______________________________________________
Nagios-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting
any issue.
::: Messages without supporting info will risk being sent to /dev/null