我正在尝试查找每个服务的错误日志计数。此日志文件非常大。但log模式如下所示:
[DEFService@]: connect failed: not authorized to connect
WARNING: Closing connection from <ipaddress>> due to timeout, exceeded timeout of 20.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
[ABCService]: connect failed: not authorized to connect
WARNING: Connection timeouts delayed around 15 seconds.
WARNING: Closing connection from <ipaddress>> due to timeout, exceeded timeout of 20.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
[XYZService@]: connect failed: not authorized to connect
WARNING: Closing connection from <<ipaddress>> due to timeout, exceeded timeout of 20.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
[DEFService@]: connect failed: not authorized to connect
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open
files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
ERROR: Accept() failed: many open files. Please check each process and system limits on the number of open files.
上面的错误消息“许多打开的文件”,已经发生了很多次为每个服务,我需要采取的计数每个服务,多少次的“许多打开的文件”错误消息已发生为该服务.例如DEFService
。
我试过:(DEFService.*)$(\r\n)(.*many open files.*)
.我得到的计数为“DEFService”为1,因为只有“许多打开的文件”错误消息发生在服务名称后的下一行,但实际计数为2,因为还有一个,但中间有一个警告行,由于Regex无法识别,需要采取该计数。我没有得到Regex。请帮帮忙
1条答案
按热度按时间ljo96ir51#
我需要计算每个服务的数量,该服务出现“许多打开的文件”错误消息的次数。
没有必要使用正则表达式,因为你可以这样做。
这假定日志文件是一致写入的。例如,如果行以
[
开始,则服务将封装在结束的]
中。印刷品
请注意,上述内容可以合并到当前正在阅读错误消息的任何代码中。