Skip to content

Instantly share code, notes, and snippets.

View human39's full-sized avatar

human39

  • Pittsburgh, Pennsylvania
View GitHub Profile
https://www.simpleprecision.com/ubuntu-16-04-lxd-networking-simple-bridge/
@human39
human39 / openvpn-in-lxd.txt
Created October 16, 2018 16:21 — forked from wastrachan/openvpn-in-lxd.txt
OpenVPN in LXD Container
# On the host
=============
lxc config set openvpn raw.lxc 'lxc.cgroup.devices.allow = c 10:200 rwm'
lxc config device add openvpn tun unix-char path=/dev/net/tun
# In the container
==================
1. mknod /dev/net/tun c 10 200
ruby {
code => "event['_logstash_host'] = Socket.gethostname"
}
@human39
human39 / gist:8b80d51a75c99e64eb42
Last active October 17, 2019 14:26
Logstash split field solution.
Problem: We have a log line that includes a perl class that we want to log the class
and method in their respected fields. An example class and method in perl:
Animal::Dog::bark
In this example, "bark" is the method. "Animal::Dog" is the class.
After some searching and hacking, I found a solution that works with Logstash 1.4.2
Assume the input is "Animal::Dog::bark".
#!/usr/bin/perl
#
# Useful for making maps like the one at http://backspace.com/mapapp/javascript_world
#
use XML::TreeBuilder;
Shell + Perl one-liner to sort and show the sizes of your pwd.
du -k | sort -n | perl -ne 'if ( /^(\d+)\s+(.*$)/){$l=log($1+.1);$m=int($l/log(1024)); printf ("%6.1f\t%s\t%25s %s\n",($1/(2**(10*$m))),(("K","M","G","T","P")[$m]),"*"x (1.5*$l),$2);}'