Skip to content

Instantly share code, notes, and snippets.

@cocoy
cocoy / gist:838322
Created February 22, 2011 07:07
Check and protect instance for termination:
Check if termination is allowed:
for i in `ec2-describe-instances | grep ^INSTANCE | cut -f2`; do ec2dinatt --disable-api-termination $i ; done
Protect:
for i in `ec2-describe-instances | grep ^INSTANCE | cut -f2`; do ec2minatt --disable-api-termination true $i ; done
@cocoy
cocoy / gist:813213
Created February 6, 2011 07:50
check disk space
du -hx --max-depth=1 /var
lsof -n |grep deleted --kill -HUP <pid>
@cocoy
cocoy / gist:794683
Created January 25, 2011 08:53
patch to ssh keypair for littlechef
--- a/littlechef.py
+++ b/littlechef.py
@@ -49,6 +49,7 @@ def new_deployment():
print >>authfh, "[userinfo]"
print >>authfh, "user = "
print >>authfh, "password = "
+ print >>authfh, "keypair-file = "
print "auth.cfg file created..."
0 0 * * * /vol/conf/snapshot.sh >> /mnt/backup_ebs.log 2>&1
0 2 * * * /vol/conf/manage_snaphost.sh >> /mnt/backup_ebs.log 2>&1
#!/bin/bash -xe
EBS_DEVICE='/dev/sdh'
INSTANCE_ID=$1
AKI=${2:-'aki-5f15f636'}
ARI=${3:-'ari-0915f660'}
ARCH=${4:-'i386'}
SIZE=${5:-10}
AZ=${6:-'us-east-1d'}
NAME=${7:-"ami-from-$INSTANCE_ID"}