LoginSignup
3
3

More than 5 years have passed since last update.

nagios.logのtai64nlocale変換

Last updated at Posted at 2014-04-03

nagios.logは以下のように、ログの時刻formatがtai64nlocaleになってる。
通常はtail64nlocaleコマンドを通せば整形されるが、[]で囲まれてるので正常に変換されない。

nagios.log
[1396426834] Caught SIGHUP, restarting...
[1396426834] Nagios 3.2.0 starting... (PID=8813)
[1396426834] Local time is Wed Apr 02 17:20:34 JST 2014
[1396426834] LOG VERSION: 2.0

なのでperlワンライナーを以下の通りにやって日付を表示させると良い

nagios.log
perl -pe 's/(\d+)/localtime($1)/e' nagios.log

[Wed Apr  2 17:20:34 2014] Caught SIGHUP, restarting...
[Wed Apr  2 17:20:34 2014] Nagios 3.2.0 starting... (PID=8813)
[Wed Apr  2 17:20:34 2014] Local time is Wed Apr 02 17:20:34 JST 2014
[Wed Apr  2 17:20:34 2014] LOG VERSION: 2.0
3
3
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3