Skip to content

Instantly share code, notes, and snippets.


Mat Wood thepacketgeek

View GitHub Profile
View gist:6f00c7d2e2d9e4ba8df20b9adf214067
./telegraf --test --config /etc/telegraf/telegraf.conf --input-filter syslog --test-wait 15
2021-06-25T17:55:06Z I! Starting Telegraf
> syslog,appname=docker-compose,facility=daemon,host=bb8,hostname=droplet,location=home,severity=info,source= facility_code=3i,message="<redacted>",severity_code=6i,timestamp=1624643706396113000i,version=1i 1624643706400667198
> syslog,appname=tailscaled,facility=daemon,host=bb8,hostname=dev,location=home,severity=info,source= facility_code=3i,message="<redacted>",severity_code=6i,timestamp=1624643706403394000i,version=1i 1624643706407850408
> syslog,appname=docker-compose,facility=daemon,host=bb8,hostname=droplet,location=home,severity=info,source= facility_code=3i,message="<redacted>",severity_code=6i,timestamp=1624643706675853000i,version=1i 1624643706679251683
> syslog,appname=multipathd,facility=daemon,host=bb8,hostname=droplet,location=home,severity=info,source= facility_code=3i,message="<redacted>",severity_code=6i,timestamp=162464370
thepacketgeek / gist:24dc4665cc4045d730ca032ed4b8aaa1
Created Nov 24, 2020
Influx Query for showing delta of cumulative iface counts
View gist:24dc4665cc4045d730ca032ed4b8aaa1
non_negative_derivative(mean("ifHCInOctets"), 1s) * 8 AS "Rx",
non_negative_derivative(mean("ifHCOutOctets"), 1s) * 8 AS "Tx"
FROM "interface"
WHERE ("ifAlias" = 'Some if here')
AND $timeFilter GROUP BY time($__interval) fill(null)

Diving into Rust

If you're wanting to get involved with Rust projects and see what the magic is all about, here are some great starting points!


  • A Gentle Introduction
    • A little more focused on the main concepts, only takes an hour or so
  • The Book
    • This is the first and foremost (albiet most time consuming) way to get familiar
  • Py2Rs
View pcapng ->
extern crate pcarp;
use std::fs::File;
use std::io::{Cursor, Read};
use std::net::IpAddr;
use std::path::Path;
use std::result::Result;
use bgp_rs::{Header, Message, Reader};
use byteorder::{NetworkEndian, ReadBytesExt};
View gist:d7ff94bdce21fe073124fc3ec142a648
Update {
withdrawn_routes: [],
attributes: [
ASPath {
segments: []
thepacketgeek /
Created Jul 24, 2015
Convert Subnet Mask to CIDR length
def calc_mask_length(mask):
""" Convert subnet mask ( to CIDR mask length (/24) """
return sum([bin(int(x)).count('1') for x in mask.split('.')])
print calc_mask_length('')
# 24
#!/usr/bin/env python
## Tiny Syslog Server in Python.
## This is a tiny syslog server that is able to receive UDP based syslog
## entries on a specified port and save them to a file.
## That's it... it does nothing else...
## There are a few configuration parameters.
LOG_FILE = 'youlogfile.log'
import paramiko
import re
from time import sleep
# Router connection details (could be read in from file or argparse)
peer = ''
username = 'admin'
password = 'admin'
def collect_output(shell, command):
#!/usr/bin/env python
Very simple HTTP server in python.
./ [<port>]
Send a GET request::
curl http://localhost
from extensions import db
from celery import Celery
from flask import Flask
from config import config, SELECTED_CONFIG
def create_celery_app(app=None):
app = app or create_app()
celery = Celery(__name__, broker=app.config['CELERY_BROKER_URL'])
TaskBase = celery.Task