Created
March 30, 2014 17:39
-
-
Save moqada/9876555 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
# 対象ホストとポートのリストを指定: ex. ('0.0.0.0:22' '1.1.1.1:22') | |
HOSTS=('<HOST>:<PORT>' '<HOST>:<PORT>') | |
RUNNING_HOSTS=() | |
# HipChat のRoom Notification Tokenを指定 | |
HIPCHAT_TOKEN='<API_TOKEN>' | |
# HipChat の対象 Room ID を指定 | |
HIPCAHT_ROOM_ID='<ROOM_ID>' | |
for host in ${HOSTS[@]} | |
do | |
echo $host | |
h=`echo $host | cut -d':' -f 1` | |
p=`echo $host | cut -d':' -f 2` | |
nc -z -w 3 $h $p | |
if test $? -eq 0; then | |
echo 'running' | |
RUNNING_HOSTS+=($host) | |
fi | |
done | |
if test ${#RUNNING_HOSTS[*]} -ne 0; then | |
curl -v -H "Accept: application/json" -H "Authorization: Bearer $HIPCHAT_TOKEN" -H "Content-type: application/json" -X POST -d "{\"message\":\"@all hey guys, BASTION SERVERS are running! ${RUNNING_HOSTS[*]} http://img.tiqav.com/1Mr.jpg\", \"color\":\"red\",\"notify\":true, \"message_format\":\"text\"}" "https://api.hipchat.com/v2/room/$HIPCAHT_ROOM_ID/notification" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment