~dave-martin-arm/ubuntu/maverick/bootchart/log-meminfo-too

« back to all changes in this revision

Viewing changes to debian/bootchart.upstart

  • Committer: Bazaar Package Importer
  • Author(s): Scott James Remnant
  • Date: 2009-09-22 11:53:32 UTC
  • Revision ID: james.westby@ubuntu.com-20090922115332-n24q6vner0ra2713
Tags: 0.90.2-1
* Convert init scripts to Upstart jobs
* Write pid of collector to /dev/.initramfs so Upstart can pick it up and
  "fake" the job
* debian/control:
  - Increase build-dependency on debhelper for upstart-aware dh_installinit
  - Remove dependency on initscripts

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 startup
 
10
stop on stopped rc
 
11
 
 
12
script
 
13
    grep -q "profile" /proc/cmdline || exit 1
 
14
    grep -q "bootchart=disable" /proc/cmdline || exit 1
 
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 ]
 
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 -f $format -o "/var/log/bootchart" "$TARBALL"
 
66
    fi
 
67
 
 
68
    # Clean up
 
69
    rm -rf $LOGS
 
70
    if [ -d /dev/.bootchart ]
 
71
    then
 
72
        umount /dev/.bootchart/proc
 
73
        rm -rf /dev/.bootchart
 
74
    fi
 
75
end script