Skip to content

Instantly share code, notes, and snippets.

View szaydel's full-sized avatar

Sam Zaydel szaydel

  • RackTop Systems
  • Moss Beach
View GitHub Profile
@szaydel
szaydel / umask-setting-user.txt
Created February 17, 2016 14:17
AFP on OSX tuning system settings
It may be necessary at times to modify umask settings in order to allow for shared file access.
This sets the umask to 0022, but other variants are also possible, assuming it is a value unix umask value.
# sudo launchctl config user umask 022
#!/usr/sbin/dtrace -qCs
#define NT_STATUS_WRONG_PASSWORD 0xC000006A
#define NT_STATUS_LOGON_FAILURE 0xC000006D
BEGIN
{
printf("%-32s %s\n", "USER", "IP");
}
@szaydel
szaydel / acl_from_parent.sh
Last active February 16, 2024 21:26
[Data Migration and Cleanup Tools] Scripts for dealing with issues after migrating storage systems or switching to stricter protocols from less strict #tags: data migration, smb, cifs, samba, renaming, illegal characters, illegal names
#!/bin/sh
# MIT License
#
# Copyright (c) 2017 RackTop Systems / Sam Zaydel.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
@szaydel
szaydel / basic-sanity-validation-profile.fio
Last active February 7, 2024 15:14
[fio profiles] fio profiles for load generation, device or system stress and IO simulation/profiling #tags: fio, load, profiling, fio-load, load-gen, load generation, io, io profiling, filesystem, stress, io-load
; fio profile for basic sanity validation of configured system.
[global]
ioengine=solarisaio
; ioengine=linuxaio
; ioengine=libaio
; fsync=16
; rw=read
iodepth=16
; rw=randrw ; Random IO
@szaydel
szaydel / dummyprog.go
Created September 11, 2015 19:03
Access StdIn of Exec'd process with Golang
package main
import (
"fmt"
)
func main() {
fmt.Println("Hello, What's your favorite number?")
var i int
fmt.Scanf("%d\n", &i)
@szaydel
szaydel / measure-opens-and-closes.d
Last active March 5, 2023 15:54
Dtrace snippets for observing the syscall interaction.
dtrace -qn '
/* Result is a CSV with three columns:
1) path,
2) count of open(s) without matching close(s)
3) number of times opened*/
int self fd[int];
string self path;
BEGIN {
start = timestamp;
}
@szaydel
szaydel / blktrace.d
Last active March 3, 2023 16:43
[Dtrace snippets using io::: probes] One-liners and Scripts for observation at lower levels of the IO stack #tags: sd, io, io probes, stable probes, block device, dtrace, bandwidth, throughput, io errors, io retries
dtrace -qn '
BEGIN {
printf("timestamp(ns),latency(us),iotype,device,filename,blk.number,blk.count");
}
io:::start {
ts[args[0]->b_edev, args[0]->b_blkno] = timestamp;
}
io:::done /ts[args[0]->b_edev, args[0]->b_blkno] != 0/ {
this->lat_us = (timestamp - ts[args[0]->b_edev, args[0]->b_blkno])
/ 1000;
@szaydel
szaydel / socket-golang-example.md
Created August 28, 2014 13:25
Example of Creating Socket Server and Client using Go's Stdlib

Unix domain socket server and client There are three types of unix domain socket.

"unix" corresponds to SOCK_STREAM "unixdomain" corresponds to SOCK_DGRAM "unixpacket" corresponds to SOCK_SEQPACKET When you write a “unix” or “unixpacket” server, use ListenUnix().

 l, err := net.ListenUnix("unix",  &net.UnixAddr{"/tmp/unixdomain", "unix"})
@szaydel
szaydel / read-block-from-filesystem-and-disk.md
Last active November 15, 2022 16:07
[ZDB - ZFS debugger tool] Various snippets for working with zdb, the zfs debugger #tags: zdb, zfs, debugger, zfs-debug, bsros, illumos

The following steps allow one to either read data from L0 block directly or after converting DVA to physical device address, read data from device instead with dd.

We'll pretend that we have pool p03 with dataset path: p03/global/data0. We have a single file on this data0 dataset, called words. It is basically a list of words, the good'ol unix dictionary.

  1. Get information with zdb about dataset, we want to get list of indirect blocks.
# zdb -AA -ddddd p03/global/data0
...snip...
    Object  lvl   iblk   dblk  dsize  lsize   %full  type
        14    2   128K   128K  19.8M  19.8M  100.00  ZFS plain file
#!/usr/bin/env bash
runtime=60
interval=10
while getopts i:t: name; do
case $name in
i) interval="$OPTARG";;
t) runtime="$OPTARG";;
?) printf "Usage: %s: [-i <value>] [-t <value>]\n" "$0"