Skip to content

Instantly share code, notes, and snippets.

@xchandan
xchandan / linux_reading_list.md
Created April 17, 2025 03:48 — forked from eenblam/linux_reading_list.md
Linux Networking Reading List

Linux Networking Reading List

Currently in no particular order. Most of these are kind of ancient.

Where's all the modern documentation? So much of what I've turned up searching is other folks complaining about having few options beyond reading source code.

The OREILLY books, while dated, seem to be some of the best available. Note that these can be read with a 7-day trial. Do this! At least get through the introduction section and first chapter of each to see if it's what you're after.

https://www.netfilter.org/

cat /dev/kmsg |awk '/invoked oom-killer/, /oom-kill:constraint/ {print}'
cat /proc/meminfo
cat /proc/stat
cat /proc/*/stat
cat /proc/vmstat
cat /proc/loadavg
cat /proc/net/netstat
cat /proc/mounts
cat /proc/diskstats
cat /proc/vmallocinfo
@xchandan
xchandan / mem-usage.sh
Last active May 10, 2024 17:51
mem-usage.sh
ps -eo pss|awk '{sum+=$1}END{print sum/1024**1}' &&\
ps -eo pid,rss|awk '!/PID/{if($2!=0){print $1}}'|xargs -I{} bash -c "pmap -X -p {}|awk 'END{print \$3}'"|awk '{sum+=$1}END{print sum/1024**1}' &&\
free -m
#20480K kernel code, 4270K rwdata, 13536K rodata, 4816K init, 17368K bss, 550384K reserved, 0K cma-reserved
#cat /var/log/dmesg|grep "Memory:"|sed 's/.*kernel: Memory:.*(\(.*\))$/\1/' |tr ',' '\n'|sed 's/K .*$//g'|awk '{sum+=$0}END{print sum/1024}'
#slabtop -o|awk '/Total Size/{print $(NF-1)}'
#!/usr/bin/python3
#https://github.com/Jin-Yang/examples/blob/master/linux/memory/pagemap/pagemap.py
import sys
import os
import binascii
import struct
def read_entry(path, offset, size=8):
@xchandan
xchandan / gist:b25ef1a56643c17c272581838f026b58
Last active April 22, 2024 16:45
kubernetes-user-creation.txt
openssl genpkey -out chandan.key -algorithm Ed25519
cat chandan.key
openssl req -new -key chandan.key -out chandan.csr -subj "/CN=chandan/O=edit"
creq=$(cat chandan.csr | base64 | tr -d "\n")
cat <<EOF | kubectl apply -f -
apiVersion: certificates.k8s.io/v1
kind: CertificateSigningRequest
metadata:
name: chandan
@xchandan
xchandan / aproducer.py
Created September 20, 2023 11:46 — forked from dabeaz/aproducer.py
"Build Your Own Async" Workshop - PyCon India - October 14, 2019 - https://www.youtube.com/watch?v=Y4Gt3Xjd7G8
# aproducer.py
#
# Async Producer-consumer problem.
# Challenge: How to implement the same functionality, but no threads.
import time
from collections import deque
import heapq
class Scheduler:
@xchandan
xchandan / README.md
Created September 9, 2023 12:42 — forked from nitaku/README.md
Minimal JSON HTTP server in python

A minimal HTTP server in python. It sends a JSON Hello World for GET requests, and echoes back JSON for POST requests.

python server.py 8009
Starting httpd on port 8009...
curl http://localhost:8009
{"received": "ok", "hello": "world"}
@xchandan
xchandan / guestlib.py
Created September 4, 2023 15:25 — forked from SegFaultAX/guestlib.py
vmGuestLib [Python] [ctypes]
from ctypes import CDLL, c_void_p, byref
from ctypes.util import find_library
# The following code fails on ubuntu 18.04, but succeeds on 14.04
lib = CDLL(find_library('guestlib'))
handle = c_void_p()
ret = lib.VMGuestLib_OpenHandle(byref(handle))
if ret != 0:
raise RuntimeError("failed to get handle")
@xchandan
xchandan / selfsigned.py
Last active June 19, 2023 03:01 — forked from bloodearnest/selfsigned.py
Create a self-signed x509 certificate with python cryptography library
# Copyright 2018 Simon Davy
#
# 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
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in