Skip to content

Instantly share code, notes, and snippets.

@charz
charz / curlxid.sh
Last active February 9, 2021 07:42
curl with xid and time
#!/bin/bash
curlxidheaders() {
echo "number,timestamp,status_code,message,size,speed_bytes_per_sec,time_total,time_namelookup,time_connect,time_appconnect,time_pretransfer,time_redirect,time_starttransfer"
}
curlxid() {
curl -w 'code: %{http_code} %{http_connect}|size: %{size_download}|speed: %{speed_download}|total: %{time_total}, %{time_namelookup}, %{time_connect}, %{time_appconnect}, %{time_pretransfer}, %{time_redirect},%{time_starttransfer}' \
-s -o /dev/null -v "$@" 2>&1 | \
grep -E 'X-Trans-Id|total|Date:' | \
@charz
charz / swift-expired-status
Last active October 5, 2020 08:43 — forked from clayg/swift-expired-status
check on the expirer queue
#!/usr/bin/env python
from collections import defaultdict
import sys
import time
import socket
from argparse import ArgumentParser
from swift.common.internal_client import InternalClient
from swift.common.utils import Timestamp
from swift.common.wsgi import ConfigString
import hashlib
import sys
def etag_checksum_s3(filename, chunk_size=6 * 1024 * 1024):
md5s = []
with open(filename, 'rb') as f:
for data in iter(lambda: f.read(chunk_size), b''):
md5s.append(hashlib.md5(data).digest())
print("s3api segment(hex): %s"% hashlib.md5(data).hexdigest())
@charz
charz / internal_logs.py
Created February 14, 2018 02:51 — forked from clayg/internal_logs.py
dig around in internal logs account
#!/usr/bin/env python
import argparse
import logging
import sys
import thread
import threading
from Queue import Queue
from datetime import datetime, timedelta
@charz
charz / 1.fuel2 command
Last active November 4, 2016 10:10
Upgrade operational MOS 8.0 env to MOS 9.1
[root@fuel ~]# fuel2 env redeploy --noop 22
Deployment task with id 570 for the environment 22 has been started.
[root@fuel ~]# fuel2 task show 570
+------------+--------------------------------------+
| Field | Value |
+------------+--------------------------------------+
| id | 570 |
| uuid | 9da95690-6a0c-4061-8d72-2eebcf46f965 |
| status | running |
[root@fuel ~]# update-prepare prepare env 22
Warning: Permanently added '10.20.0.7' (ECDSA) to the list of known hosts.
W: Failed to fetch http://10.20.0.2:8080/mirrors/mos-repos/ubuntu/8.0/dists/mos8.0/main/binary-amd64/Packages 404 Not Found
W: Failed to fetch http://10.20.0.2:8080/mirrors/mos-repos/ubuntu/8.0/dists/mos8.0/restricted/binary-amd64/Packages 404 Not Found
W: Failed to fetch http://10.20.0.2:8080/mirrors/mos-repos/ubuntu/8.0/dists/mos8.0-security/main/binary-amd64/Packages 404 Not Found
W: Failed to fetch http://10.20.0.2:8080/mirrors/mos-repos/ubuntu/8.0/dists/mos8.0-security/restricted/binary-amd64/Packages 404 Not Found
@charz
charz / .bahs_profile
Created October 24, 2016 06:00
.ss_profile
if [ -f ~/.alias ]; then
. ~/.alias
fi
if [ -f ~/.prompt ]; then
. ~/.prompt
fi
if [ -f ~/.ss_profile ]; then
@charz
charz / s3etag.sh
Created August 30, 2016 04:25 — forked from emersonf/s3etag.sh
A Bash script to compute ETag values for S3 multipart uploads on OS X.
#!/bin/bash
if [ $# -ne 2 ]; then
echo "Usage: $0 file partSizeInMb";
exit 0;
fi
file=$1
if [ ! -f "$file" ]; then
$ dpkg -l |grep iotop
ii iotop 0.4.4-4 simple top-like I/O monitor
(test-iotop)$ python
Python 2.7.3 (default, Dec 18 2014, 19:10:20)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import iotop
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
#!/bin/bash
TOKEN=AUTH_tk025422bc77c24bd0b123661e610f6c0c
ACCOUNT=$1
CONTANER=$2
swift --os-auth-token ${TOKEN} --os-storage-url http://192.168.200.21/v1/AUTH_${ACCOUNT} stat
swift --os-auth-token ${TOKEN} --os-storage-url http://192.168.200.21/v1/AUTH_${ACCOUNT} stat "${CONTAINER}1" a1
echo
swift --os-auth-token ${TOKEN} --os-storage-url http://192.168.200.21/v1/AUTH_${ACCOUNT} stat "${CONTAINER}2" a2