IT notes

galera SOS

Check status of cluster: https://nbari.com/post/galera/ Find process list not sleeping: SELECT user, time, state, info FROM information_schema.processlist WHERE command != 'Sleep' AND time >= 2 ORDER BY time DESC, id; Get locked tables: show open tables where in_use > 0; Finding locks: show engine innodb status; At the end: ---TRANSACTION 1135701157, ACTIVE 6768 sec MySQL thread id 5208136, OS thread handle 0x7f2982e91700, query id 882213399 xxxIPxxx 82.235.36.49 my_user cleaning up kill the transaction thread:

pigz

To compress using gzip format but using all your available cores: tar --use-compress-program=pigz -cf archive.tgz /path/to/source Or if you want to pipe it: tar -cf - source | pigz > archive.tgz To decompress use tar -xvf archive.tgz as usual. The output of pigz is compatible with gzip

zsh

Edit environment variables: vared PATH Diff command output creating temporary normal files vimdiff =(ls /bin) =(ls /usr/bin) Print path print -l $path Run a command detached &! or &| put it in background and disown the process, exiting the shell will leave it running: sleep 300 &!

Google Cloud Functions

Testing Google Cloud Functions using go with an average of 250 requests/second. Cost per day close to $10USD Request per day: 23,511,849 Errors: 0 memory usage: 10.4MB execution time: 55.04ms

ssh wireshark

To analyze traffic remotely over ssh: ssh [email protected] sudo tcpdump -U -s0 -i pflog0 -w -| wireshark -k -i - In case need an specific port: ssh [email protected] sudo tcpdump -U -s0 -i pflog0 -w - 'port 5984' | wireshark -k -i - To ignore trafic from ssh: ssh [email protected] sudo tcpdump -U -s0 -i pflog0 -w - 'not port 22' | wireshark -k -i -

ELK delete_by_query

To delete indexes older than X days: POST haproxy/_delete_by_query { "query": { "range": { "ISODATE": { "lt": "now-3d" } } } }

openssl SHA1 HMAC

To create an HMAC-SHA1: $ echo -n "string" | openssl sha1 -hmac "shared_secret" or $ echo -n "string" | openssl dgst -sha1 -hmac "shared_secret"

DoH Firefox

Open firefox and type: about:config Search for: network.trr.uri Probably you already have: https://mozilla.cloudflare-dns.com/dns-query If not add it or use something like: https://cloudflare-dns.com/dns-query https://dns.quad9.net/dns-query Then enable network.trr.mode by setting it to 2 Set network.trr.mode to 2 make DNS Over HTTPS the browser’s first choice but use regular DNS as a fallback (0 is “off by default”, 1 lets Firefox pick whichever is faster, 3 for TRR only mode, 5 to explicitly turn it off).

osascript

In macOS, to find a path of an application, for example Chromium: $ osascript -e 'POSIX path of (path to application "Chromium")'

Galera

To periodically check status of the cluster, create a script (/tmp/xx): #!/bin/sh mysql --defaults-file=/path/to/.my.cnf -s -e \ "SHOW GLOBAL STATUS WHERE Variable_name IN ('wsrep_ready', 'wsrep_cluster_size', 'wsrep_cluster_status', 'wsrep_connected', 'wsrep_local_state', 'wsrep_local_index');" And run it with: watch sh /tmp/xx If single node alive (ERROR 1047 WSREP has not yet prepared node for application use): SET GLOBAL wsrep_provider_options='pc.bootstrap=YES'; This node can be used now has the new master so others nodes can recover from it.