From 7707cc360eb625d573fbae755f276e51cf558df7 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Tue, 27 Apr 2021 00:08:06 -0700 Subject: [PATCH] Bash script to separate supplicant logs into per-station log files Signed-off-by: Jed Reynolds --- wifi_log_separator.bash | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 wifi_log_separator.bash diff --git a/wifi_log_separator.bash b/wifi_log_separator.bash new file mode 100755 index 00000000..1eda11a4 --- /dev/null +++ b/wifi_log_separator.bash @@ -0,0 +1,24 @@ +#!/bin/bash + +log_dir=/home/lanforge/wifi +result_dir=/home/lanforge/report-data/wifi-sta-logs + +[ ! -d $result_dir ] && mkdir -p $result_dir + +now=`date +%Y%m%d-%H%M%S` +cd $log_dir +ls wpa_supplicant_log_wiphy[0-24].txt > /tmp/log.list 2>/dev/null +[ $? -ne 0 ] && echo "No logs found" && exit 1 + +for logfile in `cat /tmp/log.list`; do + egrep -o ' sta[0-9]+: ' "$logfile" | sort | uniq > /tmp/sta_names.txt + [ ! -s /tmp/sta_names.txt ] && continue + for sta in `cat /tmp/sta_names.txt` ; do + [[ x$sta = x ]] && continue + echo "$sta" > /tmp/pattern + safe_name="${sta/:/}" + fgrep -f /tmp/pattern ${logfile} > "${result_dir}/${safe_name}_${now}.txt" + done + xz -7 < ${logfile} > ${logfile}.${now}.xz + echo "" > ${logfile} +done