Skip to content

Instantly share code, notes, and snippets.

View lsjostro's full-sized avatar
:shipit:

Lars Sjöström lsjostro

:shipit:
View GitHub Profile
#!/usr/bin/python
import sys
import time
import socket
import urllib2
def main(haproxy_host, statsd_host):
s = socket.socket(socket.AF_INET,
socket.SOCK_DGRAM)
@lsjostro
lsjostro / flume-logstash.py
Created March 14, 2014 18:58
multiline logstash to flumelogger
#!/usr/bin/python
import re
import time
import logging
from os import stat
from stat import ST_SIZE
from flumelogger.handler import FlumeHandler
FILE_INPUT = "/var/log/jenkins/jenkins.log"
MULTILINE_PATTERN_RE = r"^\w+ \d+, \d+ (\d+?:){1,2}\d\d \w\w "
@lsjostro
lsjostro / puppetdb_report.sh
Created June 3, 2014 13:25
puppetdb event report shell function
# req: brew/yum install jq on MacOS X/Linux (install in .bashrc or global profile.d/)
export PUPPETDB_HOST="my.puppetdb.host.foo"
function puppet_report { curl -sG http://$PUPPETDB_HOST/v3/events --data-urlencode "query=[\"and\", [\"=\", \"latest-report?\", true],[\"~\", \"certname\", \"^$1\"]]" | jq -r '.[] | .certname+","+.["resource-type"]+"["+.["resource-title"]+"]" + "," +.status + "," + .message' | column -t -s,; }
export -f puppet_report
def main():
options = parse_options()
db = Connection('localhost', 27017).pulp_database
rpms = db.units_rpm
repo_content_units = db.repo_content_units.find({'repo_id': options.repo_id})
units = {}
for unit in repo_content_units:
data = rpms.find_one({"_id": unit['unit_id']})
if data:
@lsjostro
lsjostro / changesets.groovy
Created April 20, 2016 08:33
Jenkinsfile: build only changed files
#!groovy
@NonCPS
def getACIChangeSets() {
def aci = []
currentBuild.rawBuild.getChangeSets().each { cs ->
cs.getItems().each { item ->
item.getAffectedFiles().each { f ->
if (f.path.endsWith(".yml")) {
aci << f.path
}
@lsjostro
lsjostro / rkt-in-rkt-issue.sh
Last active June 9, 2016 09:22
rkt in rkt issue
$ /usr/local/bin/rkt version
rkt Version: 1.7.0
appc Version: 0.8.4
Go Version: go1.6.1
Go OS/Arch: linux/amd64
Features: -TPM
# _Without_ bind mount of /var/lib/rkt
$ sudo /usr/local/bin/rkt run \
--insecure-options=image \
@lsjostro
lsjostro / docker-registry-caching-proxy.conf
Created March 14, 2017 21:34 — forked from etuttle/docker-registry-caching-proxy.conf
NGINX config for a caching proxy that sits in front of a docker registry
upstream docker-mirror-upstream {
server upstream.example.com;
}
proxy_cache_path /var/lib/docker-mirror/cache levels=1:2 max_size=10g inactive=48h keys_zone=cache:10m;
server {
listen 80 default_server;
listen 443 ssl default_server;
@lsjostro
lsjostro / oklog-stateful.yaml
Created May 9, 2017 08:21
oklog kubernetes
---
kind: Service
apiVersion: v1
metadata:
name: oklog
labels:
app: oklog
spec:
ports:
- name: api

Keybase proof

I hereby claim:

  • I am lsjostro on github.
  • I am lsjostrom (https://keybase.io/lsjostrom) on keybase.
  • I have a public key ASD29A_wPPLMnW1Gcrgg1l0EEm0IizunAtIK_YB63Mx4HQo

To claim this, I am signing this object:

@lsjostro
lsjostro / gitlab-runner.yaml
Created May 10, 2017 14:30
gitlab-runner k8s
kind: Role
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: gitlab-ci
namespace: gitlab
rules:
- apiGroups: ["*"]
resources: ["*"]
verbs: ["*"]