From 30ac2b313534178a0ed9f9dbd6fa3f6dd45edea8 Mon Sep 17 00:00:00 2001 From: paulc Date: Mon, 19 Nov 2018 21:07:13 +0000 Subject: [PATCH] Added support for monitoring services with name other than yate. git-svn-id: http://yate.null.ro/svn/yate/trunk@6328 acf43c95-373e-0410-b603-e72c3f656dc1 --- tools/yatemon.sh | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/tools/yatemon.sh b/tools/yatemon.sh index 45c3f7c9..29fe1cea 100755 --- a/tools/yatemon.sh +++ b/tools/yatemon.sh @@ -4,7 +4,7 @@ # This file is part of the YATE Project http://YATE.null.ro # # Yet Another Telephony Engine - a fully featured software PBX and IVR -# Copyright (C) 2010-2014 Null Team +# Copyright (C) 2010-2018 Null Team # # This software is distributed under multiple licenses; # see the COPYING file in the main directory for licensing @@ -18,14 +18,34 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# Use: yatemon.sh [-p pid] +# Use: yatemon.sh [-n name|-p pid] # Displays a history of Yate's memory and thread CPU usage # You will need a very wide console -pid=`pidof yate 2>/dev/null` +case "X$1" in + X-p) + pid="$2" + ;; + X-n) + pid=`pidof "$2" 2>/dev/null` + ;; + *) + pid=`pidof yate 2>/dev/null` + ;; +esac -if [ "X$1" = "X-p" ]; then - pid="$2" +if echo "$pid" | grep -q '^[0-9]\+ [0-9]\+$'; then + p1="${pid%% *}" + p2="${pid##* }" + if [ "X"`ps -p "$p1" -o ppid= | sed 's/ //g'` = "X1" ]; then + if [ "X"`ps -p "$p2" -o ppid= | sed 's/ //g'` != "X1" ]; then + pid="$p2" + fi + else + if [ "X"`ps -p "$p2" -o ppid= | sed 's/ //g'` = "X1" ]; then + pid="$p1" + fi + fi fi if ! kill -0 "$pid" 2> /dev/null; then