Skip to content

Instantly share code, notes, and snippets.

View wido's full-sized avatar

Wido den Hollander wido

View GitHub Profile
@wido
wido / pdns-backend-rgw.py
Created November 26, 2013 19:42
PowerDNS backend for Ceph's RGW It responds with a CNAME to the correct bucket location
#!/usr/bin/python
from flask import abort, Flask, request, Response
import json
import subprocess
listen_port = 6780
listen_addr = "0.0.0.0"
debug_mode = True
@wido
wido / radostimeout.c
Created February 12, 2014 11:57
Testing Ceph RADOS timeout options
#include <stdio.h>
#include <string.h>
#include <rados/librados.h>
int set_rados_option(rados_t cluster, const char *option, const char *value) {
printf("Set the %s option to: %s\n", option, value);
return rados_conf_set(cluster, option, value);
}
int main(int argc, char *argv[]) {
#!/usr/bin/env python
import time
import socket
import subprocess
import json
graphite_host = 'my.graphite.machine'
graphite_port = 2003
prefix = 'ceph'
#!/usr/bin/env python
'''
Simple Python script which endlessly keeps writing 100MB to a temp file.
Used to demonstrate a Ceph cluster. This script runs inside a Virtual Machine (KVM)
running on a RBD image on a Ceph cluster.
The demo is to randomly pull out machines and show that the script can still write
and read data.
#!/usr/bin/env python
from optparse import OptionParser
def get_object_name(prefix, sector, order):
sector_size = 512
return "%s.%012x" % (prefix, (sector * sector_size) / pow(2, order))
def main():
parser = OptionParser()
@wido
wido / ceph-rados-latency.py
Created May 27, 2014 13:05
Simple Python script to store RADOS read/write latency in Graphite
#!/usr/bin/env python
'''
This script writes X MegaByte random data to 10 RADOS objects and read the data again afterwards
It writes these statistics towards a Graphite server so you can see what the latency
inside your cluster is for both Read and Write
Author: Wido den Hollander <wido@widodh.nl>
'''
@wido
wido / ceph-rest-api.wsgi
Created May 28, 2014 13:52
Ceph REST API WSGI wrapper
'''
WSGI wrapper for the Ceph REST API to be run behind Apache with mod_wsgi.
Place this script in /var/www as ceph-rest-api.wsgi and use this VirtualHost:
<VirtualHost *:80>
DocumentRoot /var/www
ServerName ceph-rest-api
ErrorLog /var/log/apache2/error.log
@wido
wido / crush-location-lookup.sh
Created July 16, 2014 07:25
Ceph CRUSH Location lookup
#!/bin/bash
# Generates a CRUSH location based on the machine's hostname.
# This Gist was written for a customer who has mixed SSDs and HDDs in a a chassis.
# Hostname example in this case: dc2-rk01-ceph01 (Datacenter 2, rack 01, Ceph machine 01)
# It checks if the backing disk is a SSD or not and then comes up with the CRUSH location
while :; do
case $1 in
--cluster)
@wido
wido / ceph-graphite-pool-stats.py
Last active June 16, 2020 07:42
Send Ceph pool statistics to Graphite
#!/usr/bin/env python
'''
This script gathers pool statistics from RADOS and sends them to a Graphite server
It allows you to graph and see what each pool is doing.
Author: Wido den Hollander <wido@widodh.nl>
'''
@wido
wido / ceph-udev-disk-scheduler.rules
Last active July 13, 2023 14:17
ceph-udev-disk-scheduler.rules
# udev rule to set disk schedulers for Ceph
# For spinning disks we want the CFQ scheduler so that we can set
# priorities on client and recovery I/O threads
#
# Author: Wido den Hollander <wido@42on.com>
# Date: July 2015
# Use deadline for SSDs
ACTION=="add|change", KERNEL=="sd[a-z]*", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="deadline"