FrontPage

先にこちらを見たほうが良いかも。(2004-04-04)
http://squid.robata.org/faq_6.html#l-04


「時刻 squid」でググって

perl -pe 's/\d+\.\d+/localtime $&/e'

が正解。参考 squid log 時刻変換 とか squid 設定方法

squidのログの時刻

squid のログは

882008749.530    522 127.0.0.1 TCP_MISS/200 1556 GET http://localhost/ - DIRECT/localhost text/html

のように先頭がunix時間に記録されているのをローカルタイムに変換するフィルターのperlスクリプト。

onelinerに出来そうだけど深い追いはしない。

#! /usr/bin/perl

while( <>){
  chop;
  ($time, $rest) = /([0-9.]+)[  ]+(.*)/;
  ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
                  localtime($time);
 $mon++;
$year += 1900;
  print "$year-$mon-$mday $hour:$min:$sec $rest\n";
}

先の例はこのように変換される。

1997-12-13 19:25:49 522 127.0.0.1 TCP_MISS/200 1556 GET http://localhost/ - DIRECT/localhost text/html

添付ファイル: filesquid-log-time.pl 2501件 [詳細]

トップ   差分 バックアップ リロード   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2009-11-14 (土) 19:20:12 (5276d)