Rank amateur here. Good to see you all.

This Bash script does what I want it to do, but a quick look at it shows that it is doing the
same thing 3 times. This seems a bit inelegant and wasteful. I'm sure there is an easier
way to do this, but I have no idea what that might be.

Can some of you point me in the right direction? I would appreciate it.

The script:

Code:
#!/bin/bash

# See if the application in question is running and dump output into a text file
#
ps aux|grep gkrellm > gkrellm_poll.txt

# Define some variables representing the ip addresses of the machines I'm testing for
#
ADAMSMDK=192.168.1.100
PVR=192.168.1.103
SHUTTLE=192.168.1.105

# Check the text file for presence of the ip addresses expected.
# If present, move on, else, open up a gkrellm instance for that ip address.
# Do this for each ip address I'm looking for.
#
if 
        grep -Fq "$ADAMSMDK" gkrellm_poll.txt         # Is the ip address found?
then echo "found $ADAMSMDK ADAMSMDK"                  # If so, move on, if not start a gkrellm instance
else ssh -p2222 -f -L 19150:192.168.1.100:19150 192.168.1.100 "gkrellm -f -s 127.0.0.1 -P 19150"
fi
#
if 
        grep -Fq "$PVR" gkrellm_poll.txt
then echo "found $PVR PVR"
else ssh -p2222 -f -L 19150:192.168.1.103:19150 192.168.1.103 "gkrellm -f -s 127.0.0.1 -P 19150"
fi
#
if
        grep -Fq "$SHUTTLE" gkrellm_poll.txt
then echo "found $SHUTTLE SHUTTLE"
else ssh -p2222 -f -L 19150:192.168.1.105:19150 192.168.1.105 "gkrellm -f -s 127.0.0.1 -P 19150"
fi

# Clean up the no longer needed text file.
#
rm -f gkrellm_poll.txt
Thank you for your time and attention.