Skip to content

Instantly share code, notes, and snippets.

View goduncan's full-sized avatar

Duncan goduncan

View GitHub Profile

Keybase proof

I hereby claim:

  • I am goduncan on github.
  • I am dunc (https://keybase.io/dunc) on keybase.
  • I have a public key ASDoTaz6f56igrXRVzMiwfalr8hWRtcePMsMBGvOnGNKGQo

To claim this, I am signing this object:

@goduncan
goduncan / sumologic.service
Last active June 24, 2017 22:59
Example Sumo Logic systemd start-up script
[Unit]
Description=Sumo Logic Collector
[Service]
Type=forking
ExecStart=/usr/local/bin/startsumo.sh
ExecStop=/opt/SumoCollector/collector stop
# Give a reasonable amount of time for the server to start up/shut down
TimeoutSec=300
@goduncan
goduncan / startsumo.sh
Created June 24, 2017 22:57
Create a Sumo Logic collector's name from EC2 metadata
#!/bin/bash
az=$(curl -sfm1 http://169.254.169.254/latest/meta-data/placement/availability-zone)
instanceId=$(curl -sfm1 http://169.254.169.254/latest/meta-data/instance-id)
accountNo=$(curl -sfm1 http://169.254.169.254/latest/dynamic/instance-identity/document | jq -r '.accountId')
region=$(echo $az | sed 's/\w$//')
name="${instanceId}:${region}:${accountNo}"
# Check if we have set the name already
@goduncan
goduncan / create_flow_table.sql
Created January 8, 2017 12:34
Create New Flow Logs table
CREATE EXTERNAL TABLE IF NOT EXISTS goduncan.flow_logs (
src string,
spt int,
dst string,
dpt int,
proto int,
start_time bigint,
end_time bigint,
out_bytes bigint
)
import json
import gzip
import time
from StringIO import StringIO
import boto3
S3 = boto3.client('s3')