Instantly share code, notes, and snippets.

View gist:85ab9ff0cb4f61394b7796e429ca25dc
slack = `
{{- $attachments := makeSlice -}}
{{- /* Set some slack properties on the attachment */ -}}
{{- $fallback := printf "Alert on %v" .Alert.Vars.url_host -}}
{{- $title := printf "%v: HTTPUnit Check for %v returned error(s)" .Last.Status .Alert.Vars.url_host -}}
{{- $ts := .LastAbnormalTime.Unix -}}
{{- $color := "good" -}}
{{- if .Last.Status.IsWarning -}}
{{- $color = "warning" -}}
View ghook.go
package main
import (
"fmt"
"log"
"os"
"path/filepath"
"<replaceme>/bogit/util"
)
View docker.sh
docker run -d -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:5.5.3 && docker run -d -p 5601:5601 --net=host -e "ELASTICSEARCH_URL=http://localhost:9200" docker.elastic.co/kibana/kibana:5.5.3
View linelrforecastlr.txt
# Only works for single result in series due to ungroup()
$q = q("sum:hbase.region.percentFilesLocal{host=literal_or(co-tsdb05)}", "20m", "")
$to100 = tod(ungroup(forecastlr($q, 100)))
$line = linelr($q, $to100)
merge($q, $line)
View kernel.txt
Apr 18 09:11:11 kbrandtlx kernel: perf: interrupt took too long (4966 > 4957), lowering kernel.perf_event_max_sample_rate to 40250
Apr 18 13:29:38 kbrandtlx kernel: pciehp 0000:00:03.0:pcie004: Slot(5-3): Link Down
Apr 18 13:29:38 kbrandtlx kernel: pcieport 0000:00:03.0: AER: Multiple Uncorrected (Fatal) error received: id=0018
Apr 18 13:29:38 kbrandtlx kernel: pcieport 0000:00:03.0: PCIe Bus Error: severity=Uncorrected (Fatal), type=Transaction Layer, id=0018(Requester ID)
Apr 18 13:29:38 kbrandtlx kernel: pcieport 0000:00:03.0: device [8086:0e08] error status/mask=00004020/00000000
Apr 18 13:29:38 kbrandtlx kernel: pcieport 0000:00:03.0: [ 5] Surprise Down Error (First)
Apr 18 13:29:38 kbrandtlx kernel: pcieport 0000:00:03.0: [14] Completion Timeout
Apr 18 13:29:38 kbrandtlx kernel: pcieport 0000:00:03.0: broadcast error_detected message
Apr 18 13:29:38 kbrandtlx kernel: radeon 0000:06:00.0: device has no AER-aware driver
Apr 18 13:29:38 kbrandtlx kernel: snd_hda_intel 0000:06:00.1: device ha
View limb.go
package main
import (
"fmt"
"math/bits"
"sort"
)
type Limb byte
View gist:536300a5b1d6208394b264736ed76612
template network.nexus.portchannel.bad {
subject = {{.Last.Status}}: {{.Eval .Alert.Vars.upDownByHost | printf "%.f" }} down Port-Channels on {{.Group.host}}
body = `{{ template "header" . }}
{{/* source is http://www.net-snmp.org/docs/mibs/interfaces.html . Oper and Admin are actually different in that Admin only includes up/down/testing. However, 1, 2, 3 of Oper status is the same as the first 3 of admin status, so the same map can be used */}}
{{ $statusReference := makeMap "1" "up" "2" "down" "3" "testing" "4" "unknown" "5" "dormat" "6" "not present" "7" "lowerLayerDown" }}
{{ $joinResult := .LeftJoin .Alert.Vars.adminUpAndOperDown .Alert.Vars.operStatus .Alert.Vars.adminStatus }}
{{ if notNil $joinResult }}
<h2>Port-Channels with Non-Healthy Status</h2>
View example.txt
alert host.down {
template = host.down
macro = host.based.contacts
macro = host.generic_info
$notes = Both ny-bosun01 and co-tsdb01 have to agree a host is down
$unit_string = Bosun ping timeout
$query_string = "sum:bosun.ping.timeout{dst_host=*,host=ny-bosun01|co-tsdb01}"
$last_two = sum(t(min(rename(q($query_string, "2m", ""), "host=source,dst_host=host")), "host"))
$previous_four = sum(t(min(rename(q($query_string, "5m", "1m"), "host=source,dst_host=host")), "host"))
$five_to_seven = sum(t(max(rename(q($query_string, "7m", "5m"), "host=source,dst_host=host")), "host"))
View _.xkb_symbols_local
partial modifier_keys
xkb_symbols "kycracra" {
modifier_map Mod3 { Super_L, Super_R };
key <SUPR> { [ NoSymbol, Super_L ] };
modifier_map Mod3 { <SUPR> };
key <HYPR> { [ NoSymbol, Hyper_L ] };
modifier_map Mod4 { <HYPR> };
View Overview
Based on the idea in this SO answer: http://stackoverflow.com/a/30037886/107156
1) Create a ruby file to contain the variables
2) when running erb, important that file as a library
Notes:
- The .rb file must have all variables that you call methods on (i.e. `any?`) or you will get a nilClass error.
- The switch to -r doesn't have the .rb extension on it, but the file does