Skip to content

Instantly share code, notes, and snippets.

View saliceti's full-sized avatar
🐌

Colin Saliceti saliceti

🐌
  • Department for Education
View GitHub Profile
@saliceti
saliceti / logsearch_logstash.conf
Created May 10, 2017 15:54
Minimal logsearch logstash config
# The # character at the beginning of a line indicates a comment. Use
# comments to describe your configuration.
input {
file {
path => "/Users/colin/Documents/Boulot/gds/logstash/nginx_access.log"
start_position => "beginning"
}
}
@saliceti
saliceti / uaa_list_users.rb
Last active April 5, 2017 14:12
UAA script to list users
#!/usr/bin/env ruby
# Configuration
# export TARGET="https://uaa.<SYSTEM DOMAIN>"
# export UAA_CLIENT_USERNAME=admin
# export UAA_CLIENT_PASSWORD=xxx # uaa_admin_client_secret
# export SKIP_SSL_VALIDATION=true
# Uncomment and edit queries below
@saliceti
saliceti / create-token-role.sh
Created January 5, 2017 16:48 — forked from keymon/create-token-role.sh
Get temporary credentials from AWS using a MFA token, also assuming role: you can assume a role ⁠⁠⁠⁠./create-token-role.sh elasticache-broker-spike-role⁠⁠⁠⁠ or create new tokens for yourself ⁠⁠⁠⁠./create-token-role.sh me 900⁠⁠⁠⁠
#!/bin/bash
SCRIPT_NAME="$0"
usage() {
cat <<EOF
Creates a set of tokens assuming the given role. Use "me" as role to simply generate a new session token for your user.
Usage:
$SCRIPT_NAME <role name> [duration in seconds]
require 'loggregator_emitter'
require 'net/http'
require 'json'
nats_ip = '10.0.16.11'
nats_monitor_port = 4333
metron_port = 3457
@http = Net::HTTP.new(nats_ip, nats_monitor_port)
@get_varz = Net::HTTP::Get.new('/varz')
@saliceti
saliceti / usage.rb
Last active September 23, 2016 15:56
CF usage
#!/usr/bin/env ruby
require 'json'
orgs = JSON.load(`cf curl /v2/organizations`)["resources"]
quotas = JSON.load(`cf curl /v2/quota_definitions`)["resources"]
orgs_reserved_memory = 0
apps_reserved_memory = 0
allocated_services = 0
#!/bin/sh
set -eu
NAME=$1
UAA_ENDPOINT=https://...
UAA_ADMIN_CLIENT_PASS=xxxxx
PASSWORD=test
echo "Creating user ${NAME}"
uaac --trace target "${UAA_ENDPOINT}"
@saliceti
saliceti / process.sh
Created February 10, 2016 12:54
Flow log data workflow
#!/bin/bash
dirs=$@
base_dir=$(pwd)
rm -rf merged
mkdir merged
for dir in ${dirs}; do
echo Processing ${dir}...
@saliceti
saliceti / flow-logs.sh
Last active February 10, 2016 18:09
Capture TCP connections
#!/bin/bash
set -x
GATEWAY=52.48.251.177
TMP_DIR=/tmp/flow_log
VM_LIST_FILE=${TMP_DIR}/vm_list.txt
IPTABLES_INSTALL_OUTPUT="iptables -A OUTPUT -m state --state NEW -j LOG --log-prefix '[flow-logs-output] '"
IPTABLES_INSTALL_INPUT="iptables -A INPUT -m state --state NEW -j LOG --log-prefix '[flow-logs-input] '"
IPTABLES_REMOVE_OUTPUT="iptables -D OUTPUT -m state --state NEW -j LOG --log-prefix '[flow-logs-output] '"
IPTABLES_REMOVE_INPUT="iptables -D INPUT -m state --state NEW -j LOG --log-prefix '[flow-logs-input] '"
@saliceti
saliceti / pre-commit
Last active March 12, 2021 18:38
Git pre-commit hook to check for AWS keys
#!/usr/bin/env bash
# Install globally using https://coderwall.com/p/jp7d5q/create-a-global-git-commit-hook
# The checks are simple and can give false positives. Amend the hook in the specific repository.
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
@saliceti
saliceti / SampleOutput.md
Last active November 19, 2015 16:16
Parse and compare manifests
$ ruby scripts/diff.rb scripts/v224.yml scripts/v225.yml 
compilation.cloud_properties.availability_zone: __stub__eu-west-1a != __stub__eu-west-1b

compilation.cloud_properties.instance_type.c3.large: only in 1

compilation.network: only in 2

jobs.consul_z1.networks.cf1.static_ips.10.0.10.39: only in 1