~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 \
29
        --directory=${dir} $logs
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.41 by Stuart Bishop
Regular schedule of page-performance-report.py
34
35
    return 0
36
    }
37
10209.2.45 by Stuart Bishop
Daily report run updates
38
report() {
39
    category_report $* edge /srv/launchpad.net-logs/edge
40
    category_report $* lpnet /srv/launchpad.net-logs/production
41
    return 0
42
}
43
10209.2.41 by Stuart Bishop
Regular schedule of page-performance-report.py
44
fmt='+%Y-%m-%d'
45
10209.2.45 by Stuart Bishop
Daily report run updates
46
now=`date $fmt`
47
48
report  3 daily `date -d yesterday $fmt` $now
49
50
if [ `date +%a` = 'Sat' ]; then
51
    report 9 weekly `date -d 'last week' $fmt` $now
52
fi
53
54
# We don't seem to have a months worth of tracelogs, but we will
55
# generate what we can.
56
if [ `date +%d` = '01' ]; then
57
    report 32 monthly `date -d 'last month' $fmt` $now
58
fi
59
60
# One off reports to populate history.
61
## report 40 monthly `date -d '1 june 2010' $fmt` `date -d '1 july 2010' $fmt`
62
## report 23 weekly `date -d '19 june 2010' $fmt` `date -d '26 june 2010' $fmt`
63
## report 16 weekly `date -d '26 june 2010' $fmt` `date -d '3 july 2010' $fmt`
10209.2.41 by Stuart Bishop
Regular schedule of page-performance-report.py
64