Skip to content

Instantly share code, notes, and snippets.

@kormat
kormat / .vimrc
Last active March 22, 2016 20:45
set nocompatible
" ======================
" Terminal setup
" ======================
if &term =~ "^screen"
" pretend this is xterm. it probably is anyway, but if term is left as
" `screen`, vim doesn't understand ctrl-arrow.
if &term == "screen-256color"
try:
1/0
except:
handler.handleError("hi")
#!/bin/bash
set -e
COLOR=$(tput setaf 12)
RESET=$(tput sgr0)
log() {
echo "$COLOR=======> $@ $RESET"
}
@kormat
kormat / mtail-ebnf.txt
Last active April 18, 2016 21:19
EBNF description of mtail language
<statement> ::= <conditional statement>
| <expression statement>
| <declaration>
| <definition>
| <decoration statement>
| "next"
| "const", name, <pattern expression>
<conditional statement> ::= <cond> <compound statement>
Metrics store:[
{
"Name": "count",
"Program": "otherwise.mtail",
"Kind": 1,
"Keys": [
"num"
],
"LabelValues": [
{

Introduction

As mtail is designed to tail log files and apply regular expressions to new log lines to extract data, the language naturally follows this pattern-action style.

It resembles another, more famous pattern-action language, that of AWK.

Details

mtail runs all programs on every line received by the log tailing subsystem. The rough model of this looks like:

t=2016-08-08T14:55:21+0000 lvl=crit msg=Panic stack=
> goroutine 1 [running]:
> runtime/debug.Stack(0x0, 0x0, 0x0)
> /usr/lib/go-1.6/src/runtime/debug/stack.go:24 +0x80
> <...>/log.PanicLog()
> /<...>/log.go:102 +0x68
> panic(0x51cd80, 0xc82000ad00)
> /usr/lib/go-1.6/src/runtime/panic.go:426 +0x4e9
> main.main()
> /<...>/test.go:22 +0x4d0
@kormat
kormat / godeps.py
Last active August 12, 2016 12:39
# Small script to automate finding all external dependencies of a Go directory
# Example use:
# go get -v $(godeps.py)
import json
import subprocess
def main():
top = subprocess.check_output(["go", "list", "-e"],
$ git diff
diff --git a/lib/librte_eal/linuxapp/kni/Makefile b/lib/librte_eal/linuxapp/kni/Makefile
index 8cc6b61..5d9e286 100644
--- a/lib/librte_eal/linuxapp/kni/Makefile
+++ b/lib/librte_eal/linuxapp/kni/Makefile
@@ -50,6 +50,7 @@ UBUNTU_KERNEL_CODE := $(shell echo `grep UTS_RELEASE $(RTE_KERNELDIR)/include/ge
| cut -d '"' -f2 | cut -d- -f1,2 | tr .- ,`,1)
MODULE_CFLAGS += -D"UBUNTU_KERNEL_CODE=UBUNTU_KERNEL_VERSION($(UBUNTU_KERNEL_CODE))"
endif
+MODULE_CFLAGS += -DUBUNTU_RELEASE_CODE=1404 -D"UBUNTU_KERNEL_CODE=UBUNTU_KERNEL_VERSION(3,13,0,93,1)"
[83038.261427] KNI: /dev/kni closed
[83038.261451] BUG: unable to handle kernel NULL pointer dereference at 0000000000000200
[83038.261483] IP: [<ffffffffc00fe4b0>] uio_release+0x20/0x60 [uio]
[83038.261508] PGD 0
[83038.261517] Oops: 0000 [#1] SMP
[83038.261531] Modules linked in: nfnetlink_queue nfnetlink_log nfnetlink bluetooth bridge stp llc intel_rapl x86_pkg_temp_thermal intel_powerclamp coretemp kvm_intel kvm irqbypass crct10dif_pclmul crc32_pclmul ppdev aesni_intel aes_x86_64 snd_hda_codec_hdmi mei_me lrw parport_pc snd_hda_codec_realtek snd_hda_codec_generic snd_hda_intel snd_hda_codec snd_hda_core snd_hwdep snd_pcm snd_timer snd gf128mul parport mei soundcore glue_helper ablk_helper cryptd serio_raw 8250_fintek shpchp lpc_ich mac_hid rte_kni(OE) igb_uio(OE) uio autofs4 uas usb_storage i915 psmouse r8169 i2c_algo_bit mii drm_kms_helper ahci syscopyarea libahci sysfillrect e1000e sysimgblt fb_sys_fops ptp drm pps_core wmi fjes video
[83038.261804] CPU: 3 PID: 24444 Comm: border Tainted: G OE