Skip to content

Instantly share code, notes, and snippets.

@simontraill
simontraill / gist:bf34665372515cd4699fac7f4ec7e2ba
Last active July 18, 2018 16:50
SwiftStack Firewall rules addition - example
#!/usr/bin/env bash
# Allow extra connections to a SwiftStack controller or node through the firewall.
# We require firewall-cmd be installed for this, or else we warn the user.
# On startup this script adds a new input chain called localrules-in...
#
# - To the INPUT chain if on a node;
# - To the IN_public_allow chain if on a controller.
#
# For Enterprise Linux 7 only; for IPv4 only.
#
@simontraill
simontraill / Project Gutenberg To Swift Scraper
Last active April 18, 2018 16:30
Scrapes the top 100 books from the Gutenberg project (https://www.gutenberg.org) and uploads them to Swift - with metadata.
# Quick and Dirty Project Scraper. Pulls top 100 text Ebooks, massages the metadata to make it more Elasticsearch friendly, and uploads to Swift.
# Usage: Edit the params below and run me.
# It's slow. This is deliberate, because otherwise Gutenberg will block your connection (for up to 24 hours). Which is slower.
# straill 2018/04/18
SWIFT_HOST=localhost:3880
SWIFT_PROTO=http # ( http | https )
SWIFT_USER=gutenberg
SWIFT_PASSWORD=password
SWIFT_AUTH_URL=${SWIFT_PROTO}://${SWIFT_HOST}/auth/v1.0
@simontraill
simontraill / swift_live_object_replication.sh
Last active October 26, 2017 15:11
Check that a normal object upload is replicating as we'd expect.
#!/usr/bin/env bash
# Openstack Swift Object Live Replication Test
# straill (SwiftStack) 2017/10/26
#
# Setup:
# - Ensure you have a swift account created - see SWIFT_USER below.
# - Then set the config varibles below for your endpoints and password.
#
# We push a test object into a swift cluster, then use swift-get-nodes to see where the replicas actually are.
@simontraill
simontraill / swiftstack_ring_dispersion
Created October 26, 2017 13:52
Ring Dispersion checker for Swiftstack Storage Policies
#!/usr/bin/env bash
# Check a given storage policy dispersion. If non-zero, return a warning.
# straill 2017/11/26
. /opt/ss/etc/profile.d/01-swiftstack-controller.sh
# Configure me here.
# Usage note: when you change your storage layout, the dispersion of your storage policy WILL BE NON ZERO for some time.
# Further, if your cluster layout is not entirely balanced across failure domains (same amount of disks and nodes in each, and each disk has the same size), dispersion will increase. This doesn't indicate a cluster failure - just that swift is either rebalancing or doing the best it can with the storage it's been given.
@simontraill
simontraill / swiftstack_alerts.sh
Created October 26, 2017 13:17
check_mk probe for SwiftStack Controller alert status. If any unacknowleged alerts exist, return a WARNING.
#!/usr/bin/env bash
# Probe for Swiftstack alerts. If we find ANY unacknowleged alerts in the controller, spit out a WARNING in check_mk.
# straill 2017/11/26
. /opt/ss/etc/profile.d/01-swiftstack-controller.sh
# PGPASS location
export PGPASSFILE=/home/swiftstack/repstatus/pgpass
[ ! -f $PGPASSFILE ] && PGPASSFILE=/opt/ss/etc/pgpass
@simontraill
simontraill / certsetup.sh
Created October 18, 2017 13:17
Install a self signed SSL certificate into the local machine's trust store
#!/usr/bin/env bash
set -x
HOST=$1
if [ -d /etc/pki/ca-trust/source/anchors/ ] ; then
echo -n | openssl s_client -connect ${HOST}| sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /etc/pki/ca-trust/source/anchors/ssman.crt
update-ca-trust enable
update-ca-trust extract
elif [ -d /usr/local/share/ca-certificates ] ; then
echo -n | openssl s_client -connect ${HOST} | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /usr/local/share/ca-certificates/ssman.crt
@simontraill
simontraill / swift_throughput.sh
Created October 18, 2017 11:23
Throughput monitor for Swift, check_mk format
#!/usr/bin/env bash
# Openstack Swift Basic Throughput test
# straill (SwiftStack) 2017/10/16
#
# Setup:
# - Ensure you have a swift account created - see SWIFT_USER below.
# - Then set the config varibles below for your endpoints and password.
# - Runs a simple PUT with a known size object; returns success levels based on speed
# - Runs a simple GET with a known size object; returns success levels based on speed
@simontraill
simontraill / swift_replication_status.sh
Created October 17, 2017 15:50
SwiftStack repliation status checker in check_mk format
#!/usr/bin/env bash
# Probe for Swiftstack replication cycle times, taken from postgres on controller
# straill 2016/11/01
# Arguments:
# $1 cluster name
# $2 replication type (must be one of 'object', 'container', 'account')
. /opt/ss/etc/profile.d/01-swiftstack-controller.sh
@simontraill
simontraill / replication_status.sh
Created October 17, 2017 15:39
Exit code based alerting based on SwiftStack replication status
#!/usr/bin/env bash
# Probe for Swiftstack replication cycle times, taken from postgres on controller
# straill 2016/11/01
# Arguments:
# $1 cluster name
# $2 replication type (must be one of 'object', 'container', 'account')
CID=$1
RTYPE=$2
@simontraill
simontraill / swift_api.sh
Last active April 9, 2019 08:31
swift api checks in check_mk format
#!/usr/bin/env bash
# Openstack Swift Basic API tests for check_mk
# straill (SwiftStack) 2017/10/16
#
# Setup:
# - Ensure you have a swift account created - see SWIFT_USER below.
# - Then set the config varibles below for your endpoints and password.
# - Runs basic functional test set using some (ugly) cURL commands; returns status in check_mk format
# - Failures will cause us to immediately bail and return bad status