-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootchart-gather.sh
executable file
·56 lines (48 loc) · 1.75 KB
/
bootchart-gather.sh
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
#!/bin/sh -e
# bootchart-gather
#
# Copyright © 2009 Canonical Ltd.
# Author: Scott James Remnant <[email protected]>.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Gather output of the bootchart collector into a tarball that bootchart
# can process itself.
TARBALL="$1"
if [ -z "$TARBALL" ]; then
echo "Usage: $0 TARBALL [DIR]" 1>&2
exit 1
fi
if [ "${TARBALL#/}" = "$TARBALL" ]; then
TARBALL="$(pwd)/$TARBALL"
fi
DIR="$2"
[ -n "$DIR" ] || DIR="."
if [ -x "/usr/bin/dpkg-query" ]; then
version="$(dpkg-query -f'${Version}' -W bootchart)"
else
version="$(rpm -q bootchart --queryformat '%{VERSION}')"
fi
cd $DIR
# Output the header file with information about the system
{
echo "version = $version"
echo "title = Boot chart for $(hostname) ($(date))"
echo "system.uname = $(uname -srvm)"
echo "system.release = $(lsb_release -sd)"
echo "system.cpu = $(grep '^model name' /proc/cpuinfo)"\
"($(grep -c '^model name' /proc/cpuinfo))"
echo "system.kernel.options = $(sed q /proc/cmdline)"
} > header
# Create a tarball of the logs and header which can be parsed into the chart
tar -cz --ignore-failed-read -f $TARBALL header proc_stat.log proc_diskstats.log proc_ps.log taskstats.log
exit 0