Skip to content

Instantly share code, notes, and snippets.

View mjf's full-sized avatar

Matouš Jan Fialka mjf

View GitHub Profile
@mjf
mjf / cpu_cycles_and_instructions_count.conf.toml
Last active June 24, 2022 10:33
Telegraf config to collect per-CPU cycles and instructions
# Telegraf configuration to collect per-CPU cycles and instructions
# using perf(1). You can then calculate CPI / IPC from the metrics.
# If Telegraf is not running as UID 0 (aka "root") you can either use
# sudo(1) with the perf(1) command, raise Telegraf capability, or set
# kernel.perf_event_paranoid = 0. But be warned: "Hic sunt dracones".
[[inputs.exec]]
name_prefix = "cpu_"
@mjf
mjf / telegraf_psi.conf.toml
Created June 23, 2022 07:04
Telegraf configuration to collect Pressure Stall Information (PSI)
# Telegraf configuration to collect Pressure Stall Information (PSI)
[[inputs.file]]
name_override = "pressure_cpu"
# interval = "5s"
files = ["/proc/pressure/cpu"]
data_format = "grok"
grok_patterns = [
"%{NOTSPACE:type:tag} avg10=%{NUMBER:avg10:float} avg60=%{NUMBER:avg60:float} avg300=%{NUMBER:avg300:float} total=%{NUMBER:total:int}"
]
@mjf
mjf / crockford-base32
Last active May 19, 2022 10:55
Encode and Decode Crockford's BASE32 in pure shell
#! /bin/sh
# Encode and decode Crockford's BASE32
# Copyright (C) 2022 Matous Jan Fialka, <https://mjf.cz/>
# Released under the terms of the "MIT" license
# DO NOT USE FOR ANY REASON! This was just for some quick testing.
use() {
printf -- '%s -d <enc> | <dec>\n' "${0##*/}"
@mjf
mjf / percentile_example.sql
Last active April 27, 2022 20:42
Postgres percentile calculation example
with
/* first generate random metric serie for past 1 day, 360 per hour */
series as
(
select
cast(
now() - '1 day'::interval + n*'10 seconds'::interval
as timestamp with time zone
),
n*random()::double precision
@mjf
mjf / Postgres blogs.md
Last active August 12, 2024 08:25
Postgres blogs to visit regularly
@mjf
mjf / mjf.vim
Created February 24, 2022 21:31
.vim/colors/mjf.vim
set background=dark
hi clear
if exists('syntax_on')
syntax reset
endif
let g:colors_name = 'mjf'
hi Normal ctermfg=250
@mjf
mjf / .lftprc
Last active January 12, 2022 07:13
LFTP RC file
set cmd:prompt '\U \S\n$ '
set ftp:port-range 21000-21999
set ftp:sync-mode off
set ssl:verify-certificate off
debug 4
alias ledit 'local edit'
alias lls 'local ls'
alias nocertverify 'set ssl:verify-certificate off'
@mjf
mjf / dip
Created December 6, 2021 10:30
DIP - Docker IP (petite tool to list container IP addresses)
#! /bin/sh
# DIP - Docker IP (petite tool to list container IP addresses)
# Copyright (C) 2021 Matous Jan Fialka, <https://mjf.cz>
# Released under the terms of the "MIT License"
printf -- '%-12s %-47s %-15s\n' 'CONTAINER ID' 'NAME' 'IP ADDRESS'
printf -- '------------ '
printf -- '----------------------------------------------- '
printf -- '---------------\n'
@mjf
mjf / pgbouncer_lookup.sql
Last active October 27, 2021 08:43
PgBouncer Lookup Function
-- Create login role, schema and security definer function for PgBouncer
-- Copyright (C) 2021 Matous Jan Fialka, <https://mjf.cz/>
-- Released under the terms of the "MIT License"
-- PER CLUSTER
CREATE ROLE
pgbouncer
WITH
LOGIN
@mjf
mjf / README.md
Last active October 8, 2021 09:15
Rclone server for Restic
cp [email protected] /etc/systemd/system
systemctl daemon-reload
systemctl enable [email protected]
cp rclone@restic /etc/sysconfig
vi /etc/sysconfig/rclone@restic
systemctl start rclone@restic
journalctl -xefurclone@restic