Repository: trafodion
Updated Branches:
  refs/heads/master fa6ae7121 -> debf35be5


Several scripts incorrectly use cut -b 1-5 to extract pid information


Project: http://git-wip-us.apache.org/repos/asf/trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafodion/commit/9644ff8c
Tree: http://git-wip-us.apache.org/repos/asf/trafodion/tree/9644ff8c
Diff: http://git-wip-us.apache.org/repos/asf/trafodion/diff/9644ff8c

Branch: refs/heads/master
Commit: 9644ff8cfeb23729ff163372f5f1c822338a3110
Parents: 7d77dd4
Author: Anuradha Hegde <[email protected]>
Authored: Mon Mar 26 17:58:31 2018 +0000
Committer: Anuradha Hegde <[email protected]>
Committed: Mon Mar 26 17:58:31 2018 +0000

----------------------------------------------------------------------
 core/sqf/sql/scripts/pkillall                         | 14 +++++++-------
 core/sqf/sql/scripts/presumeall                       |  4 ++--
 core/sqf/sql/scripts/psuspendall                      |  4 ++--
 core/sqf/sql/scripts/traf_pkill                       |  2 +-
 .../TRAFODION/2.1/package/scripts/trafodionnode.py    |  2 +-
 5 files changed, 13 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafodion/blob/9644ff8c/core/sqf/sql/scripts/pkillall
----------------------------------------------------------------------
diff --git a/core/sqf/sql/scripts/pkillall b/core/sqf/sql/scripts/pkillall
index b3a3b9f..bfd69b4 100755
--- a/core/sqf/sql/scripts/pkillall
+++ b/core/sqf/sql/scripts/pkillall
@@ -23,18 +23,18 @@
 #
 
 # Obtain process ids of any monitors for current user.
-MONPIDLIST=$(ps --no-header -C monitor -o user:12,pid | grep -w ^$USER | cut 
-b 14-18)
+MONPIDLIST=$(ps --no-header -C monitor -o user:12,pid | grep -w ^$USER | awk 
'{print $2}')
 # Make MONPIDLISTCS a comma separated list of monitor process ids
-MONPIDLISTCS=$(echo $MONPIDLIST | sed 's/ /,/g')
+MONPIDLISTCS=$(echo $MONPIDLIST | sed 's/\s/,/g')
 
 # Obtain process ids of any watchdog processes for current user.
-WDTPIDLIST=$(ps --sort=cmd,pid -C sqwatchdog -o user:12,pid | grep -w ^$USER | 
cut -b 14-18)
+WDTPIDLIST=$(ps --sort=cmd,pid -C sqwatchdog -o user:12,pid | grep -w ^$USER | 
awk '{print $2}')
 
 # Obtain process ids of Trafodion processes (except monitor and watchdog 
processes)
 if [ "$1" = "-safekill" ]; then
     SAFE=1
 fi
-SQ_PROCS=$(pstat -h -s | cut -b 14-18)
+SQ_PROCS=$(pstat -h -s | awk '{print $2}')
 
 # Remove Trafodion processes (except monitor and watchdog processes)
 if [[ -n $SQ_PROCS ]]; then
@@ -49,7 +49,7 @@ sleep 1
 # to the system but not included in "pstat" or if the monitor was
 # creating a new process just at the time "pstat" was executing).
 if [[ -n $MONPIDLISTCS ]]; then
-    ORPHANS=$(ps --no-headers --ppid $MONPIDLISTCS -o pid,cmd | grep -v 
sqwatchdog | cut -b 1-5)
+    ORPHANS=$(ps --no-headers --ppid $MONPIDLISTCS -o pid,cmd | grep -v 
sqwatchdog | awk '{print $1}')
 fi
 if [[ -n $ORPHANS ]]; then
     echo $ORPHANS | xargs kill -9 2>/dev/null
@@ -68,14 +68,14 @@ if [[ -z $SAFE ]]; then
     # This repeats the earlier steps.  Generally will be few if any Trafodion
     # processes remaining.   Those remaining are typically persistent processes
     # that got recreated by the monitor before it was killed.
-    SQ_PROCS=$(pstat -h -s | cut -b 14-18)
+    SQ_PROCS=$(pstat -h -s | awk '{print $2}')
     if [[ -n $SQ_PROCS ]]; then
         echo $SQ_PROCS | xargs kill -9 2>/dev/null
     fi
 fi
 
 # kill all running vili workflows
