Skip to content

Instantly share code, notes, and snippets.

@sts
sts / apt
Created December 12, 2011 08:37
CheckMK APT Check v0.1
# 1 WARNING ; 2 CRITICAL
apt_repository_severity = {
'Debian-Security' : 2,
'debian-volatile' : 1,
'Unofficial' : 1
}
apt_cache_max_age = 3600
def inventory_apt(checkname, info):
@sts
sts / gist:1465973
Created December 12, 2011 08:42
CheckMK Apt Check Agent Plugin v0.1
#!/bin/bash
if [[ -e /etc/debian_version && `which apt-get` ]] &>/dev/null ; then
cache_time_ref=/var/cache/apt/pkgcache.bin
delta=0
# Only try to manually update the cache, if cron-apt is not installed.
if [[ `dpkg-query -W -f='${Status}\n' cron-apt` != "install ok installed" ]] &>/dev/null ; then
now=`date +%s`
@sts
sts / distance.js
Last active September 29, 2015 15:08
Javascript Implementation of Levenshtein's Distance Algorithm
/* (c) 2012, Stefan Schlesinger - http://sts.ono.at
*
* My first version of a Javascript Levenshtein distance implementation.
* http://en.wikipedia.org/wiki/Levenshtein_distance
*/
function unpack(str) {
var bytes = [];
for(var i = 0; i < str.length; i++) {
var char = str.charCodeAt(i);
@sts
sts / imager.rb
Created June 21, 2012 18:15
Middleman Imager
require 'base64'
require 'RMagick'
include Magick
module Imager
class << self
def registered(app)
app.send :include, InstanceMethods
app.ready do
@sts
sts / Directory Listening Created
Last active December 16, 2015 14:09
automunki-release.sh -- Build a munki release of build artifacts.
/Library/WebServer/Documents/munki -> /Library/WebServer/Documents/munki-releases/distribution-20130423195006
/Library/WebServer/Documents/munki-releases
/Library/WebServer/Documents/munki-releases/distribution-20130423195006/catalogs
/Library/WebServer/Documents/munki-releases/distribution-20130423195006/catalogs/all
/Library/WebServer/Documents/munki-releases/distribution-20130423195006/catalogs/testing
/Library/WebServer/Documents/munki-releases/distribution-20130423195006/manifests
/Library/WebServer/Documents/munki-releases/distribution-20130423195006/pkgs
/Library/WebServer/Documents/munki-releases/distribution-20130423195006/pkgs/jenkins
@sts
sts / classes.pp
Created October 14, 2013 19:27
Puppet: Is there a solution to avoid dependency on line #33?
class apt {
include apt::update
anchor { 'apt::update':
require => Class['apt::update']
}
}
class apt::update {
exec { 'aptitude_update':
@sts
sts / ipxe-bootstrap.txt
Last active December 26, 2015 16:59
ipxe-scripts
#!ipxe
chain http://boot.ono.at/ipxe?uuid=\${uuid}&mac=\${mac}&busid=\${busid}&ip=\${ip}&hostname=\${hostname:uristring}&serial=\${serial:uristring}&asset=\${asset:uristring}&manufacturer=\${manufacturer:uristring}&product=\${product:uristring}
@sts
sts / plugin.pp
Created December 2, 2013 18:55
checkmk::plugin
# Definition: checkmk::plugin
#
# Install a check_mk agent plugin on machine into the directroy:
# /usr/lib/check-mk-agent/plugins/
#
# Usage:
#
# The following will source the check-mk-agent plugin called 'puppet' from the
# puppet module puppet: puppet:///modules/puppet/checkmk/agent.plugin
#
@sts
sts / mrped
Created December 3, 2013 08:29
Check_MK use /etc/check_mk/mrpe.d instead of /etc/check_mk/mrpe.conf
#!/bin/bash
# MK's Remote Plugin Executor NG ;-)
#
# Workaround for check_mks inability to use scripts from a mrpe.d directory
# http://lists.mathias-kettner.de/pipermail/checkmk-en/2013-February/008646.html
#
# Make sure mrpe.cfg doesn't exist, or you will end up with two <<<mrpe>>>
# output sections.
#
@sts
sts / gist:4e664295d662a487bff5
Created May 4, 2014 12:37
RT Scrip: Autoreply to Whitelisted Domains + Mail Create
my @autoreplyDomains = qw(
example.com
);
my $transactionType = $self->TransactionObj->Type;
my $transactionContent = $self->TransactionOnj->Message->First;
my $ticketRequestor = lc($self->TicketObj->RequestorAddresses);
if ($transactionType eq 'Create' && $transactionContent) {