-
Notifications
You must be signed in to change notification settings - Fork 2
/
analyze-all.sh
executable file
·66 lines (59 loc) · 1.95 KB
/
analyze-all.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
#!/bin/bash
# Get the first day of the last month
first_day_last_month=$(date -d "$(date -d "last month" +%Y-%m-01)" +%F)
# Get the last day of the last month
last_day_last_month=$(date -d "$(date -d "last month" +%Y-%m-01) +1 month -1 day" +%F)
creation_date_seconds=$(date -d "$first_day_last_month" '+%s')
mod_date_seconds=$(date -d "$last_day_last_month" '+%s')
creation_date=$first_day_last_month
mod_date=$last_day_last_month
diff_days=$(( ($mod_date_seconds - $creation_date_seconds)/(60*60*24) ))
output="./log_history/log_history.$last_day_last_month.txt"
touch $output
truncate -s 0 $output
process() {
local label=$1
local files_sent=$2
echo -n "$label," >> $output
echo -n "$creation_date," >> $output
echo -n "$mod_date," >> $output
echo -n "$diff_days," >> $output
echo -n "$files_sent," >> $output
if [ $files_sent -ne 0 ]; then
result=$(echo "scale=1; $files_sent / ($diff_days/30)" | bc)
echo -n $result >> $output
else
echo -n "0" >> $output
fi
echo "" >> $output
}
# Header
echo "program,start_date,end_date,days,files,average" >> $output
# Futres queries
files=($(ls -1 /home/exouser/.pm2/logs/futresapi.v1.query-out.log))
for i in "${files[@]}"
do
files_sent=$(cat "$i" | grep "_search" | grep futres | wc -l)
process "Futres queries" "$files_sent"
done
# Futres downloads
files=($(ls -1 /home/exouser/.pm2/logs/futresapi.v3.download-out.log))
for i in "${files[@]}"
do
files_sent=$(cat $i | grep sent: | sort | uniq | wc -l)
process "Futres downloads" "$files_sent"
done
# PPO queries
files=($(ls -1 /home/exouser/.pm2/logs/api.v1.query-out.log))
for i in "${files[@]}"
do
files_sent=$(cat $i | grep "_search" | wc -l)
process "ppo queries" "$files_sent"
done
# PPO downloads
files=($(ls -1 /home/exouser/.pm2/logs/api.v3.download-out.log))
for i in "${files[@]}"
do
files_sent=$(cat $i | grep sent: | sort | uniq | wc -l)
process "ppo downloads" "$files_sent"
done