Skip to content

Instantly share code, notes, and snippets.

@markuskont
markuskont / LLRB.js
Created June 6, 2016 15:02 — forked from hillar/LLRB.js
Left-leaning Red-Black Trees
// see Robert Sedgewick :: Left-leaning Red-Black Trees
const RED = true;
const BLACK = false;
var Node = function(key, value) {
this.key = key;
this.value = value;
this.color = RED;
this.N = 1;
@markuskont
markuskont / use_es_curator.sh
Created June 8, 2016 11:51
use ES curator to delete old indices
#!/bin/bash
# apt-get install python-pip
# pip install elasticsearch-curator
RETAINDAYS=14
INDICES=( suricata apache cee syslog samba logstash )
for i in "${INDICES[@]}"
do
echo "${i}"
for indice in `pcregrep --color -o1 '^\S+\s+\S+\s+(\S+)' indices.txt `; do
curl -ss -XPUT localhost:9200/$indice/_settings -d '
{
"index" : {
"number_of_replicas" : 0
}
}'
done
curl -ssk -XPUT localhost:9200/_cluster/settings -d '{
"transient" :{
"cluster.routing.allocation.exclude._name" : "node-8-es-01,node-9-es-01"
}
}'
#!/usr/bin/python
# A testing implementation of binary trees
# Very primitive (key = value, no duplicates, only integers)
# http://www.algolist.net/Data_structures/Binary_search_tree/Insertion
# http://stackoverflow.com/questions/2598437/how-to-implement-a-binary-tree-in-
class Node:
def __init__(self, val):
self.l = None
self.r = None
#!/usr/bin/env python
import sys
def openfile(argv):
with open(argv, 'r') as file:
lines = [line.rstrip('\n') for line in file]
return lines
PUPPET_TPL = """auditd::rule { "audit-rule-%(INDEX)s":
#!/usr/bin/env python
# A simple python playground for playing with top-k algorithms
# process data stream S and return most frequent K elements
# in my case, I create a unix socket and process syslog stream from syslog-ng
# syslog template only contains host, program and message; no timestamp
# as this is a naive implementation, with native python data structures (dictionaries)
# thus only useful for testing, not real data streams
import socket
import os, os.path
destination d_auditd {
file("/var/log/auditd.json" template("$(format-json .auditd.*)\n"));
};
parser p_auditd {
linux-audit-parser (prefix(".auditd."));
};
filter f_auditd {program("audispd")};
@markuskont
markuskont / datalvm.sls
Created October 3, 2016 10:53
Saltstack state files for deploying TICK stack
lvm2:
pkg.installed: []
/dev/sdb:
lvm.pv_present:
- require:
- pkg: lvm2
DATA:
lvm.vg_present:
[alerta]
# Configure Alerta.
enabled = true
# The Alerta URL.
url = "http://192.168.0.197:8080"
# Default authentication token.
token = ""
# Default environment.
environment = "Production"
# Default origin.