Fix some casting errors that had never appeared during compilation before. Ever
[aquarium] / ping.sh
1 #!/bin/bash
2 #
3 PORT=8888
4 SERVER=localhost
5 #
6 usage() {
7   echo "Usage: $0 [options]"
8   echo ""
9   echo "OPTIONS:"
10   echo "  -s address Server IP address."
11   echo "  -p port    Server port number."
12   echo "  -h         Show this message."
13   exit 0
14 }
15 #
16 function ping {
17    #echo "SERVER : $SERVER PORT : $PORT" 
18    OUT=`curl -s http://$SERVER:$PORT/ping/$1  | grep PONG`
19    if [ "$OUT"  != "PONG" ] ;  
20    then
21       exit 1
22    fi
23 }
24 #
25 while getopts ":p:s:h" opt
26 do
27   case $opt in
28     p) PORT=$OPTARG
29     ;;
30     s) SERVER=$OPTARG
31     ;;
32     h) usage
33     ;;
34     :) ERROR="Option -$OPTARG requires an argument. Aborting..."
35     ;;
36     \?) ERROR="Invalid option: -$OPTARG"
37     ;;
38   esac
39 done
40
41 if [ -n "$ERROR" ]; then
42   echo $ERROR >&2
43   exit 1
44 fi
45
46 #
47 ping aquarium
48 ping rabbitmq
49 ping imstore
50 ping rcstore
51 exit 0