Fix up all use of /dev/stderr for portability to busybox /bin/sh
[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 22usage () {
cdfcd011
JW
23 echo "Usage: $0 [OPTION]..." 1>&2
24 echo "Connect lttng markers" 1>&2
25 echo "" 1>&2
26 echo "Options:" 1>&2
27 printf "\t-l Also activate locking markers (high traffic)\n" 1>&2
28 printf "\t-n Also activate detailed network markers (large size)\n" 1>&2
29 printf "\t-i Also activate input subsystem events (security implication: records keyboard inputs)\n" 1>&2
30 echo "" 1>&2
31 printf "\t-q Quiet mode, suppress output\n" 1>&2
32 printf "\t-h Print this help\n" 1>&2
33 echo "" 1>&2
045880fb
BP
34}
35
efd72b5d 36if [ "$(id -u)" != "0" ]; then
cdfcd011 37 echo "Error: This script needs to be run as root." 1>&2
efd72b5d
AM
38 exit 1;
39fi
40
fde9c319 41if [ ! "${DEBUGFSROOT}" ]; then
cdfcd011 42 echo "Error: debugfs not mounted" 1>&2
045880fb
BP
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
cdfcd011 52 echo "Error: LTT trace controller not found (did you compile and load LTTng?)" 1>&2
efd72b5d
AM
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.026361 seconds and 4 git commands to generate.