This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for s in $(aws kinesis list-streams --query 'StreamNames[*]' --output text); do | |
if [[ $(aws kinesis describe-stream --stream-name $s --query 'StreamDescription.EnhancedMonitoring.ShardLevelMetrics') != "null" ]]; then | |
echo "Activated for ${s}"; | |
fi ; | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// This script reports the number of metrics in cloudwatch for each namespace / | |
// metric / metric dimension that can be pulled over the last 2 hours. It helps | |
// tracking the density of the metrics and this way find who stores at least 1 | |
// metric per second. This is needed when you try to track down the spend in the | |
// monthly report for the PutMetrics operation. | |
// Outputs the result in a CSV format in the given file path. | |
// | |
// usage example: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// Note: I initially wrote this script to delete old Cloudwatch metrics | |
// but I found out too late that it's not possible to do delete metrics from CloudWatch | |
// so just keeping this script as a usage example of the metrics statistics manipulations | |
import ( | |
"github.com/aws/aws-sdk-go/aws" | |
"github.com/aws/aws-sdk-go/aws/session" | |
"github.com/aws/aws-sdk-go/service/cloudwatch" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// Parses classic ELB access logs and puts them inside a MySQL/MariaDB table | |
// Easy way to get a DB: | |
// docker run --name some-mariadb -e MYSQL_ROOT_PASSWORD=my-secret-pw -e MYSQL_DATABASE=accesslogs -p 3306:3306 -d mariadb:latest | |
// | |
// The bulk load your files: | |
// for f in ~/Downloads/*.txt ; do go run aws_elb_log_analyzer.go -db-create-table -db-host "tcp(172.17.0.2)" -db-name accesslogs -db-user root -db-pwd my-secret-pw -db-table bla -file-path $f; done | |
// Or: | |
// TBL=bla ; find /tmp/${TBL} -type f -name '*.log' -o -name '*.txt' | while read f; do echo "Processing $f"; go run aws_elb_log_analyzer.go -db-create-table -db-host "tcp(172.17.0.2)" -db-name accesslogs -db-user root -db-pwd my-secret-pw -db-table ${TBL} -file-path $f; done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aws elb describe-load-balancers --query 'LoadBalancerDescriptions[*].{name:LoadBalancerName,instances:Instances[*].InstanceId}' | jq '[.[] | {name: .name, inst: .instances | length}]' | |
# List only the empty ones: | |
aws elb describe-load-balancers --query 'LoadBalancerDescriptions[*].{name:LoadBalancerName,instances:Instances[*].InstanceId}' | jq '[.[] | if (.instances | length) <= 0 then {name: .name, number_of_instances: .instances | length} else empty end]' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// This script cleans up old LogGroups (empty and olde than 90 days and old | |
// LogStreams (last event timestamp is over 30 days old or if the logstream | |
// is empty and has been created over 30 days ago) from AWS Cloudwatch | |
import ( | |
"github.com/aws/aws-sdk-go/aws/session" | |
"github.com/aws/aws-sdk-go/service/cloudwatchlogs" | |
"log" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export AWS_PROFILE=dev; for lg in $(aws logs describe-log-groups --query 'logGroups[].logGroupName' --output text); do aws logs describe-log-streams --log-group-name "${lg}" --query 'logStreams[].{arn:arn,rs:lastEventTimestamp}' --output text ; done > /tmp/${AWS_PROFILE}.out ; cp /tmp/${AWS_PROFILE}.out /tmp/{AWS_PROFILE}.sh ; sed 's/^arn:aws:logs:.*:.*:log-group:\(.*\):log-stream:\(.*\)\t\+\(.*\) *$/if [[ $(( \3 \/ 1000 )) -lt $(date +%s -d "-30 days") ]] ; then aws logs delete-log-stream --log-group-name '"'"'\1'"'"' --log-stream-name '"'"'\2'"'"'; fi/g' -i /tmp/{AWS_PROFILE}.sh; bash /tmp/{AWS_PROFILE}.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# records from the webcam and my bass pedal | |
ffmpeg -f v4l2 -thread_queue_size 512 -i /dev/video0 -thread_queue_size 512 \ | |
-f alsa -i hw:1,0 -c:v copy -c:a copy \ | |
${HOME}/Videos/$(date +%Y%m%d%H%M)_record.mkv | |
# ffmpeg -f v4l2 -thread_queue_size 512 -i /dev/video0 \ | |
# -thread_queue_size 512 \ | |
# -f alsa -i hw:1,0 \ | |
# -vcodec libx264 -x264opts keyint=60:no-scenecut -preset fast \ | |
# -q:v 4 -s 640x480 -r 30 / | |
# -acodec libmp3lame -q:a 7 -channels 2 \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// This script export all the security groups (not the stale ones) and corresponding rules to the stdout in a csv format | |
// Quickn dirty version | |
import ( | |
"fmt" | |
"github.com/aws/aws-sdk-go/aws/session" | |
"github.com/aws/aws-sdk-go/service/ec2" | |
"log" |