Skip to content

Instantly share code, notes, and snippets.

View gregtaylor99's full-sized avatar

Greg Taylor gregtaylor99

  • 08:03 (UTC -04:00)
View GitHub Profile
@gregtaylor99
gregtaylor99 / aws_billing_grafana.sh
Created March 23, 2018 19:20 — forked from shokoe/aws_billing_grafana.sh
Export aws billing info to grafana. Uses AWS billing info from S3. Just activate logs in billing and change the 'f' var in the script.
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
netcat=$(which nc)
host='<carbon IP>'
port='2003'
nc_cmd="$netcat -q0 $host $port"
get_month(){
f="<your id>-aws-billing-detailed-line-items-with-resources-and-tags-${1}"
@gregtaylor99
gregtaylor99 / rds_getlogs.sh
Created March 23, 2018 19:19 — forked from shokoe/rds_getlogs.sh
AWS RDS audit log copy to local dir and to S3. Handles rotation to timestamp naming (so nothing is lost), monthly dirs and S3 encryption. Has a readable and easily monitored log.
#!/bin/bash
# currently support server_audit only!!
# Requires:
# working awscli
# apt-get install lockfile-progs
# required monitoring:
# logwatch on $admin_log for the word 'ERROR'
# log integrity check
# locations:
# script log - /var/log/rds/rds_getlogs.log
@gregtaylor99
gregtaylor99 / readme.md
Created March 23, 2018 17:21 — forked from AlbertoMonteiro/readme.md
AWS Importing and Exporting SQL Server Databases
@gregtaylor99
gregtaylor99 / vbox.sh
Created March 23, 2018 01:40 — forked from pahud/vbox.sh
create docker-machine from local virtualbox ISO image
$ dm create -d virtualbox --virtualbox-boot2docker-url="file://$HOME/.docker/machine/cache/boot2docker.iso" machine-name
@gregtaylor99
gregtaylor99 / icurl.sh
Created March 23, 2018 01:39 — forked from pahud/icurl.sh
icurl
#!/bin/bash
#set -x
curl -s "$@" -w "\r\n=> total: %{time_total}s\r\n"
@gregtaylor99
gregtaylor99 / add_ssh_pubkey.sh
Created March 23, 2018 01:37 — forked from pahud/add_ssh_pubkey.sh
temporarily add your SSH public key on Amazon Linux in User Data file
#!/bin/bash
cat >> ~ec2-user/.ssh/authorized_keys << EOF
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC0QIiv+QYlGIlBc6FFNMQ1WDWfqV2DrpxK2owdDCXsofIoMEhR+QUU4crJ6sNrIe7hMtYbT8c8t487zZHqPbiktjH3rhDq5soeKpUpbcQAbVo9eIC5y4nSr4FoPxonhF0vF0e7keTzquoAVWGYzyyLqsTN8AuJ0aHpsuWrJSLRNoPE/jYkM+gQjp3qecKlgZ1WxOokBGzebufUhszBYwGCD0CT4iKiU4HIQXf+einBq/cEJvtDX5bbttsfaU4pPZ2EjM37o2RTzHpyzO42fn6nHi01Hw2xInPiEGlmwQGV1EK9hA7S77ZriYaVlWEsKWNsBfcjbkS3J4J+UMJBoxFB pahud@pahud-mb12.2016
EOF
@gregtaylor99
gregtaylor99 / self_vol_attach.sh
Created March 23, 2018 01:37 — forked from pahud/self_vol_attach.sh
self volume attaching within EC2
instId=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)
deviceName='/dev/sdz'
volId='vol-97f21469'
region='ap-northeast-1'
mountPoint='/o'
aws --region $region ec2 attach-volume --device $deviceName --volume-id $volId --instance-id $instId && \
mount $deviceNmae $mountPoint
@gregtaylor99
gregtaylor99 / build_dm_awsec2.sh
Created March 23, 2018 01:37 — forked from pahud/build_dm_awsec2.sh
build your docker-machine on AWS EC2 instance
#!/bin/bash
machine='docker-builder'
export AWS_PROFILE='pahud'
AWS_ACCESS_KEY_ID=$(aws configure get aws_access_key_id)
AWS_SECRET_ACCESS_KEY=$(aws configure get aws_secret_access_key)
VPC='vpc-xxxxxx'
docker-machine create --driver amazonec2 \
@gregtaylor99
gregtaylor99 / ecs_mon_docker_freespace.sh
Created March 23, 2018 01:36 — forked from pahud/ecs_mon_docker_freespace.sh
monitor available docker free space in ECS
#!/bin/bash
instanceid=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)
region=$(curl -s http://169.254.169.254/latest/dynamic/instance-identity/document | awk -F\" '/region/ {print $4}')
ip=$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4)
free_space=$(docker info |grep "Data Space Available" |grep G |awk -F "." {'print $1'} |awk {'print $NF'})
metric_name='DockerFreeSpace'
@gregtaylor99
gregtaylor99 / upload_aws_server_crt.sh
Created March 23, 2018 01:35 — forked from pahud/upload_aws_server_crt.sh
AWS IAM upload-server-certificate example
#!/bin/bash
aws iam upload-server-certificate \
--server-certificate-name my-cert-name \
--certificate-body file://cert.pem \
--private-key file://privkey.pem \
--certificate-chain file://chain.pem