Skip to content

Instantly share code, notes, and snippets.

@pcuzner
pcuzner / analyze-cloudping.py
Last active March 7, 2023 01:20
Quick analysis of cloudping to identify regions that match a specific inter-region latency
#!/usr/bin/env python3
import sys
# data extracted from cloudping : https://www.cloudping.co/grid/p_90/timeframe/1D
rows = []
try:
max_latency = int(sys.argv[1])
except (IndexError, ValueError):
max_latency = 20
@pcuzner
pcuzner / rgw-exporter.py
Last active October 28, 2022 04:17
basic rgw-exporter to show radosgw-admin and prometheus-client
#!/usr/bin/env python3
# simple POC code to illustrate the integration of radosgw-admin and a prometheus
# client
#
# Requires:
# python3-jmespath
# python3-prometheus_client
# ceph-common installed (i.e. radosgw-admin command is available)
# ceph.conf configured
@pcuzner
pcuzner / rbd-mirror-exporter.py
Last active September 8, 2022 05:14
Example exporter using the prometheus client to provide rbd-mirror metrics
#!/usr/bin/env/python3
import threading
from prometheus_client import start_http_server
from prometheus_client.core import GaugeMetricFamily, REGISTRY
import os
import subprocess
import json
import time
import enum
@pcuzner
pcuzner / cherrypie.py
Created August 9, 2021 22:22
cherrypy example
#!/usr/bin/env python3
import cherrypy
# Test:
# curl -H "Content-Type: application/json" http://localhost:8000/data --data '{"data":30}' -X POST
class Root:
def __init__(self):
@pcuzner
pcuzner / CephContainerAnalysis.json
Created July 19, 2021 21:36
Grafana Dashboard to visualise Ceph container resource utilisation from cadvisor metrics
{
"annotations": {
"list": [
{
"$$hashKey": "object:140",
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
@pcuzner
pcuzner / cephadmremoto.py
Last active September 29, 2020 22:36
test script to understand the elapsed time of a remoto (ssh) call for a basic cephadm -h command
import datetime
import os
import json
# 1. ensure your host has python3-remoto installed
import remoto
# 2. Pick the location of the cephadm 'binary' to ship to the target
# cephadm_path = '/home/paul/git/ceph/src/cephadm/cephadm'
# cephadm_path = '/usr/sbin/cephadm'
@pcuzner
pcuzner / Peek 2020-09-11 16-40.gif
Last active September 11, 2020 05:19
cephadm daemon demo
Peek 2020-09-11 16-40.gif
@pcuzner
pcuzner / cephadm payload
Created September 10, 2020 22:47
Output example from a proposed web service for cephadm
{
"health": {
"host_facts": "active",
"list_daemons": "active",
"ceph_volume": "active",
"http_server": "active"
},
"host": {
"scrape_timestamp": 1599777626.2632258,
"scrape_duration_secs": 0.01775193214416504,
@pcuzner
pcuzner / daemonls.py
Last active September 1, 2020 06:05
POC code which demonstrates a faster approach to the cephadm daemon_list function
#!/usr/bin/env python3
import os
import fcntl
import subprocess
import logging
import time
import select
import json
import datetime
from urllib.request import urlopen
@pcuzner
pcuzner / monitoring.py
Last active November 27, 2019 22:54
deploying ceph monitoring components. This is just test code to identify the processing flow that would need to be added to the ceph-daemon script
import yaml
import threading
import logging
import json
import os
import subprocess
import socket
import sys
import fcntl
import select