Mengubah squid log file timestamp


Squid menampilkan tanggal di log file nya dalam format unix timestamp
yang kita tidak mengerti. Untuk membacanya dengan jelas gunakan kode berikut:

#!/usr/bin/perl -ps/^\d+\.\d+/localtime $&/e
Buat sebuah file - convert_unixtimestamp.pl,
isi dengan kode tadi, simpan dan pastikan di set menjadi executable(bila di linux) Contoh sebelum diconvert:
$ tail -f /c/squid/var/logs/access.log

1442487610.388      4 172.17.0.91 TCP_DENIED/407 2057 CONNECT apis.google.com:443 - NONE/- text/html
1442487611.874      1 172.17.0.91 TCP_DENIED/407 1737 CONNECT accounts.google.com:443 - NONE/- text/html
1442487612.208      4 172.17.0.91 TCP_DENIED/407 2069 CONNECT accounts.google.com:443 - NONE/- text/html

Sesudah:
$ tail -f /c/squid/var/logs/access.log | convert_unix_timestamp

Thu Sep 17 18:00:10 2015      4 172.17.0.91 TCP_DENIED/407 2057 CONNECT apis.google.com:443 - NONE/- text/html
Thu Sep 17 18:00:11 2015      1 172.17.0.91 TCP_DENIED/407 1737 CONNECT accounts.google.com:443 - NONE/- text/html
Thu Sep 17 18:00:12 2015      4 172.17.0.91 TCP_DENIED/407 2069 CONNECT accounts.google.com:443 - NONE/- text/html

No comments :

Post a Comment