Skip to content

Instantly share code, notes, and snippets.

View Slach's full-sized avatar
💭
deep diving into kuberntes

Eugene Klimov Slach

💭
deep diving into kuberntes
View GitHub Profile
@edeNFed
edeNFed / profile
Last active September 9, 2020 04:01
BCC Profile with python type bug fixed
#!/usr/bin/python
# @lint-avoid-python-3-compatibility-imports
#
# profile Profile CPU usage by sampling stack traces at a timed interval.
# For Linux, uses BCC, BPF, perf_events. Embedded C.
#
# This is an efficient profiler, as stack traces are frequency counted in
# kernel context, rather than passing every stack to user space for frequency
# counting there. Only the unique stacks and counts are passed to user space
# at the end of the profile, greatly reducing the kernel<->user transfer.
@djfdyuruiry
djfdyuruiry / README.md
Last active April 28, 2024 08:34
WSL 2 - Enabling systemd

Enable systemd in WSL 2

NOTE: If you have Windows 11 there is now an official way to do this in WSL 2, use it if possible - see MS post here (WINDOWS 11 ONLY)

This guide will enable systemd to run as normal under WSL 2. This will enable services like microk8s, docker and many more to just work during a WSL session. Note: this was tested on Windows 10 Build 2004, running Ubuntu 20.04 LTS in WSL 2.

  • To enable systemd under WSL we require a tool called systemd-genie

  • Copy the contents of install-sg.sh to a new file /tmp/install-sg.sh:

package seriesList
import (
"fmt"
"math"
"strconv"
"github.com/go-graphite/carbonapi/expr/helper"
"github.com/go-graphite/carbonapi/expr/interfaces"
"github.com/go-graphite/carbonapi/expr/types"
@MarioHewardt
MarioHewardt / enable_ebpf_on_wsl2
Last active April 27, 2024 09:27
Enable EBPF on WSL2
By default, EBPF programs will not run on WSL2 due to required kernel modules missing. The following example error is an
indication of this problem:
modprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file '/lib/modules/4.19.84-microso
ft-standard/modules.dep.bin'
modprobe: FATAL: Module kheaders not found in directory /lib/modules/4.19.84-microsoft-standard
chdir(/lib/modules/4.19.84-microsoft-standard/build): No such file or directory
To fix this you need to rebuild the WSL2 kernel with the missing kernel modules. The below instructions are for Ubuntu 18.04 WSL2.
1. git clone https://github.com/microsoft/WSL2-Linux-Kernel.git
@narendrans
narendrans / Dockerfile
Last active September 15, 2020 19:26
Superset with Dremio ODBC on Centos7 Docker image
FROM centos:7
RUN yum install -y python3 python3-devel python3-pip unixODBC unixODBC-devel python3-setuptools gcc gcc-c++ https://download.dremio.com/odbc-driver/dremio-odbc-LATEST.x86_64.rpm && \
pip3 install apache-superset sqlalchemy_dremio && \
export LC_ALL=en_US.UTF-8 && \
superset db upgrade && \
superset init && \
export FLASK_APP=superset && \
flask fab create-admin --username admin --firstname admin --lastname admin --email admin@admin --password admin
@alexey-milovidov
alexey-milovidov / profile_example.txt
Created July 30, 2019 00:07
Example of query profiling.
SELECT
count(),
arrayStringConcat(arrayMap(x -> concat(demangle(addressToSymbol(x)), '\n ', addressToLine(x)), trace), '\n') AS sym
FROM system.trace_log
WHERE (query_id = 'ebca3574-ad0a-400a-9cbc-dca382f5998c') AND (event_date = today())
GROUP BY trace
ORDER BY count() DESC
LIMIT 10
Row 1:

Счётчики, метрики и трейспоинты в ClickHouse (черновик).

Мотивация

В ClickHouse разным образом реализовано некоторое количество функциональности, имеющей общие черты. Это:

  • метрики на основе инкрементальных счётчиков (ProfileEvents);
  • метрики на основе количества одновременных процессов (Metrics);
  • метрики на основе асинхронно получаемых значений (AsynchronousMetrics);
  • ограничения на сложность выполнения запроса (встроены в Settings);
  • прогресс выполнения запроса (Progress, отправляется клиенту);
@jjo
jjo / kubectl-root-in-host-nopriv.sh
Last active February 5, 2024 23:07
Yeah. Get a root shell at any Kubernetes *node* via `privileged: true` + `nsenter` sauce. PodSecurityPolicy will save us. DenyExecOnPrivileged didn't (kubectl-root-in-host-nopriv.sh exploits it)
#!/bin/sh
# Launch a Pod ab-using a hostPath mount to land on a Kubernetes node cluster as root
# without requiring `privileged: true`, in particular can abuse `DenyExecOnPrivileged`
# admission controller.
# Pod command in turn runs a privileged container using node's /var/run/docker.sock.
node=${1}
case "${node}" in
"")
nodeSelector=''
podName=${USER+${USER}-}docker-any
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active May 6, 2024 20:05
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@kanekv
kanekv / .gdbinit
Created May 2, 2017 04:27
.gdbinit
# -*- ksh -*-
#
# If you use the GNU debugger gdb to debug the Python C runtime, you
# might find some of the following commands useful. Copy this to your
# ~/.gdbinit file and it'll get loaded into gdb automatically when you
# start it up. Then, at the gdb prompt you can do things like:
#
# (gdb) pyo apyobjectptr
# <module 'foobar' (built-in)>
# refcounts: 1