Skip to content

Instantly share code, notes, and snippets.

View retzkek's full-sized avatar

Kevin Retzke retzkek

View GitHub Profile
@retzkek
retzkek / openbsd.lisp
Last active July 27, 2023 21:42
OpenBSD pledge() and unveil() interface for Common Lisp (sbcl)
(defpackage :openbsd
(:use :cl :sb-alien)
(:export :pledge :unveil))
(in-package :openbsd)
(define-alien-routine "pledge" int
(promises c-string)
(execpromises c-string))
@retzkek
retzkek / chialog.mtail
Last active April 29, 2021 07:31
chia log mtail program
# start with harvester logs, e.g.
# 2021-04-24T11:01:53.390 harvester chia.harvester.harvester: INFO 1 plots were eligible for farming 940b588c2a... Found 0 proofs. Time: 0.98087 s. Total 19 plots
counter chia_harvester_blocks_total
gauge chia_harvester_plots_total
counter chia_harvester_plots_eligible
counter chia_harvester_proofs_total
histogram chia_harvester_search_time buckets 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 10
/^(?P<timestamp>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d+) harvester chia.harvester.harvester: \w+\s+ (?P<eligible_plots>\d+) plots were eligible for farming \w+\.\.\. Found (?P<proofs>\d+) proofs\. Time: (?P<search_time>[\d\.]+) s\. Total (?P<total_plots>\d+) plots$/ {
strptime($timestamp, "2006-01-02T15:04:05")
@retzkek
retzkek / gwms2graphite.py
Created September 29, 2017 17:00
GlideinWMS Monitoring
#!/usr/bin/python
import xml.etree.ElementTree as etree
import re
import urllib2
from optparse import OptionParser
import sys
def parse_gwms_xml(f, frontend_re=r'.*fifebatch_frontend$', edit_period='7200'):
tree = etree.parse(f)
@retzkek
retzkek / condor_probe.service
Created February 24, 2017 19:48
Fifemon systemd units
[Unit]
Description=Fifemon HTCondor Probe
Documentation=https://github.com/fifemon
Wants=network-online.target
After=network-online.target
[Service]
User=fifemon
Group=fifemon
Type=simple
@retzkek
retzkek / gratia-add-oim.py
Last active August 18, 2017 20:49
Gratia MasterSummaryData dump to GRACC
#!/bin/env python
"""
Add OIM information to Gratia summaries
"""
from argparse import ArgumentParser
import logging
import requests
import traceback
import time

Keybase proof

I hereby claim:

  • I am retzkek on github.
  • I am retzkek (https://keybase.io/retzkek) on keybase.
  • I have a public key ASDV5JaBjK3Q5Oo49LJZqNgeuEqzJsOqn0npd_RiGxTMZwo

To claim this, I am signing this object:

@retzkek
retzkek / graphite_mapping.conf
Last active September 9, 2016 22:27
Prometheus graphite_exporter mapping for Grafana internal metrics
grafana.*.api.dataproxy.request.*.count
name="grafana_api_proxy_requests"
instance="$1"
group="$2"
job="grafana"
grafana.*.api.dataproxy.request.*.min
name="grafana_api_proxy_request_duration_seconds_min"
instance="$1"
group="$2"
#!/usr/bin/env python
import re
import tabulate
from elasticsearch import Elasticsearch
groups = [
{'name':'GRACC (osg)', 'regex': r'gracc\.osg\.'},
{'name':'GRACC (osg) [OLD]', 'regex': r'gracc-osg-[12]'},
{'name':'GRACC (osg-transfer)', 'regex': r'gracc\.osg-transfer\.'},
@retzkek
retzkek / main.go
Created May 22, 2014 06:22
Basic EVE EMDR client in Go
package main
import (
"bytes"
"compress/zlib"
"encoding/json"
"fmt"
"github.com/alecthomas/gozmq"
"log"
"time"
@retzkek
retzkek / eratos-array.clj
Last active January 2, 2016 16:19
Sieve of Eratosthenes using Java array
(defn eratos-array
"Compute all primes below n using Sieve of Eratosthenes. Uses Java Boolean array of odds."
[n]
(let [array (boolean-array (-> n (quot 2) (dec)) true) ;; 0=3,1=5,2=7,...
n-to-i (fn [n] (-> n (- 3) (/ 2)))
i-to-n (fn [i] (+ i i 3))]
(loop [i 3]
(if (> (* i i) n)
(areduce array ii ret [2]
(if (aget array ii)