~launchpad-pqm/launchpad/devel

10209.2.41 by Stuart Bishop
Regular schedule of page-performance-report.py
1
#!/bin/sh
10209.2.45 by Stuart Bishop
Daily report run updates
2
10209.2.41 by Stuart Bishop
Regular schedule of page-performance-report.py
3
#TZ=UTC # trace logs are still BST - blech
4
10209.2.45 by Stuart Bishop
Daily report run updates
5
category_report() {
6
    max_log_age=$1
7
    type=$2
8
    from=$3
9
    until=$4
10
    category=$5
11
    log_root=$6
10209.2.41 by Stuart Bishop
Regular schedule of page-performance-report.py
12
10209.2.45 by Stuart Bishop
Daily report run updates
13
    local logs
14
    logs=`find ${log_root} \
15
        -maxdepth 2 -type f -mtime -${max_log_age} -name launchpad-trace\* \
16
        | sort | xargs -x`
10209.2.41 by Stuart Bishop
Regular schedule of page-performance-report.py
17
18
    local root
10209.2.45 by Stuart Bishop
Daily report run updates
19
    root=${HOME}/public_html/ppr/${category}
10209.2.41 by Stuart Bishop
Regular schedule of page-performance-report.py
20
21
    local dir
10209.2.45 by Stuart Bishop
Daily report run updates
22
    dir=${root}/${type}_${from}_${until}
23
24
    mkdir -p ${dir}
25
26
    echo Generating report from $from until $until into $dir `date`
27
28
    ./page-performance-report.py -v --from=$from --until=$until \
10209.2.51 by Stuart Bishop
Generate top200 reports daily
29
        --top-urls=200 --directory=${dir} $logs
10209.2.45 by Stuart Bishop
Daily report run updates
30
31
    ln -sf ${dir}/categories.html ${root}/latest-${type}-categories.html
32
    ln -sf ${dir}/pageids.html    ${root}/latest-${type}-pageids.html
33
    ln -sf ${dir}/combined.html   ${root}/latest-${type}-combined.html
10209.2.52 by Stuart Bishop
Correct filename
34
    ln -sf ${dir}/top200.html   ${root}/latest-${type}-top200.html
10209.3.5 by Stuart Bishop
Merge lp:~lifeless/launchpad/foundations, resolving conflicts
35
    ln -sf ${dir}/timeout-candidates.html   \
36
        ${root}/latest-${type}-timeout-candidates.html
10209.2.41 by Stuart Bishop
Regular schedule of page-performance-report.py
37
38
    return 0
39
    }
40
10209.2.45 by Stuart Bishop
Daily report run updates
41
report() {
42
    category_report $* edge /srv/launchpad.net-logs/edge
43
    category_report $* lpnet /srv/launchpad.net-logs/production
44
    return 0
45
}
46
10209.2.41 by Stuart Bishop
Regular schedule of page-performance-report.py
47
fmt='+%Y-%m-%d'
48
10209.2.45 by Stuart Bishop
Daily report run updates
49
now=`date $fmt`
50
51
report  3 daily `date -d yesterday $fmt` $now
52
53
if [ `date +%a` = 'Sat' ]; then
54
    report 9 weekly `date -d 'last week' $fmt` $now
55
fi
56
57
# We don't seem to have a months worth of tracelogs, but we will
58
# generate what we can.
59
if [ `date +%d` = '01' ]; then
60
    report 32 monthly `date -d 'last month' $fmt` $now
61
fi
62
10209.2.41 by Stuart Bishop
Regular schedule of page-performance-report.py
63