Hi all…
Can anyone help me with this one…
I want to set my nagios to write logs as YYYY-MM-DD
right now log are in format - MM-DD-YYYY…
I`m running nagios under FreeBSD 5.4 stable
Thanks !
Hi all…
Can anyone help me with this one…
I want to set my nagios to write logs as YYYY-MM-DD
right now log are in format - MM-DD-YYYY…
I`m running nagios under FreeBSD 5.4 stable
Thanks !
Probably your best chance would be to set the date_format variable in nagios.cfg to something like iso8601… although whether or not that will affect the timestamp in the logs is unclear from the documentation
[blockquote]Date Format
Format: date_format=
Example: date_format=us
This option allows you to specify what kind of date/time format Nagios should use in the web interface and date/time macros. Possible options (along with example output) include:
Option Output Format Sample Output
us MM/DD/YYYY HH:MM:SS 06/30/2002 03:15:00
euro DD/MM/YYYY HH:MM:SS 30/06/2002 03:15:00
iso8601 YYYY-MM-DD HH:MM:SS 2002-06-30 03:15:00
strict-iso8601 YYYY-MM-DDTHH:MM:SS 2002-06-30T03:15:00 [/blockquote] nagios.sourceforge.net/docs/3_0/configmain.html
By default I am with iso8601 and the log format date is MM-DD-YYYY. So maybe it’s not connected with the log name.
Anyone else has other suggestions?
Thanks
There is not parameter you can set in nagios.cfg to change the nagios.log date format. But I suggest you use following script to change epoch time to Normal Date format for auditing resource.
#!/usr/bin/perl
sub epochtime
{
my $epoch_time = shift;
($sec,$min,$hour,$day,$month,$year) = localtime($epoch_time);
$year = 1900 + $year;
$month++;
return sprintf("%02d/%02d/%02d %02d:%02d:%02d", $year, $month, $day, $hour, $min, $sec);
}
while (<>)
{
my $epoch = substr $, 1, 10;
my $remainder = substr $, 13;
my $human_date = &epochtime($epoch);
printf("%s] %s", $human_date, $remainder);
}
exit
Run the above script as
#cat nagios.log | epoch.pl