Skip to content

Instantly share code, notes, and snippets.

View wido's full-sized avatar

Wido den Hollander wido

View GitHub Profile
@wido
wido / varnish-rgw-auth-pcre.vcl
Last active July 10, 2018 05:51
Varnish regsub PCRE Amazon AWS Authentication header
import std;
#
# When using Varnish in front of Ceph's RADOS Gateway you might want to log the access keys doing a request
# and they are a part of the Authorization HTTP header
#
# Using regsub and PCRE we can fetch just that part from the header and log it to the VCL Log which we can pick up with varnishncsa
#
sub vcl_recv {
@wido
wido / ceph-bluestore-overhead.py
Last active April 8, 2021 07:56
Calculate Ceph BlueStore OSD overhead per object
#!/usr/bin/env python
'''
Talk to local Ceph OSDs running with BlueStore and calculate the overhead
per object in the RocksDB database from BlueStore.
Author: Wido den Hollander <[email protected]>
'''
import json
from os import listdir
@wido
wido / nanotime.py
Created April 12, 2018 11:42
Python UNIX timestamp nanoseconds
# Get the current UNIX Timestamp in nanoseconds
#
# Author: Wido den Hollander <[email protected]>
import time
now = int(round(time.time() * 1000000000))
print(now)
@wido
wido / cloudstack-build-deb.sh
Created March 19, 2018 16:26
Build Apache CloudStack DEB packages
#!/bin/bash
apt-get update
apt-get install -y python-software-properties software-properties-common
add-apt-repository -y ppa:openjdk-r/ppa
apt-get update
apt-get install -y openjdk-8-jdk openjdk-8-jre wget dpkg-dev devscripts debhelper genisoimage python-mysql.connector maven dh-systemd python-setuptools
@wido
wido / set-ipv6-security-group-rules.py
Created March 8, 2018 13:52
Add CloudStack IPv6 Security Group rules after upgrade to CloudStack 4.10
#!/usr/bin/env python3
import uuid
import mysql.connector
MYSQL_PASS = 'XXXXXXXXX'
cnx = mysql.connector.connect(password=MYSQL_PASS, user='root', database='cloud')
cursor = cnx.cursor()
@wido
wido / crushmap.txt
Created February 19, 2018 13:40
Ceph CRUSHMap to replicate over datacenters
# begin crush map
tunable choose_local_tries 0
tunable choose_local_fallback_tries 0
tunable choose_total_tries 50
tunable chooseleaf_descend_once 1
tunable chooseleaf_vary_r 1
tunable chooseleaf_stable 1
tunable straw_calc_version 1
tunable allowed_bucket_algs 54
@wido
wido / ceph-bluestore-db-size.sh
Created January 30, 2018 09:12
Ceph OSD BlueStore database size
#!/bin/bash
# For each running OSD query the BlueStore DB size and entries and calculate avg size per entry
#
# Author: Wido den Hollander <[email protected]>
#
for OSD_ID in $(find /var/run/ceph -name 'ceph-osd.*.asok' -type s -printf "%f\n"|cut -d '.' -f 2); do
DB_USED_BYTES=$(ceph daemon osd.$OSD_ID perf dump|jq '.bluefs.db_used_bytes')
BLUESTORE_ONODES=$(ceph daemon osd.$OSD_ID perf dump|jq '.bluestore.bluestore_onodes')
echo "osd.$OSD_ID: db_used_bytes=$DB_USED_BYTES bluestore_onodes=$BLUESTORE_ONODES db_entry_size=$(($DB_USED_BYTES / BLUESTORE_ONODES))"
@wido
wido / ceph-umount-and-wipe.sh
Last active January 30, 2018 12:06
Stop, umount and wipe all Ceph OSDs on a system
#!/bin/bash
set -e
systemctl stop ceph-osd.target
for ID in $(df -P|grep "/var/lib/ceph/osd"|awk '{print $6}'|cut -d '-' -f 2); do
DEVICE=$(df -P /var/lib/ceph/osd/ceph-$ID|awk '{print $1}'|tail -1|sed 's/.$//'|cut -d '/' -f 3)
ROTATIONAL=$(cat /sys/block/$DEVICE/queue/rotational)
@wido
wido / duply.conf
Created December 8, 2017 11:53
Duply Configuration with SSH on PCextreme's Aurora Mammoth
# Duply configuration I use to backup my ownCloud server to PCextreme's Aurora Mammoth: https://www.pcextreme.com/aurora/mammoth
#
# Uses SSH/SFTP to store data
#
# Yes, I disabled GPG on purpose
#
# File: /root/.duply/owncloud/conf
#
GPG_KEY='disabled'
TARGET='rsync://[email protected]/owncloud'
@wido
wido / fizzbuzz.py
Created November 29, 2017 10:23
FizzBuzz in Python 3
#!/usr/bin/env python3
for i in range(1, 100 + 1):
buf = str()
if (i % 3) == 0:
buf += "Fizz"
if (i % 5) == 0:
buf += "Buzz"