当前位置: 首页> 财经> 股票 > 免费b站在线观看人数统计_网络营销推广方式有几种_网络营销推广优化_常用的关键词挖掘工具

免费b站在线观看人数统计_网络营销推广方式有几种_网络营销推广优化_常用的关键词挖掘工具

时间:2025/7/12 19:27:51来源:https://blog.csdn.net/weixin_42933305/article/details/146917492 浏览次数:0次
免费b站在线观看人数统计_网络营销推广方式有几种_网络营销推广优化_常用的关键词挖掘工具

最新版本更新
https://code.jiangjiesheng.cn/article/364?from=csdn

推荐 《高并发 & 微服务 & 性能调优实战案例100讲 源码下载》

1. 查询实时报错日志

物理路径(带*的放在靠后,或者不用*

cd /home/logs/java-gz-log-dir && tail -2000f java-gz-log-dir-error.log | grep -ivE '(登录失败|不包含|不合法|不匹配|存在|未在系统中|入参无效|没有【生效中】|找不到|重复|JwtToken|已过期|catalina|token 为空|被踢出|Broken pipe|ErrorPage|Servlet\.service\(\) for servlet \[dispatcherServlet\]|无*数据)' | grep -iE -C 30 '(timeout|PSQLException: ERROR|ERROR|失败|EOFException|SocketException|IOException|sql执行出现异常|不判定为缺失)' 

docker版本(带*的放在靠后,或者不用*

docker logs --tail 20000 --follow java-gz-log-dir | grep -ivE '(登录失败|不包含|不合法|不匹配|存在|未在系统中|入参无效|没有【生效中】|找不到|重复|JwtToken|已过期|catalina|token 为空|被踢出|Broken pipe|ErrorPage|Servlet\.service\(\) for servlet \[dispatcherServlet\]|无*数据)' | grep -iE -C 20 '(timeout|PSQLException: ERROR|ERROR|失败|EOFException|SocketException|IOException|sql执行出现异常|监测点|不判定为缺失)'

2. 查询前1天业务报错gz压缩日志

简化版:

cd /home/logs/java-gz-log-dir && [ -d "/home/logs/java-gz-log-dir/lastDayErrorLog" ] || mkdir /home/logs/java-gz-log-dir/lastDayErrorLog && rm -f /home/logs/java-gz-log-dir/lastDayErrorLog/* && echo "开始复制昨天的错误日志文件" && cp $(ls -t java-gz-log-dir-error.log.*.gz | head -1) lastDayErrorLog && cd ./lastDayErrorLog && echo "开始解压错误日志文件" && gunzip *.gz && echo "开始查找错误日志文件内容" && cat * | grep -ivE '(登录失败|不包含|不合法|不匹配|存在|未在系统中|入参无效|没有【生效中】|找不到|重复|JwtToken|已过期|catalina|token 为空|被踢出|Broken pipe|ErrorPage|Servlet\.service\(\) for servlet \[dispatcherServlet\]|无*数据)' | grep -iE -C 30 '(timeout|PSQLException: ERROR|ERROR|失败|EOFException|SocketException|IOException|sql执行出现异常|监测点|不判定为缺失)' || true && \
echo "查找完成"

完整版:

clear && \
log_dir="/home/logs/java-gz-log-dir" && \
log_file="java-gz-log-dir-error.log.*.gz" && \
latest_log=$(ls -t $log_dir/$log_file | head -1) && \
if [ -z "$latest_log" ]; thenecho "未找到需要复制的日志文件"exit 0
fi && \
cd "$log_dir" && \
[ -d "$log_dir/lastDayErrorLog" ] || mkdir "$log_dir/lastDayErrorLog" && \
rm -f "$log_dir"/lastDayErrorLog/* && \
echo "开始复制昨天的错误日志文件: $latest_log" && \
echo "开始复制昨天的错误日志文件: $latest_log" >> "$log_dir/lastDayErrorLog/error_analysis_result.log" && \
cp "$latest_log" "$log_dir/lastDayErrorLog" && \
cd "$log_dir/lastDayErrorLog" && \
echo "开始解压错误日志文件"  && \
echo "开始解压错误日志文件" >> "$log_dir/lastDayErrorLog/error_analysis_result.log" && \
gunzip -c *.gz > unzip_file.log || { echo "解压失败"; exit 1; } && \
echo "确认当前文件夹下文件:" && \
echo "确认当前文件夹下文件:" >> "$log_dir/lastDayErrorLog/error_analysis_result.log" && \
ls -lsh >> "$log_dir/lastDayErrorLog/error_analysis_result.log" && \
echo "开始查找错误日志文件内容;$(ls -t ./*)"  && \
echo "开始查找错误日志文件内容;$(ls -t ./*)" >> "$log_dir/lastDayErrorLog/error_analysis_result.log" && \
total_lines=$(cat * | wc -l) && \
# 控制打印10次进度日志
print_interval=$((total_lines / 10)) && \
output_file="$log_dir/lastDayErrorLog/error_analysis_result.log" && \
>> "$output_file" && \ # 清空或创建输出文件
awk -v total_lines="$total_lines" -v print_interval="$print_interval" 'BEGIN {context = 50; # 设置上下文为50行line_count = 0; # 记录当前处理的行数RED = "\033[31m"; # 红色BLUE = "\033[34m"; # 蓝色RESET = "\033[0m"; # 重置颜色}{# 跳过空白行if (NF == 0) {next;}# 打印提示信息if (line_count % print_interval == 0) {print "继续查找中... 当前行号:", NR, "/ 总行数:", total_lines;}line_count++;# 忽略不相关的行if ($0 ~ /登录失败|不包含|不合法|不匹配|存在|未在系统中|入参无效|没有【生效中】|找不到|重复|JwtToken|已过期|catalina|token 为空|被踢出|Broken pipe|ErrorPage|Servlet\.service$$ for servlet $dispatcherServlet$|无*数据/) {next;}# 缓存所有行,不删除任何内容lines[NR] = $0;# 匹配目标关键字并记录命中行号if ($0 ~ /timeout|PSQLException: ERROR|ERROR|失败|EOFException|SocketException|IOException|sql执行出现异常|不判定为缺失/) {hit_lines[NR] = 1; # 记录命中行号}}END {# 将命中行号存储到数组中以便排序n = 0;for (hit_nr in hit_lines) {sorted_hits[++n] = hit_nr+0; # 强制转为数值}# 手动实现冒泡排序(适用于所有 awk 实现)for (i = 1; i <= n; i++) {for (j = i + 1; j <= n; j++) {if (sorted_hits[i] > sorted_hits[j]) {temp = sorted_hits[i];sorted_hits[i] = sorted_hits[j];sorted_hits[j] = temp;}}}# 遍历排序后的命中行号,打印上下文for (i = 1; i <= n; i++) {hit_nr = sorted_hits[i];printf("\n\n-----------------------错误序号: %d------------------------------\n", i);printf("\n\n-----------------------错误序号: %d------------------------------\n", i) >> "'"$output_file"'";# 打印命中行(红色高亮)printf("%s命中关键字: 命中行号 %d%s\n", RED, hit_nr, RESET);printf("%s%s%s\n", RED, lines[hit_nr], RESET); # 打印命中行,使用红色高亮# 写入文件:命中行printf("命中关键字: 命中行号 %d\n", hit_nr) >> "'"$output_file"'";printf("%s\n", lines[hit_nr]) >> "'"$output_file"'";# 打印上下文范围提示print (hit_nr > context ? "..." : ""), (hit_nr-context > 0 ? hit_nr-context : 1), "<--命中前后上下文-->", hit_nr+context, "...";# 写入文件:上下文范围提示printf((hit_nr > context ? "...\n" : ""), (hit_nr-context > 0 ? hit_nr-context : 1), "<--命中前后上下文-->", hit_nr+context, "...") >> "'"$output_file"'";# 打印上下文行for (j = hit_nr-context; j <= hit_nr+context; j++) {if (j in lines && length(lines[j]) > 0 && j >= 1) { # 确保 j 在有效范围内if (j == hit_nr) {# 当前行是命中行,打印红色printf("%s[命中行号:%d] %s%s\n", RED, j, lines[j], RESET);# 写入文件:命中行上下文printf("[命中行号:%d] %s\n", j, lines[j]) >> "'"$output_file"'";} else if (lines[j] ~ /cn.jiangjiesheng|otherkeyword/) {# 当前行包含指定关键词,打印蓝色printf("%s[行号:%d] %s%s\n", BLUE, j, lines[j], RESET);# 写入文件:关键词上下文printf("[行号:%d] %s\n", j, lines[j]) >> "'"$output_file"'";} else {# 其他行是上下文行,打印默认颜色printf("[行号:%d] %s\n", j, lines[j]);# 写入文件:其他上下文printf("[行号:%d] %s\n", j, lines[j]) >> "'"$output_file"'";}}}}}
' unzip_file.log || true && \
echo " " && \
echo " " >> "$log_dir/lastDayErrorLog/error_analysis_result.log" && \
echo "查找完成,准备删除解压文件" && \
echo "查找完成,准备删除解压文件" >> "$log_dir/lastDayErrorLog/error_analysis_result.log" && \
find "$log_dir/lastDayErrorLog" -maxdepth 1 -type f ! -name '*result*' -exec rm -f {} \; && \
echo "删除解压文件完成,执行ls -lsh结果" && \
echo "删除解压文件完成,执行ls -lsh结果" >> "$log_dir/lastDayErrorLog/error_analysis_result.log" && \
ls -lsh && \
ls -lsh >> "$log_dir/lastDayErrorLog/error_analysis_result.log" && \
echo "是否下载分析结果文件 error_analysis_result.log? 输入 y 确认,其他键跳过【适用XShell,后期可以改成小文件不压缩】: " && \
read user_input && \
if [ "$user_input" = "y" ]; thentar -zcvf error_analysis_result.log.tar.gz error_analysis_result.logsz error_analysis_result.log.tar.gz || echo "文件下载失败,请检查环境是否支持 sz 命令。"
elseecho "跳过文件下载。"
fi

效果如图:
效果展示

最新版本更新
https://code.jiangjiesheng.cn/article/364?from=csdn

推荐 《高并发 & 微服务 & 性能调优实战案例100讲 源码下载》

关键字:免费b站在线观看人数统计_网络营销推广方式有几种_网络营销推广优化_常用的关键词挖掘工具

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: