Skip to content

Instantly share code, notes, and snippets.

@hermes-pimentel
hermes-pimentel / elb-cf-logs-parser.sh
Last active December 27, 2017 12:59
ELB/CF Parser
#download files from bucket
#group logs
cat *.log >> single.txt && mv single.txt single.log
#IPS GET
cat single.log| grep -v POST | awk '{print $3}' | cut -d : -f 1 | sort | uniq -c | sort -nr
#IPS POST
cat single.log| grep -v GET | awk '{print $3}' | cut -d : -f 1 | sort | uniq -c | sort -nr
#!/bin/bash
# (optional) You might need to set your PATH variable at the top here
# depending on how you run this script
#PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# Export the aws keys
export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=
@hermes-pimentel
hermes-pimentel / check-wan.sh
Last active May 2, 2016 17:02
dd-wrt reset wan IP if internet isn't working
#!/bin/bash
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo `date` " - Internet OK - IP:" `ifconfig vlan2 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*'` >> /tmp/script.out
exit 0
else
echo `date` " - Internet NOK - IP:" `ifconfig vlan2 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*'` >> /tmp/script.out
killall -SIGUSR1 udhcpc
killall -SIGUSR2 udhcpc
sleep 600
wget -O w1.txt http://aws.amazon.com/whitepapers/ && for i in `awk -F'"' '$0=$2' w1.txt | grep pdf | grep -v http`; do wget http:$i ; done
@hermes-pimentel
hermes-pimentel / list-ec2-to-csv.py
Last active May 11, 2017 19:45
Export ec2 to csv
#!/usr/bin/env python
import boto.ec2
from boto.ec2 import EC2Connection
import sys
reload(sys)
sys.setdefaultencoding('utf8')
csv_file = open('instances.csv','w+')
def process_instance_list(connection):