flamegraph

Fork of flamegraph without J***S*****.
git clone git://git.laack.co/flamegraph.git
Log | Files | Refs | README

commit 702072d8fb5176c5a5a6df2accbd0365cf5abace
parent 15184018a0aaf8fc72d50800b46bd0c4d194ea38
Author: Brendan Gregg <brendan.d.gregg@gmail.com>
Date:   Fri, 16 Jun 2017 14:21:01 -0700

use the UID mode to sudo if needed

Diffstat:
Mjmaps | 9++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/jmaps b/jmaps @@ -77,9 +77,12 @@ for pid in $(pgrep -x java); do user=$(ps ho user -p $pid) if [[ "$user" != root ]]; then - # make $user the username if it is a UID: - if [[ "$user" == [0-9]* ]]; then user=$(awk -F: '$3 == '$user' { print $1 }' /etc/passwd); fi - cmd="sudo -u $user sh -c '$cmd'" + if [[ "$user" == [0-9]* ]]; then + # UID only, run sudo with #UID: + cmd="sudo -u '#'$user sh -c '$cmd'" + else + cmd="sudo -u $user sh -c '$cmd'" + fi fi echo "Mapping PID $pid (user $user):"