Add module-loading capabilities to ltt-armall
[ltt-control.git] / lttctl / ltt-armall.sh
CommitLineData
045880fb 1# Copyright (C) 2009 Benjamin Poirier
36cf2b17 2# Copyright (C) 2010 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
045880fb
BP
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2 of the License, or
7# (at your option) any later version.
8
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13
14# You should have received a copy of the GNU General Public License along
15# with this program; if not, write to the Free Software Foundation, Inc.,
16# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
36cf2b17 18DEBUGFSROOT=$(awk '{if ($3 == "debugfs") print $2}' /proc/mounts | head -n 1)
80bb2806 19MARKERSROOT=${DEBUGFSROOT}/ltt/markers
efd72b5d 20DEFAULTMODULES="ltt-trace-control ltt-marker-control ltt-tracer ltt-relay ltt-kprobes ltt-userspace-event ltt-statedump ipc-trace kernel-trace mm-trace net-trace fs-trace jbd2-trace syscall-trace trap-trace block-trace rcu-trace"
80bb2806 21
045880fb
BP
22usage () {
23 echo "Usage: $0 [OPTION]..." > /dev/stderr
24 echo "Connect lttng markers" > /dev/stderr
25 echo "" > /dev/stderr
26 echo "Options:" > /dev/stderr
27 printf "\t-l Also activate locking markers (high traffic)\n" > /dev/stderr
28 printf "\t-n Also activate detailed network markers (large size)\n" > /dev/stderr
a4dc603f 29 printf "\t-i Also activate input subsystem events (security implication: records keyboard inputs)\n" > /dev/stderr
045880fb
BP
30 echo "" > /dev/stderr
31 printf "\t-q Quiet mode, suppress output\n" > /dev/stderr
32 printf "\t-h Print this help\n" > /dev/stderr
33 echo "" > /dev/stderr
34}
35
efd72b5d
AM
36if [ "$(id -u)" != "0" ]; then
37 echo "Error: This script needs to be run as root." > /dev/stderr
38 exit 1;
39fi
40
fde9c319 41if [ ! "${DEBUGFSROOT}" ]; then
045880fb
BP
42 echo "Error: debugfs not mounted" > /dev/stderr
43 exit 1;
44fi
45
fde9c319 46if [ ! -d "${MARKERSROOT}" ]; then
efd72b5d
AM
47 #Try loading the kernel modules first
48 for i in ${DEFAULTMODULES}; do
49 modprobe $i
50 done
51 if [ ! -d "${MARKERSROOT}" ]; then
52 echo "Error: LTT trace controller not found (did you compile and load LTTng?)" > /dev/stderr
53 exit 1;
54 fi
045880fb
BP
55fi
56
57while getopts "lnqh" options; do
fde9c319 58 case ${options} in
045880fb
BP
59 l) LOCKING="0";;
60 n) NETWORK="0";;
61 q) QUIET="0";;
a4dc603f 62 i) INPUT="0";;
045880fb
BP
63 h) usage;
64 exit 0;;
65 \?) usage;
66 exit 1;;
80bb2806 67 esac
68done
fde9c319 69shift $((${OPTIND} - 1))
045880fb
BP
70
71
fde9c319 72if [ ! ${LOCKING} ]; then
045880fb 73 TESTS="${TESTS} -name lockdep -prune -o -name locking -prune -o"
efd72b5d
AM
74else
75 modprobe lockdep-trace
045880fb
BP
76fi
77
fde9c319 78if [ ! ${NETWORK} ]; then
045880fb 79 TESTS="${TESTS} -path '*/net/*_extended' -prune -o"
efd72b5d
AM
80else
81 modprobe net-extended-trace
045880fb
BP
82fi
83
a4dc603f
MD
84if [ ! ${INPUT} ]; then
85 TESTS="${TESTS} -name input -prune -o"
86fi
87
6e8902bf 88(eval "find '${MARKERSROOT}' ${TESTS} -name metadata -prune -o -name enable -print") | while read -r marker; do
fde9c319 89 if [ ! ${QUIET} ]; then
045880fb
BP
90 echo "Connecting ${marker%/enable}"
91 fi
fde9c319 92 echo 1 > ${marker}
d7a3410b 93done
This page took 0.026211 seconds and 4 git commands to generate.