~upstart-devel/upstart/upstart-jobs

« back to all changes in this revision

Viewing changes to vivid/etc/init/bootchart.conf

  • Committer: Dimitri John Ledkov
  • Date: 2014-11-19 12:58:41 UTC
  • Revision ID: dimitri.j.ledkov@intel.com-20141119125841-98dr37roy8dvcv3b
auto update

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# bootchart - boot sequence auditing
 
2
#
 
3
# bootchart allows you to audit the boot sequence of your computer and
 
4
# generate a pretty chart of the processes run, including how long they
 
5
# took and how much CPU and I/O they used.
 
6
 
 
7
description     "boot sequence auditing"
 
8
 
 
9
start on virtual-filesystems
 
10
stop on stopped rc
 
11
 
 
12
script
 
13
    grep -q "profile" /proc/cmdline && { stop; exit 0; }
 
14
    grep -q "bootchart=disable" /proc/cmdline && { stop; exit 0; }
 
15
 
 
16
    if grep -q "bootchart=[0-9]*hz" /proc/cmdline
 
17
    then
 
18
        HZ=$(sed -e 's/.*bootchart=//;s/hz.*//' /proc/cmdline)
 
19
    else
 
20
        HZ=25
 
21
    fi
 
22
 
 
23
    mkdir -p /var/run/bootchart
 
24
    exec /lib/bootchart/collector $HZ /var/run/bootchart 2>/dev/null
 
25
end script
 
26
 
 
27
pre-stop script
 
28
    # Sleep for an extra 45s to allow enough time to chart the desktop
 
29
    # login
 
30
    [ "$UPSTART_STOP_EVENTS" = "stopped" ] && sleep 45
 
31
end script
 
32
 
 
33
post-stop script
 
34
    if [ -d /dev/.bootchart/log ]
 
35
    then
 
36
        LOGS=/dev/.bootchart/log
 
37
    else
 
38
        LOGS=/var/run/bootchart
 
39
    fi
 
40
 
 
41
    # Figure out name for the chart
 
42
    base="$(hostname -s)-$(lsb_release -sc)-$(date +%Y%m%d)"
 
43
    count=1
 
44
    while [ -e "/var/log/bootchart/$base-$count.tgz" -o -e "/var/log/bootchart/$base-$count.png" -o -e "/var/log/bootchart/$base-$count.svg" ]
 
45
    do
 
46
        count=$(( $count + 1 ))
 
47
    done
 
48
 
 
49
    BASE="/var/log/bootchart/$base-$count"
 
50
    TARBALL="$BASE.tgz"
 
51
 
 
52
    # Gather the output into the tarball
 
53
    /lib/bootchart/gather "$TARBALL" "$LOGS"
 
54
 
 
55
    # Generate SVG and optionally PNG if pybootchartgui is installed
 
56
    if [ -x /usr/bin/bootchart ]
 
57
    then
 
58
        if grep -q "bootchart=svg" /proc/cmdline
 
59
        then
 
60
            format=svg
 
61
        else
 
62
            format=png
 
63
        fi
 
64
 
 
65
        bootchart --format=$format \
 
66
                --crop-after=compiz,metacity,mutter,kwin,xfwm4,unity8 \
 
67
                --annotate=ureadahead,mountall,hostname,hwclock \
 
68
                --annotate=Xorg \
 
69
                --annotate=gdm-session-worker \
 
70
                --output="/var/log/bootchart" "$TARBALL"
 
71
    fi
 
72
 
 
73
    # Clean up
 
74
    rm -rf $LOGS
 
75
    if [ -d /dev/.bootchart ]
 
76
    then
 
77
        umount /dev/.bootchart/proc
 
78
        rm -rf /dev/.bootchart
 
79
    fi
 
80
end script