A simple Perl script to convert Nagios/Squid logs time to a human readable format

########################################################

Installation steps

#######################

vim nagios-time-converter.pl

Paste the following codes and save the file

#!/usr/bin/perl

# ------------------------------------------------------------
# nagios-time-converter.pl
# ------------
# by:- Eranga Perera
# a perl script to convert Nagios "epoch time" (epoch seconds)
# into a human-readable format.
# ------------------------------------------------------------

$num_args = $#ARGV + 1;
die "Usage: this-program epochtime (something like '1279236316')" if
($num_args != 1);

$epoch_time = $ARGV[0];

($sec,$min,$hour,$day,$month,$year) = localtime($epoch_time);

# correct the date and month
$year = 1900 + $year;
$month++;

printf "%02d/%02d/%02d %02d:%02d:%02d\n", $year, $month, $day, $hour, $min, $sec;

chmod 755 nagios-time-converter.pl

Usage
#######################

./nagios-time-converter.pl 1279236316

########################################################

Hi Friends,,,