日志格式:
2009-05-07 12:20:26,518 INFO [netty-evt-0] (LoggerConstant.java:227) - --- This package is report ---
2009-05-07 12:20:26,518 INFO [netty-evt-0] (LoggerConstant.java:228) - msgid2=0507131009250246858
2009-05-07 12:20:26,518 INFO [netty-evt-0] (LoggerConstant.java:229) - DestTermId=13513354175
2009-05-07 12:20:26,519 INFO [netty-evt-0] (LoggerConstant.java:230) - stat=DELIVRD
2009-05-07 12:20:26,519 INFO [netty-evt-0] (LoggerConstant.java:231) - --- end of report ---
2009-05-07 12:20:32,297 INFO [netty-evt-0] (LoggerConstant.java:227) - --- This package is report ---
2009-05-07 12:20:32,297 INFO [netty-evt-0] (LoggerConstant.java:228) - msgid2=0507131005250243379
2009-05-07 12:20:32,297 INFO [netty-evt-0] (LoggerConstant.java:229) - DestTermId=13798623689
2009-05-07 12:20:32,298 INFO [netty-evt-0] (LoggerConstant.java:230) - stat=DELIVRD
2009-05-07 12:20:32,298 INFO [netty-evt-0] (LoggerConstant.java:231) - --- end of report ---
处理This package is report 段数据,便于将报告入库;
脚本:
1、此方法较好,不易出错。
[root@localhost tmp]# awk 'BEGIN{FS="=";ORS=""}{if ($0~/java:228/) {print $2"\t"}; if ($0~/java:229/){print $2"\t"} ;if($0~/java:230/ ){print $2"\n"} }' all_cm_8866_mo.log.2009-05-07
2、此方法有可能出现数据不完整。
[root@localhost tmp]# awk 'BEGIN{FS="\=";ORS="";c=3}{if ($0~/msgid2=/ ) { print $2"\t" ;c-- } else if (c>0 && c<3) {print $2"\t";c--; if (c<=0){ c=3;print "\n"}}}' all_cm_8866_mo.log.2009-05-07
处理后的数据格式:
0507131009250246858 13513052075 DELIVRD
0507131005250246379 13798024089 DELIVRD