Created
July 3, 2014 22:30
-
-
Save mrpatrick/cfe1991726ad32ccef51 to your computer and use it in GitHub Desktop.
Get the status of Rackspace-ORD and set them on StatusPage.io Components
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 | |
# Set from statuspage.io | |
PAGE_ID="" | |
AUTH_TOKEN="" | |
# Set from statuspage.io Component ID's | |
COMP_SERVERS_NEXT="" | |
COMP_SERVERS_FIRST="" | |
COMP_LOAD_BALANCERS="" | |
COMP_BLOCK_STORAGE="" | |
COMP_FILES="" | |
COMP_BACKUP="" | |
# status | |
UP="operational" | |
DOWN="partial_outage" | |
# Rackspace ORD Services | |
SERVERS_NEXT=$(curl -s https://raw.githubusercontent.com/jjasghar/nagios-status-rackspace/master/cloud_servers_next_chicago.sh | bash /dev/stdin |grep normal) | |
SERVERS_FIRST=$(curl -s https://raw.githubusercontent.com/jjasghar/nagios-status-rackspace/master/cloud_servers_1st_chicago.sh | bash /dev/stdin |grep normal) | |
LOAD_BALANCERS=$(curl -s https://raw.githubusercontent.com/jjasghar/nagios-status-rackspace/master/cloud_load_balancers_chicago.sh | bash /dev/stdin |grep normal) | |
BLOCK_STORAGE=$(curl -s https://raw.githubusercontent.com/jjasghar/nagios-status-rackspace/master/cloud_block_storage_chicago.sh | bash /dev/stdin |grep normal) | |
FILES=$(curl -s https://raw.githubusercontent.com/jjasghar/nagios-status-rackspace/master/cloud_files_chicago.sh | bash /dev/stdin |grep normal) | |
BACKUP=$(curl -s https://raw.githubusercontent.com/jjasghar/nagios-status-rackspace/master/cloud_backup_chicago.sh | bash /dev/stdin |grep normal) | |
# Request Info | |
URL="https://api.statuspage.io/v1/pages/$PAGE_ID/components/" | |
AUTH="Authorization: OAuth $AUTH_TOKEN" | |
TYPE="Content-Type: application/x-www-form-urlencoded" | |
# Set Status | |
if [ -z "$SERVERS_NEXT" ]; then | |
SERVERS_NEXT=$DOWN | |
else | |
SERVERS_NEXT=$UP | |
fi | |
if [ -z "$SERVERS_FIRST" ]; then | |
SERVERS_FIRST=$DOWN | |
else | |
SERVERS_FIRST=$UP | |
fi | |
if [ -z "$LOAD_BALANCERS" ]; then | |
LOAD_BALANCERS=$DOWN | |
else | |
LOAD_BALANCERS=$UP | |
fi | |
if [ -z "$BLOCK_STORAGE" ]; then | |
BLOCK_STORAGE=$DOWN | |
else | |
BLOCK_STORAGE=$UP | |
fi | |
if [ -z "$FILES" ]; then | |
FILES=$DOWN | |
else | |
FILES=$UP | |
fi | |
if [ -z "$BACKUP" ]; then | |
BACKUP=$DOWN | |
else | |
BACKUP=$UP | |
fi | |
# Set Status on StatusPage.io | |
curl "$URL$COMP_SERVERS_NEXT" \ | |
-X PATCH \ | |
-H "$AUTH" \ | |
-H "$TYPE" \ | |
-d "component[status]=$SERVERS_NEXT" \ | |
curl "$URL$COMP_SERVERS_FIRST" \ | |
-X PATCH \ | |
-H "$AUTH" \ | |
-H "$TYPE" \ | |
-d "component[status]=$SERVERS_FIRST" \ | |
curl "$URL$COMP_LOAD_BALANCERS" \ | |
-X PATCH \ | |
-H "$AUTH" \ | |
-H "$TYPE" \ | |
-d "component[status]=$LOAD_BALANCERS" \ | |
curl "$URL$COMP_BLOCK_STORAGE" \ | |
-X PATCH \ | |
-H "$AUTH" \ | |
-H "$TYPE" \ | |
-d "component[status]=$BLOCK_STORAGE" \ | |
curl "$URL$COMP_CLOUD_FILES" \ | |
-X PATCH \ | |
-H "$AUTH" \ | |
-H "$TYPE" \ | |
-d "component[status]=$CLOUD_FILES" \ | |
curl "$URL$COMP_BACKUP" \ | |
-X PATCH \ | |
-H "$AUTH" \ | |
-H "$TYPE" \ | |
-d "component[status]=$BACKUP" \ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment