使用AWK生成HTML表格报告

时间:2014-06-06 09:27:35

标签: linux bash awk gawk

我有我的服务器日志,按以下格式,是否可以以表格格式转换?

服务器日志: -

####<Jun 1, 2014 9:28:49 AM EDT> <Error> <JMX> <Host1> <pnbprod01> <[ACTIVE] ExecuteThread: '21' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <> <1401629329071> <BEA-149500> <An exception occurred while registering the MBean null.
java.lang.IllegalArgumentException: Registered more than one instance with the same objectName : com.bea:ServerRuntime=server01,Name="http://server.com/:QueryInterfaceServicePort:http://192.168.56.1/epics/services/queryInterface:",ApplicationRuntime=PNB,Type=WseeClientRuntime,EJBComponentRuntime=lib/CodingServicesEJB.jar new:weblogic.wsee.monitoring.WseeClientRuntimeMBeanImpl@4b7fbc82 - /pnbprod01[ServerRuntime]/PNB[J2EEApplicationRuntimeMBeanImpl]/lib/CodingServicesEJB.jar[EJBComponentRuntimeMBeanImpl]/

这样的东西?

表格形式: -

Column1                         Column2   Column3 Column4 
Jun 1, 2014 9:28:49 AM EDT      Error      JMX    An exception occurred while registering 

1 个答案:

答案 0 :(得分:0)

使用awk

将字段分隔符设置为< 写出标题

检查行上的时间戳

根据位置和字段分隔符

解析所需的正确信息
awk 'BEGIN { FS="<"; print "\nColumn 1\t\t\tColumn 2\tColumn 3\tColumn 4" } /[0-9]:[0-9][0-9]/ { gsub(">", ""); print $2"\t"$3"\t\t"$4"\t\t"$14 }'