Skip to content

Instantly share code, notes, and snippets.

James Phillips slackpad

Block or report user

Report or block slackpad

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
slackpad / stack.txt
Created Nov 19, 2017
Full stack dump for hashicorp/consul issue #3700
View stack.txt
goroutine profile: total 1272
1131 @ 0x42d6ec 0x42d7de 0x43ed74 0x43e999 0x473b79 0xa287a1 0xf2a44f 0xf2f72d 0xf78b28 0xf72c65 0xf71685 0x684dc4 0x686580 0x687af4 0x683c9d 0x45ce61
# 0x43e998 sync.runtime_Semacquire+0x38 /goroot/src/runtime/sema.go:56
# 0x473b78 sync.(*RWMutex).RLock+0x48 /goroot/src/sync/rwmutex.go:50
# 0xa287a0*State).Stats+0x50 /gopath/src/
# 0xf2a44e*Agent).Stats+0x21e /gopath/src/
# 0xf2f72c*HTTPServer).AgentSelf+0x3ac /gopath/src/
# 0xf78b27*HTTPServer).AgentSelf-fm+0x47 /gopath/src/
# 0xf72c64*HTTPServer).wrap.func1+0x664 /gopath/src/
# 0xf71684 githu
slackpad / setrlimit.c
Created Nov 19, 2017
Increase fd rlimit for pid 18048
View setrlimit.c
#include <stdlib.h>
#include <sys/resource.h>
int main() {
struct rlimit limit;
limit.rlim_cur = 4096;
limit.rlim_max = 4096;
int ret;
ret = prlimit(18048, RLIMIT_NOFILE, &limit, NULL);
slackpad /
Last active Jul 18, 2019
Bootstrapping Consul Servers with Version 8 ACLs Enabled (v0.8.1)
slackpad / main.go
Created Feb 24, 2017
Consul ephemeral key example
View main.go
package main
import (
func main() {
client, err := api.NewClient(api.DefaultConfig())
View panic.txt
panic: in txn 802578 node leaf channel closed in 0
goroutine 52 [running]:
panic(0xee1140, 0xc454d24f40)
/usr/local/go/src/runtime/panic.go:500 +0x1a1*Txn).writeNode(0xc4533a4320, 0xc44eede460, 0xc42038d401, 0x1)
/root/go/src/ +0x5cb*Txn).delete(0xc4533a4320, 0xc44eede4b0, 0xc44eede460, 0xc454d24ecf, 0x0, 0x1, 0x1, 0x1)
/root/go/src/ +0x169*Txn).delete(0xc4533a4320, 0xc4533ddcc0, 0xc44eede4b0, 0xc454d24ecc, 0x3, 0x4, 0x1, 0x8)
slackpad / consul-dns-log.patch
Created Dec 19, 2016
Simple patch to add extra TRACE level logging for failed requests
View consul-dns-log.patch
diff --git a/command/agent/dns.go b/command/agent/dns.go
index 7f373cd4..9fa78b66 100644
--- a/command/agent/dns.go
+++ b/command/agent/dns.go
@@ -270,6 +270,9 @@ func (d *DNSServer) handleQuery(resp dns.ResponseWriter, req *dns.Msg) {
if err := resp.WriteMsg(m); err != nil {
d.logger.Printf("[WARN] dns: failed to respond: %v", err)
+ if m.MsgHdr.Rcode != 0 {
+ d.logger.Printf("[TRACE] dns: request for %v failed: rcode=%s", q, dns.RcodeToString[m.MsgHdr.Rcode])
View stats.json
"Config": {
"DevMode": true,
"Bootstrap": false,
"BootstrapExpect": 0,
"Server": true,
"Datacenter": "dc1",
"DataDir": "",
"DNSRecursor": "",
"DNSRecursors": [],
View wildcard.json
"Name": "",
"Template": {
"Type": "name_prefix_match"
"Service": {
"Service": "${name.full}",
"Failover": {
"NearestN": 3
slackpad /
Last active Mar 23, 2016
A bare-bones dead node notification system for Consul

Here's a basic watch script that will look through the output for serfHealth checks in the critical state. The serfHealth check is a built-in check added by Consul that keeps track of the health of a node. When this watch handler fires, it will get the JSON body of the health endpoint passed to it over stdin.

for node in $(jq '.[] | select(.CheckID=="serfHealth" and .Status=="critical") | .Node' -); do
    echo "$node is dead"
dig @ -p8600 nope.node.consul

; <<>> DiG 9.8.3-P1 <<>> @ -p8600 nope.node.consul
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 14084
;; flags: qr aa rd; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; WARNING: recursion requested but not available
You can’t perform that action at this time.