Skip to content

Instantly share code, notes, and snippets.

@seidler2547
seidler2547 / elastic.conf
Last active February 7, 2017 12:23
rsyslog to Elasticsearch
# monthly syslog indices
template(name="logstash-index"
type="list") {
constant(value="logstash-syslog-")
property(name="timereported" dateFormat="rfc3339" position.from="1" position.to="4")
constant(value=".")
property(name="timereported" dateFormat="rfc3339" position.from="6" position.to="7")
}
# most data we can get
@seidler2547
seidler2547 / curate.sh
Last active June 14, 2017 07:31
Elasticsearch sensible curator
#!/bin/bash
[ -f "$1" ] && . "$1"
[ "$2" ] && ACTION="$2"
[ "$2" ] && OPTIM=""
for ref in $(seq $MAX -1 $MIN)
do
IDX="${PREFIX}$(date -d @$(($(date +%s)-(${INTERVAL}*${ref}))) +${PATTERN})"
# change this to whatever you need
export DPI=165
# hardly useful
xrandr --dpi $DPI
# used by a couple of legacy applications
echo 'Xft.dpi: '$DPI | xrdb -merge -
# the point here is to increase the mouse cursor size - adjust to your preference
@seidler2547
seidler2547 / etc_network_interfaces
Created September 15, 2017 13:22
HAProxy as a IPv4 gateway for IPv6-only hosts with IPv4 NAT
[ ... ]
auto vmbr0
iface vmbr0 inet static
[ ... ]
post-up echo 1 > /proc/sys/net/ipv4/ip_nonlocal_bind
post-up iptables -t mangle -N DIVERT
post-up iptables -t mangle -A PREROUTING -p tcp -m socket -j DIVERT
post-up iptables -t mangle -A DIVERT -j MARK --set-mark 74
post-up iptables -t mangle -A DIVERT -j ACCEPT
@seidler2547
seidler2547 / Xresources
Created September 19, 2017 08:07
urxvt config
URxvt*scrollBar_right: True
URxvt*scrollBar_floating: True
URxvt*scrollWithBuffer: True
URxvt*scrollTtyKeypress: True
URxvt*scrollTtyOutput: False
URxvt*visualBell: True
URxvt*font: -*-fixed-medium-r-normal-*-13-*-*-*-*-70-iso10646-1
URxvt*boldFont: -*-fixed-bold-r-normal-*-13-*-*-*-*-70-iso10646-1
URxvt*background: black
URxvt*foreground: white smoke
@seidler2547
seidler2547 / _etc_network_interfaces
Created February 6, 2018 14:23
"Invisible" Bridge on Linux
auto vmbr1
iface vmbr1 inet manual
bridge_ports eth0
bridge_stp off
bridge_fd 0
up /sbin/sysctl -w net.ipv6.conf.$IFACE.disable_ipv6=1
up /sbin/sysctl -w net.ipv6.conf.$IFACE.autoconf=0
up /sbin/sysctl -w net.ipv6.conf.$IFACE.accept_ra=0
up ip link set dev $IFACE arp off
up ip link set dev eth0 arp off
@seidler2547
seidler2547 / convert_ha_sqlite2mysql.sh
Last active October 23, 2024 13:02
One-liner to convert an existing Home-Assistant SQLite database to MySQL
# prerequisites:
## install software
apt install mariadb-server libmariadbclient-dev sqlite3
## install mysqlclient in virtualenv
su -c 'homeassistant/bin/pip3 install mysqlclient --upgrade' -l homeassistant
## create database
mysql -e 'CREATE SCHEMA IF NOT EXISTS `hass_db` DEFAULT CHARACTER SET utf8'
## create user (use a safe password please)
mysql -e "CREATE USER 'hass_user'@'localhost' IDENTIFIED BY 'hass_pw'"
mysql -e "GRANT ALL PRIVILEGES ON hass_db.* TO 'hass_user'@'localhost'"
@seidler2547
seidler2547 / stopmotion.sh
Created January 5, 2019 21:29
Create a stop-motion MP4 from individual JPG files
#!/bin/bash
n=0; for i in * ; do mv $i $(printf '%04d\n' $n).jpg ; ((n++)); done
ffmpeg -y -f image2 -r ${1:-3} -i "%04d.jpg" -vf scale=-1:720 -c:v libx264 -crf 20 -preset slow -r 24 out.mp4
@seidler2547
seidler2547 / check_boot_kernel
Created August 30, 2019 10:32
Icinga 2 plugins
#!/usr/bin/env perl
my $currentkernel = `uname -r`;
chomp($currentkernel);
`ls -t1 /boot/vmlinuz-* | head -1` =~ q!^/boot/vmlinuz-(.+)$!;
my $latestkernel = $1;
chomp($latestkernel);
if ($currentkernel eq '' || $latestkernel eq '') {
print "UNKNOWN, could not determine kernel version, current=\"$currentkernel\", latest=\"$latestkernel.\"\n";
@seidler2547
seidler2547 / master.pp
Created April 16, 2020 08:37
Exchange SSH user and host keys using Puppet
class mybase::jenkins::master {
Sshkey <<| tag == 'jenkinsslave' |>>
}