If you want the output of some command | grep "server may be down" stored in the variable server_status you have to use command substitution, that is:
Code:
server_status=$(some command | grep "server may be down")
but you can also embed the command in the if/then statement:
Code:
if some command | grep -q "server may be down"
echo "server $(hostname) is down " >> /home/uname/filename
else
echo "server $(hostname) is OK " >> /home/uname/filename
fi