#!/bin/bash
###############################################################################################################
#                                                                                                             #
#                                           Cassandra Process Killer                                          #
#                                          Eloy Gil - eloy.gil@bsc.es                                         #
#                                                                                                             #
#                                        Barcelona Supercomputing Center                                      #
#                                                    .-.--_                                                   #
#                                                  ,´,´.´   `.                                                #
#                                                  | | | BSC |                                                #
#                                                  `.`.`. _ .´                                                #
#                                                    `·`··                                                    #
#                                                                                                             #
###############################################################################################################

# Kill Cassandra instance
PID=$(ps aux | grep java | grep cassandra | awk '{ print $2 }')
if [ "$PID" != "" ]; then
    echo "Host $(hostname) is killing its cassandra process with PID: "$PID
    kill $PID
else
    echo "Host $(hostname) can not find a running cassandra process to kill."
fi

# Kill Arrow Helpers
PID=$(ps aux |grep arrow_helper | awk '{print $2}')
if [ "$PID" != "" ]; then
    echo "Host $(hostname) is killing its arrow_helper process with PID: "$PID
    kill $PID
else
    echo "Host $(hostname) can not find a running arrow_helper process to kill."
fi

# Kill Kafka
PID=$(ps aux |grep java | awk '{print $2}')
if [ "$PID" != "" ]; then
    echo "Host $(hostname) is killing its kafka process with PID: "$PID
    kill $PID
else
    echo "Host $(hostname) can not find a running kafka process to kill."
fi

exit

#!/bin/bash
###############################################################################################################
#                                                                                                             #
#                                           Cassandra Process Killer                                          #
#                                          Eloy Gil - eloy.gil@bsc.es                                         #
#                                                                                                             #
#                                        Barcelona Supercomputing Center                                      #
#                                                    .-.--_                                                   #
#                                                  ,´,´.´   `.                                                #
#                                                  | | | BSC |                                                #
#                                                  `.`.`. _ .´                                                #
#                                                    `·`··                                                    #
#                                                                                                             #
###############################################################################################################

# Kill Cassandra instance
PID=$(ps aux | grep java | grep -v grep| grep cassandra | awk '{ print $2 }')
if [ "$PID" != "" ]; then
    echo "Host $(hostname) is killing its cassandra process with PID: "$PID
    kill $PID
fi

# Kill Arrow Helpers
PID=$(ps aux |grep arrow_helper | grep -v grep| awk '{print $2}')
if [ "$PID" != "" ]; then
    echo "Host $(hostname) is killing its arrow_helper process with PID: "$PID
    kill $PID
fi

# Kill Kafka
PID=$(ps aux |grep java | grep -v grep| grep kafka | awk '{print $2}')
if [ "$PID" != "" ]; then
    echo "Host $(hostname) is killing its kafka process with PID: "$PID
    kill $PID
fi

PID=$(ps aux |grep java | grep -v grep| grep zookeeper | awk '{print $2}')
if [ "$PID" != "" ]; then
    echo "Host $(hostname) is killing its zookeeper process with PID: "$PID
    kill $PID
fi

exit

Hide empty messages when killing processes
Hide empty messages when killing processes

    * There was a message saying that it was unable to kill
      cassandra/kafka/zookeeper processes in a node. These messages were
      harmless as the script was being executed in all nodes in the
      cluster.
