Skip to content

Instantly share code, notes, and snippets.

curl -fsSL https://install.determinate.systems/nix | sh -s -- install
bash -l
nix develop github:illustris/perfws
https://github.com/illustris/perfws
@illustris
illustris / biosnoop.bt
Created February 11, 2024 06:38
biosnoop with more details
#!/usr/bin/env bpftrace
/*
* biosnoop.bt Block I/O tracing tool, showing per I/O latency.
* For Linux, uses bpftrace, eBPF.
*
* TODO: switch to block tracepoints. Add offset and size columns.
*
* This is a bpftrace version of the bcc tool of the same name.
*
* 15-Nov-2017 Brendan Gregg Created this.
import sys
import functools
callstack = []
@functools.cache
def lookup(func):
try:
parts = func.split(":")
with open(parts[0]) as f:
@illustris
illustris / join_prom_metrics.md
Created August 25, 2022 14:52
Join prom metrics

Example metrics:

# HELP node_hwmon_sensor_label Label for given chip and sensor
# TYPE node_hwmon_sensor_label gauge
node_hwmon_sensor_label{chip="pci0000:00_0000:00:18_3",label="tccd1",sensor="temp3"} 1
node_hwmon_sensor_label{chip="pci0000:00_0000:00:18_3",label="tccd2",sensor="temp4"} 1
node_hwmon_sensor_label{chip="pci0000:00_0000:00:18_3",label="tccd3",sensor="temp5"} 1
node_hwmon_sensor_label{chip="pci0000:00_0000:00:18_3",label="tccd4",sensor="temp6"} 1
node_hwmon_sensor_label{chip="pci0000:00_0000:00:18_3",label="tccd5",sensor="temp7"} 1
node_hwmon_sensor_label{chip="pci0000:00_0000:00:18_3",label="tccd6",sensor="temp8"} 1
@illustris
illustris / easy_nixpkgs_testing.md
Created June 5, 2021 18:12
An easy way to test nixpkgs changes locally using nixos-container
[illustris@illustris-thinkpad:~/src/nixpkgs]$ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

[illustris@illustris-thinkpad:~/src/nixpkgs]$ git remote -v
origin  git@github.com:illustris/nixpkgs.git (fetch)
origin  git@github.com:illustris/nixpkgs.git (push)
@illustris
illustris / nix_cheat_sheet.md
Last active September 14, 2024 02:14
because I forget things

Nix

Get .drv for /etc/nixos/configuration.nix

nix-instantiate '<nixos>' -A system

Pretty print derivation

@illustris
illustris / freq.py
Created March 30, 2020 13:27
Quick script to count occurrences of terms in metrics
from collections import Counter
c = Counter()
for line in sys.stdin:
c.update(re.findall('.[^A-Z]*', line.split()[2].split('_')[2]))
print(c)
#define N 4
int *sort(int *arr, int len)
{
for(int i=0;i<len;i++)
{
for(int j=i+1;j<len;j++)
{
if(arr[i]>arr[j])
{
@illustris
illustris / emenu
Created December 16, 2019 14:15
dmenu + history
#!/bin/sh
cachedir=${XDG_CACHE_HOME:-"$HOME/.cache"}
histsize=50
if [ -d "$cachedir" ]; then
cache=$cachedir/emenu
hist=$cachedir/emenu_hist
else
cache=$HOME/.emenu_cache # if no xdg dir, fall back to dotfile in ~
hist=$HOME/.emenu_cache_hist # if no xdg dir, fall back to dotfile in ~
fi
@illustris
illustris / corss.sh
Last active December 5, 2019 06:30
get memory utilization of corosync
#!/bin/bash
print_usage() {
echo "$0 - Get memory utilization of corosync"
echo ""
echo "$0 [options]"
echo "Options:"
echo "-h, --help show help"
echo "-b, --byte print rss in bytes (could get printed in scientific notation)"
echo "-k, --kbyte print rss in bytes (could get printed in scientific notation)"