Skip to content

Instantly share code, notes, and snippets.

@clayg
clayg / async_pending_stats.py
Last active October 5, 2022 18:16
Get info about async pendings
#!/usr/bin/env python
import sys
import os
import errno
from argparse import ArgumentParser
from collections import defaultdict
import pickle
import logging
try:
import thread
@clayg
clayg / slow_s3_download.py
Created November 11, 2020 17:44
s3 client for playing with slow ranged reads
from argparse import ArgumentParser
import sys
import time
import boto3
parser = ArgumentParser()
parser.add_argument('bucket', help='bucket to make the upload')
parser.add_argument('key', nargs='?', help='key name for large object')
@clayg
clayg / example.out
Last active April 30, 2020 21:35
priority updater can target/skip specific problematic containers
vagrant@saio:~$ /vagrant/.scratch/priority-object-updater --help
Usage: priority-object-updater CONFIG [options]
Options:
-h, --help show this help message and exit
--container=FILTER_CONTAINERS
Only process specific AUTH_acct/container(s)
--skip=SKIP_CONTAINERS
Do not process skipped AUTH_acct/container(s)
-v, --verbose log to console
@notmyname
notmyname / rst_table.py
Last active June 10, 2019 21:07
rst table printer
#!/usr/bin/env python3.7
# pretty-print columns of text
import sys
def table_print(lines_to_print, padding=3):
"""Given a list of tuples/lists, print a nicely formatted .rst table"""
@clayg
clayg / .gitignore
Last active October 15, 2020 18:10
Troll the disks for async_pendings and gather some stats
/*.json
@clayg
clayg / swift-expired-status
Last active September 6, 2023 10:58
check on the expirer queue
#!/usr/bin/env python
from collections import defaultdict
import sys
import time
from argparse import ArgumentParser
from swift.common.internal_client import InternalClient
from swift.common.utils import Timestamp
from swift.common.wsgi import ConfigString
from swift.container.sync import ic_conf_body
@clayg
clayg / classify_handoff_parts.py
Last active April 23, 2020 18:25
check handoffs vs. misplaced parts
import sys
import os
import errno
from argparse import ArgumentParser
from collections import defaultdict
from itertools import islice
from swift.common.storage_policy import split_policy_string
from swift.obj.diskfile import get_data_dir
from swift.common.ring import Ring
#!/usr/bin/env python
import sys
from argparse import ArgumentParser
from swift.common.direct_client import direct_get_suffix_hashes
from swift.common.storage_policy import POLICIES
parser = ArgumentParser()
parser.add_argument('--policy-index', default=0, help='policy index')
parser.add_argument('part', help='the part')
@creiht
creiht / gist:7457109
Created November 13, 2013 21:53
Simple local cache implementation
import os
import sqlite3
import simplejson
import time
class LocalCache(object):
def __init__(self, path='/run/shm/cache.db'):
self.db = sqlite3.Connection(path)
#!/usr/bin/env python
"""
This script is about telling want you need *today* - not what you want to hear
""" # noqa
import sys
import math
from argparse import ArgumentParser
parser = ArgumentParser(description=__doc__.lstrip())