#!/bin/bash trap 'echo Goodbye! && rm $cmdfile && kill $child; exit 1' INT if [ -z $1 ] then echo "Usage: monitor_search hostname" exit 1 else host=$1 fi cmdfile=/tmp/search_server_commands touch $cmdfile tail -f $cmdfile | ssh ip@$host 'bash -s' & child=$! while : do clear echo $host | tr 'a-z' 'A-Z' echo echo 'echo "Connection Status" && lsof | grep java.*TCP.*8983 && echo && echo "Memory Usage" && free | grep -P "total|Mem"' > $cmdfile sleep 5 done