Skip to content

Instantly share code, notes, and snippets.

View cgswong's full-sized avatar

Stuart Wong cgswong

View GitHub Profile
@cgswong
cgswong / aws-cfn.sh
Created July 7, 2016 13:35
Setup CentOS server with AWS CFN bootstrap
#!/bin/bash
# Setup CentOS 7 host as AMI
# Update base OS update, and install EPEL repo and Python Pip
sudo yum -y update
sudo yum –y install epel-release
sudo yum -y install python-pip
# Install Python add-ons:
sudo pip install pystache
1. Find ID of container to move
`docker ps -a` or `docker images`
2. Save container as new image:
`docker save [newimage] | gzip > /tmp/docker-[newimage].tar.gz`
3. Copy file, `/tmp/docker-[newimage].tar.gz`, to destination and gunzip
4. Load new image:
`docker load --input docker-[newimage].tar`
@cgswong
cgswong / coreid.sh
Last active August 29, 2015 14:24
Get AWS AMI ID for CoreOS channels
#!/bin/bash
# CoreOS channel ["stable" | "beta" | "alpha"]
channel=${1:-"alpha"}
# AWS AMI disk backing ["pv" | "hvm"]
disk=hvm
# Use default us-east-1 region
region=${2:-"us-east-1"}
@cgswong
cgswong / bootstrap_marathon.sh
Created June 29, 2015 15:47
Marathon startup
#!/bin/bash
# Set locale: this is required by the standard Mesos startup scripts
echo "info: Setting locale to en_US.UTF-8..."
locale-gen en_US.UTF-8 > /dev/null 2>&1
# Start syslog if not started....
echo "info: Starting syslog..."
service rsyslog start > /dev/null 2>&1
@cgswong
cgswong / logstash-msg.conf
Last active August 29, 2015 14:23
Logstash message queue config
# #####################################################################
# DESC: Logstash configuration file. Typically forwarding logs to
# Elasticsearch instance.
# #####################################################################
# Where to get input
input {
# Get input from Redis queue
redis {
data_type => "list"
@cgswong
cgswong / logstash-http.conf
Created June 16, 2015 17:50
Logstash web log configuration
# #####################################################################
# DESC: Logstash configuration file. Typically forwarding logs to
# Elasticsearch instance.
# #####################################################################
# Where to get input
input {
# Get input from Apache logs
file {
type => "apache-access"
@cgswong
cgswong / logstash-syslog-filter.conf
Last active December 18, 2021 20:30
Logstash syslog parser
# syslog/relp
grok {
match => { "@message" => "(?:%{INT:syslog6587_msglen} )?<%{POSINT:syslog_pri}>(?:%{NONNEGINT:syslog5424_ver} )?(?:%{SYSLOGTIMESTAMP:syslog_timestamp}|%{TIMESTAMP_ISO8601:syslog_timestamp}) %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?(:)? %{GREEDYDATA:syslog_message}" }
add_field => [ "received_at", "%{@timestamp}" ]
add_field => [ "received_from", "%{host}" ]
add_tag => [ "syslog_standard" ]
tag_on_failure => ["_grokparsefailure-syslog_standard"]
}
@cgswong
cgswong / docker-cleaner.py
Created May 20, 2015 16:43
docker cleaner
#!/usr/bin/env python3
# Copyright 2015 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@cgswong
cgswong / docker-cleaner.sh
Created May 20, 2015 16:42
Docker container cleanup
#! /bin/bash
echo "Removing exited docker containers..."
docker rm -v $(docker ps -a -f status=exited -q)
echo "Removing untagged images..."
docker rmi $(docker images --no-trunc | grep "<none>" | awk '{print $3}')
echo "Removing unused docker images"
images=($(docker images | awk '{print $1":"$2}'))
@cgswong
cgswong / kibana.conf
Created May 20, 2015 16:20
nginx configuration for Kibana 4
upstream kibana {
server 127.0.0.1:5601 fail_timeout=0;
}
server {
listen 80;
return 301 https://example.com;
}
server {