~launchpad-pqm/launchpad/devel

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
#!/bin/sh

#TZ=UTC # trace logs are still BST - blech

category_report() {
    max_log_age=$1
    type=$2
    from=$3
    until=$4
    category=$5
    log_root=$6

    local logs
    logs=`find ${log_root} \
        -maxdepth 2 -type f -mtime -${max_log_age} -name launchpad-trace\* \
        | sort | xargs -x`

    local root
    root=${HOME}/public_html/ppr/${category}

    local dir
    dir=${root}/${type}_${from}_${until}

    mkdir -p ${dir}

    echo Generating report from $from until $until into $dir `date`

    ./page-performance-report.py -v --from=$from --until=$until \
        --top-urls=200 --directory=${dir} $logs

    ln -sf ${dir}/categories.html ${root}/latest-${type}-categories.html
    ln -sf ${dir}/pageids.html    ${root}/latest-${type}-pageids.html
    ln -sf ${dir}/combined.html   ${root}/latest-${type}-combined.html
    ln -sf ${dir}/top200.html   ${root}/latest-${type}-top200.html
    ln -sf ${dir}/timeout-candidates.html   \
        ${root}/latest-${type}-timeout-candidates.html

    return 0
    }

report() {
    category_report $* edge /srv/launchpad.net-logs/edge
    category_report $* lpnet /srv/launchpad.net-logs/production
    return 0
}

fmt='+%Y-%m-%d'

now=`date $fmt`

report  3 daily `date -d yesterday $fmt` $now

if [ `date +%a` = 'Sat' ]; then
    report 9 weekly `date -d 'last week' $fmt` $now
fi

# We don't seem to have a months worth of tracelogs, but we will
# generate what we can.
if [ `date +%d` = '01' ]; then
    report 32 monthly `date -d 'last month' $fmt` $now
fi