-ps -u $USER -o pid,cmd | grep " -vili" | cut -b 1-5 | xargs -r kill -9 
2>/dev/null
+ps -u $USER -o pid,cmd | grep " -vili" | awk '{print $1}' | xargs -r kill -9 
2>/dev/null
 
 rm -f /dev/shm/sem.rms.`id -u`.* 2>/dev/null
 rm -f /dev/shm/sem.monitor*$USER 2>/dev/null

http://git-wip-us.apache.org/repos/asf/trafodion/blob/9644ff8c/core/sqf/sql/scripts/presumeall
----------------------------------------------------------------------
diff --git a/core/sqf/sql/scripts/presumeall b/core/sqf/sql/scripts/presumeall
index c96f26e..faea8ca 100755
--- a/core/sqf/sql/scripts/presumeall
+++ b/core/sqf/sql/scripts/presumeall
@@ -21,8 +21,8 @@
 #
 # @@@ END COPYRIGHT @@@
 #
-SQ_PROCS=`pstat -h | cut -b 14-18`
+SQ_PROCS=`pstat -h | awk '{print $2}'`
 if [[ $SQ_PROCS != "" ]]; then
     echo "Executing the presumeall command"
-    pstat -h | cut -b 14-18 | xargs kill -s SIGCONT
+    pstat -h | awk '{print $2}' | xargs kill -s SIGCONT
 fi

http://git-wip-us.apache.org/repos/asf/trafodion/blob/9644ff8c/core/sqf/sql/scripts/psuspendall
----------------------------------------------------------------------
diff --git a/core/sqf/sql/scripts/psuspendall b/core/sqf/sql/scripts/psuspendall
index 6da993d..8f30536 100755
--- a/core/sqf/sql/scripts/psuspendall
+++ b/core/sqf/sql/scripts/psuspendall
@@ -21,8 +21,8 @@
 #
 # @@@ END COPYRIGHT @@@
 #
-SQ_PROCS=`pstat -h | cut -b 14-18`
+SQ_PROCS=`pstat -h | awk '{print $2}'`
 if [[ $SQ_PROCS != "" ]]; then
     echo "Executing the psuspendall command"
-    pstat -h | cut -b 14-18 | xargs kill -s SIGSTOP
+    pstat -h | awk '{print $2}' | xargs kill -s SIGSTOP
 fi

http://git-wip-us.apache.org/repos/asf/trafodion/blob/9644ff8c/core/sqf/sql/scripts/traf_pkill
----------------------------------------------------------------------
diff --git a/core/sqf/sql/scripts/traf_pkill b/core/sqf/sql/scripts/traf_pkill
index 2352ba1..4310822 100755
--- a/core/sqf/sql/scripts/traf_pkill
+++ b/core/sqf/sql/scripts/traf_pkill
@@ -21,4 +21,4 @@
 #
 # @@@ END COPYRIGHT @@@
 #
-ps -ef | grep $1 | cut -b 10-14 | xargs kill -9
+ps -ef | grep $1 | grep -v grep | awk '{print $2}' | xargs kill -9

http://git-wip-us.apache.org/repos/asf/trafodion/blob/9644ff8c/install/ambari-installer/traf-mpack/common-services/TRAFODION/2.1/package/scripts/trafodionnode.py
----------------------------------------------------------------------
diff --git 
a/install/ambari-installer/traf-mpack/common-services/TRAFODION/2.1/package/scripts/trafodionnode.py
 
b/install/ambari-installer/traf-mpack/common-services/TRAFODION/2.1/package/scripts/trafodionnode.py
index 642851e..b9a07e7 100755
--- 
a/install/ambari-installer/traf-mpack/common-services/TRAFODION/2.1/package/scripts/trafodionnode.py
+++ 
b/install/ambari-installer/traf-mpack/common-services/TRAFODION/2.1/package/scripts/trafodionnode.py
@@ -138,7 +138,7 @@ class Node(Script):
          content = InlineTemplate(params.dcs_log4j_template),
          mode=0644)
 
-    serverlist = 
'\n'.join(params.dcs_mast_node_list[1:len(params.dcs_mast_node_list)]) + '\n'
+    serverlist = '\n'.join(params.dcs_mast_node_list)) + '\n'
     File(os.path.join(trafhome,"masters"),
          owner = params.traf_user, 
          group = params.traf_group, 

Reply via email to