Skip to content

Instantly share code, notes, and snippets.

#include <event2/event.h>
#include <event2/thread.h>
#include <event2/util.h>
#include <stdlib.h>
#include <pthread.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#!/usr/bin/env bash
for i in {1..8}; do
truncate -s10m loop-$i
losetup /dev/loop$i loop-$i
done
mdadm -CR /dev/md0 --metadata 1.1 --level raid10 --raid-disks 4 /dev/loop{1..4}
# recovery
sleep 1m
@azat
azat / nfs-estale.sh
Created March 4, 2018 13:19
nfs-estale.sh
#!/usr/bin/env bash
head -c100M /dev/zero > /tmp/zero
cp /tmp/zero /srv/nfs4/zero
exec 3</mnt/nfs4/zero
exportfs -f
rpc.nfsd 0
exportfs -r
#!/usr/bin/env python3
import sys
import re
"""
Decode kernel message from mpt*sas, like:
mpt3sas_cm0: log_info(0x31120303): originator(PL), code(0x12), sub_code(0x0303)
mpt2sas_cm0: log_info(0x31120303): originator(PL), code(0x12), sub_code(0x0303)
#!/usr/bin/env bash
function match()
{
local f="$1" && shift
[[ "$f" =~ [^/]*\.conf$ ]] && {
local o=(
'^cert '
'^key '
'^tls-auth '
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <event2/event.h>
#include <event2/thread.h>
void
cb( evutil_socket_t fd, short what, void *arg )
{
#!/usr/bin/env python3
import sys, os, time
import subprocess
import argparse
import re
def exec(cmd):
return subprocess.check_output(cmd)
#!/usr/bin/env bash
function usage()
{
cat - <<EOL
Get DIMM Bank Locator (via dmidecode) by ADDR from mcelog
(tested with dmidecode 3.1)
Usage: $0 <addr>
EOL
gettimeofday(): 53.7 *1e6 # vdso
getpid(): 15.4 *1e6 # non-vdso
3.5x time slower
// https://github.com/libevent/libevent/issues/674#issuecomment-409853793
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <unistd.h>
#include <inttypes.h>
#include <sys/types.h>
#include <sys/socket.h>