Problem with nagios logs

YAVUZ TEMIZKAN ytemizkan at inteltek.com.tr
Fri Sep 17 10:08:02 CEST 2004


Thanks this script seems to be helpful.
We want to see the logs by date ( i mean like when did the last problem occur about some host) so unix time doesnt make sense in this situation.
Regards
Yavuz

-----Original Message-----
From: Andreas Ericsson [mailto:ae at op5.se] 
Sent: 16 Eylül 2004 Perşembe 21:41
To: nagios-users at lists.sourceforge.net
Subject: Re: [Nagios-users] Problem with nagios logs


YAVUZ TEMIZKAN wrote:
> Hi folks,
> 
> Currently i have an intention to parse nagios log files according to 
> hosts and/or time. But my problem is that nagios logs the time 
> according to unix time i mean like this: [1095351602] Auto-save of 
> retention data completed successfully.
> 

Are you going to parse them by hand or can you have a script/program do 
it for you? If it's the script version, then just let it translate it as 
it goes along.

> İ have to change these logs to normal time ie
> 16-09-2004 19:28:59 EEST 2004
> 

What is considered 'normal time' differs greatly from country to 
country. The only thing everybody agrees to being 'normal' time is 
computer-parsed log-files, which log in unix timestamps.

> However i have nearly 6 months logs and this will be too much time 
>consuming even if done with a script. (i have a script to translate 
>this time written in perl)
> 

Computers don't complain about overtime. That's the main thing that 
makes them good.

> What i want to find out is  how can we change the logging format in 
> nagios ( cant find anything useful in nagios.log)
> 

For the logs you can't, and even if you did it wouldn't convert the logs 
you already have.

Try something like this to convert the data in all your logs to the 
format you specified. You might want to make backups before you try it 
though. It's untested.
for logfile in *; do
	cat logfile | while read line do;
		unixtime=`echo $line | sed 's#^\[\([^\]]*\)\].*#\1#'`
		humantime=`echo $unixtime | date --date="1970-01-01 UTC $unixtime 
seconds" "+%d-%m-%Y %H:%M:%S %Z %Y"
		echo $line | sed "s#$unixtime#$humantime#" >> parsed.$logfile
	done
done

You should by no means have any trouble concocting a faster script in a 
language of your choice. C is fastest of the manageable ones. I 
personally like PHP (yes, even for command-line scripts) for its fast 
logical syntax and non-silly hash/array handling.

> Thanks in advance
> 

You're welcome. It's always nice to put some shell-scripts out here in 
perl-land. ;)

> Yavuz Temizkan
> 

-- 
Andreas Ericsson                   andreas.ericsson at op5.se
OP5 AB                             www.op5.se
Lead Developer


-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php _______________________________________________
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


-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
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