Skip to content

Instantly share code, notes, and snippets.

@flannon
flannon / Create an auto scaling group
Last active September 18, 2015 20:48
Create Autoscaling groupwith the aws cli.
aws autoscaling create-auto-scaling-group --auto-scaling-group-name <name-asg> --launch-configuration-name uqbar-lc --max-size 1 --min-size 1 --availability-zones "us-east-1b" --vpc-zone-identifier <subnet-XXXXXXXX>
@flannon
flannon / Create lauch configuration
Last active December 8, 2015 21:51
Create a launch configuration with a spot price of ¢.045
Create launch configuration - with a spot price requirement single security group, no termination policy
aws autoscaling create-launch-configuration --launch-configuration-name <name-lc> --image-id <ami-XXXXXXXX> --instance-type m3.medium --associate-public-ip-address --spot-price .045 --security-groups <security group name>
Create launch configuration -- with a spot price requirement, multiple security groups and block device mappings for terminaiton policy
aws autoscaling create-launch-configuration --launch-configuration-name test-lc --image-id <ami-xxxxxxxx> --instance-type t1.micro --associate-public-ip-address --spot-price .035 --security-groups {<sg-XXXXXXX>,<sg-XXXXXXX>} --block-device-mapping "[{\"DeviceName\": \"/dev/sda\",\"Ebs\": {\"DeleteOnTermination\": true, \"VolumeSize\": 8, \"VolumeType\": \"standard\"}}]"
@flannon
flannon / scaleup.sh
Last active September 18, 2015 20:52
Scale up - time based scale up of autoscale group
aws autoscaling put-scheduled-update-group-action --scheduled-action-name <name-UpDaily> --auto-scaling-group-name <name-asg> --recurrence "45 16 * * *" --min-size 1 --max-size 1 --desired-capacity 1 --start-time 2015-08-16T20:44:00Z
@flannon
flannon / scaledown.sh
Last active September 18, 2015 20:53
Scale down - time based scale down sets autoscaling group to 0 instances
aws autoscaling put-scheduled-update-group-action --scheduled-action-name <name-DownDaily> --auto-scaling-group-name <name-asg> --recurrence "10 22 * * *" --min-size 0 --max-size 0 --desired-capacity 0 --start-time 2015-08-16T20:12:00Z
@flannon
flannon / clean_orphaned_snapshots.py
Created February 8, 2016 22:57 — forked from mjbommar/clean_orphaned_snapshots.py
Cleans orphaned snapshots from an EC2 account. Requires boto config.
'''
@author Bommarito Consulting, LLC
@date 20120622
Identify and, if requested, remove orphaned snapshots from an EC2 account.
'''
# Imports
import boto
@flannon
flannon / post-merge
Created February 16, 2016 17:59 — forked from sindresorhus/post-merge
git hook to run a command after `git pull` if a specified file was changed. In this example it's used to run `npm install` if package.json changed and `bower install` if `bower.json` changed. Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
#/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
a solr rpm implementation
https://github.com/mentalblock/solr-rpm
Enable screen sharing/VNC
$ sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -on -clientopts -setvnclegacy -vnclegacy yes -clientopts -setvncpw -vncpw <password> -restart -agent -privs -all
List all groups
$ dscl . list /groups
List group members
List block devices
$ lsblk
Read label
$ sudo e2label <device name>
write label
$ sudo e2label <device name> <label>
fstab entries to mount by label
list compiled modules
$ httpd -l
Estimate memory usage per apache process
$ ps -lyC httpd --sort:rss | awk '{sum+=$8; ++n} END {print "Tot="sum"("n")";print "Avg="sum"/"n"="sum/n/1024"MB"}'
The max value for MaxClients/MaxServers should be set to 80% of memory consumption
(i.e. mem per httpd process divided by 80% system memory.)
Or, for another version from https://gist.github.com/tbjers/4496984 with slight modifications, try this,