Skip to content

Instantly share code, notes, and snippets.

View tomislacker's full-sized avatar

Ben Tomasik tomislacker

View GitHub Profile
@tomislacker
tomislacker / vmstat_monitor.sh
Last active May 18, 2017 14:47
vmstat_monitor
#!/bin/bash
###############################################################################
# vmstat_monitor.sh
#
# Options:
# $1 Delay, in seconds, between readings. Must be >0
# $2 Count of readings to take. This should always be 2
#
# If the VMSTAT_DEBUG variable is set non-empty, debug output of all values of
# variables will be outputed to stderr.
@tomislacker
tomislacker / Output
Created May 9, 2017 15:45 — forked from speshak/Output
Convert CIDR networks into string glob (like what ssh_config expects)
10.255.0.0/11
['10.224.*',
'10.225.*',
'10.226.*',
'10.227.*',
'10.228.*',
'10.229.*',
'10.230.*',
'10.231.*',
'10.232.*',
@tomislacker
tomislacker / find_iam_key.sh
Last active February 1, 2018 05:27
Find IAM Users from Access Key Id
#!/bin/bash
###############################################################################
# find_iam_key.sh <access key id>
# Searches through all IAM users to find out which soul decided NOT to use
# instance profiles, and instead embeded a key+secret pair in an EC2 instance.
###############################################################################
#############
# Functions #
@tomislacker
tomislacker / s3_website.md
Last active December 29, 2016 17:56
S3 Website Hosting Crashcourse

S3 Website Hosting Crashcourse

Procedure (Without an explicit domain)

In this case, your bucket name does not matter

  1. Create the bucket (I'll use myassets) as an example
  2. In the S3 interface, goto the bucket's Properties
  3. Under Permissions add a grantee: - Grantee: Everyone - Check only "View Permissions"
@tomislacker
tomislacker / aws_find_user_key.sh
Created August 25, 2016 18:27
Find AWS IAM Account a Key Belongs To
#!/bin/bash
get_keys_for_user ()
{
aws iam list-access-keys \
--user-name $@ \
| jq -r '.AccessKeyMetadata[].AccessKeyId'
}
get_all_users ()
@tomislacker
tomislacker / php-fpm_strace.sh
Created August 19, 2016 16:38
php-fpm strace all (or some) instances
#!/bin/bash
# Default number of seconds to strace for
DEFAULT_STRACE_TIMEOUT=$((60*30))
# Job check frequency
DEFAULT_CHECK_INTERVAL=30
# Use timeout?
USE_TIMEOUT_CMD=n
@tomislacker
tomislacker / example_usage.ipynb
Last active August 19, 2016 15:17
Dump output from nfsstat to csv format for more processing fun
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tomislacker
tomislacker / php_aarray_filter.md
Created August 11, 2016 20:44
Ansible PHP Associative Array Filter

Ansible PHP Associative Array Filter

php_aarray.py

"""
Custom filter to take a hash and output a PHP associative array
"""
from __future__ import print_function
import json
@tomislacker
tomislacker / example.md
Created April 14, 2016 14:35
2016.04.14 Logging SSH Password Logins

2016.04.14 Logging SSH Password Logins

Original

Taken from this article but modified to log all passwords, not just failed attempts.

Revised Code

@tomislacker
tomislacker / PyInvoke\ Extending\ Config\ File.ipynb
Last active April 6, 2016 20:08
PyInvoke Extended Configuration
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.