Reading Nagios Alerts

Robert Wolfe rwolfe at i-evolve.com
Tue May 25 21:36:28 CEST 2010


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, at 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:rmp.dmd1229 at gmail.com]
Sent: Tuesday, May 25, 2010 3:27 PM
To: nagios-users at lists.sourceforge.net
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20100525/a0d97690/attachment.html>
-------------- next part --------------
------------------------------------------------------------------------------

-------------- next part --------------
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
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


More information about the Users mailing list