-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdirewolf_rx_counts.sh
75 lines (42 loc) · 2.04 KB
/
direwolf_rx_counts.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/sh
# crude bash script to count the number of packets rx'd by direwolf
# assumes direwolf is using the daily log file option, i.e., lowercase l (-l)
# Casey J. Davis 2020.02.26
# forever loop
while :
do
clear
# location of daily log files
direwolf_log_dir="$HOME/direwolf_rx_log"
# finds two most recent log files
second_newest_file=$(ls $direwolf_log_dir | sort -m | tail -n 2 | head -n 1)
first_newest_file=$(ls $direwolf_log_dir | sort -m | tail -n 2 | tail -n 1)
printf "%-15s %-15s\n" "Data Sources:" $second_newest_file
printf "%-15s %-15s\n\n" "" $first_newest_file
# define complete paths to both log files
two_files="$direwolf_log_dir/$second_newest_file $direwolf_log_dir/$first_newest_file"
# define list of times for awk command and labels for output
dt=("now-24 hour" "now-1000 minute" "now-100 minute" "now-10 minute" "now-1 minute")
label=("24 Hrs:" "1000 Min:" "100 Min:" "10 Min:" "1 Min:")
printf "%-25s\n\n" "Rx packet counts in the last:"
# loop to run awk command for each time defined above and for both log files
for i in ${!dt[@]};
do
count=$(awk -F',' -vDate=`date -d "${dt[$i]}" +'%Y-%m-%dT%H:%M:%SZ'` '/chan/ {next} $3 > Date {print $0}' $two_files | wc -l)
printf "%12s %-6i\n\n" "${label[$i]}" $count
done
# get names of 'source' from logs, i.e., stations which were heard directly
rx_sources=$(awk -F',' -vDate=`date -d 'now-100 min' +'%Y-%m-%dT%H:%M:%SZ'` '/chan/ {next} $3 > Date {print $5}' $two_files | sort | uniq -c | sort -r)
printf "%-25s\n\n" "Rx sources in the last 100 minutes:"
printf "%s\n\n\n" "$rx_sources"
# show bar graph history of rx packet counts for all files in log directory
printf "%-25s\n\n" "Daily Total Rx Packet Count for Last Two Months:"
wc -l $direwolf_log_dir/* | grep -v total | tail -n 56 | awk '{print $1}' | spark
# attempting to add markers under bar graph
seq -s '......' 0 8
printf "\n\n"
# pause infinite loop
sleep 15s
done
# awk -F ',' '$5 == "W1UWS-1" {print $5 "\t" $11 "\t" $12}' $two_files
# awk -F ',' '/W1UWS-1/ {print $0}' $two_files