| 1 | # Copyright (C) 2009 Benjamin Poirier |
| 2 | # Copyright (C) 2010 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
| 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 | |
| 18 | DEBUGFSROOT=$(awk '{if ($3 == "debugfs") print $2}' /proc/mounts | head -n 1) |
| 19 | MARKERSROOT=${DEBUGFSROOT}/ltt/markers |
| 20 | DEFAULTMODULES="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" |
| 21 | |
| 22 | usage () { |
| 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 |
| 29 | printf "\t-i Also activate input subsystem events (security implication: records keyboard inputs)\n" > /dev/stderr |
| 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 | |
| 36 | if [ "$(id -u)" != "0" ]; then |
| 37 | echo "Error: This script needs to be run as root." > /dev/stderr |
| 38 | exit 1; |
| 39 | fi |
| 40 | |
| 41 | if [ ! "${DEBUGFSROOT}" ]; then |
| 42 | echo "Error: debugfs not mounted" > /dev/stderr |
| 43 | exit 1; |
| 44 | fi |
| 45 | |
| 46 | if [ ! -d "${MARKERSROOT}" ]; then |
| 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 |
| 55 | fi |
| 56 | |
| 57 | while getopts "lnqh" options; do |
| 58 | case ${options} in |
| 59 | l) LOCKING="0";; |
| 60 | n) NETWORK="0";; |
| 61 | q) QUIET="0";; |
| 62 | i) INPUT="0";; |
| 63 | h) usage; |
| 64 | exit 0;; |
| 65 | \?) usage; |
| 66 | exit 1;; |
| 67 | esac |
| 68 | done |
| 69 | shift $((${OPTIND} - 1)) |
| 70 | |
| 71 | |
| 72 | if [ ! ${LOCKING} ]; then |
| 73 | TESTS="${TESTS} -name lockdep -prune -o -name locking -prune -o" |
| 74 | else |
| 75 | modprobe lockdep-trace |
| 76 | fi |
| 77 | |
| 78 | if [ ! ${NETWORK} ]; then |
| 79 | TESTS="${TESTS} -path '*/net/*_extended' -prune -o" |
| 80 | else |
| 81 | modprobe net-extended-trace |
| 82 | fi |
| 83 | |
| 84 | if [ ! ${INPUT} ]; then |
| 85 | TESTS="${TESTS} -name input -prune -o" |
| 86 | fi |
| 87 | |
| 88 | (eval "find '${MARKERSROOT}' ${TESTS} -name metadata -prune -o -name enable -print") | while read -r marker; do |
| 89 | if [ ! ${QUIET} ]; then |
| 90 | echo "Connecting ${marker%/enable}" |
| 91 | fi |
| 92 | echo 1 > ${marker} |
| 93 | done |