Created
October 13, 2011 16:07
-
-
Save wbailey/1284643 to your computer and use it in GitHub Desktop.
Monitoring remote services using SSH
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment