Skip to content

Instantly share code, notes, and snippets.

View padilo's full-sized avatar

Pablo Díaz-López padilo

  • Dynatrace
  • Barcelona
View GitHub Profile
@padilo
padilo / kafka-consumer-by-topic.sh
Created July 3, 2019 13:22
Script to get from Kakfa the list of topics consumed by each consumer group
#!/bin/bash
if [ $# -ne 2 ]; then
>&2 echo "usage: $0 <kafka_binary_folder> <bootstrap.server>"
>&2 echo
>&2 echo "It outputs the list of topics consumed by consumergroup as csv."
>&2 echo "With the following structure:"
>&2 echo " <consumer>,<topic>"
exit 1
fi
@padilo
padilo / ami-usage.sh
Created November 9, 2017 09:20
Check the uses of an AMI in all configured AWS accounts
#!/usr/bin/env bash
profiles="$((egrep '^\[ *[a-zA-Z0-9_-]+ *\]$' ~/.aws/credentials 2>/dev/null; grep '\[profile' ~/.aws/config 2>/dev/null | sed 's|\[profile ||g') | tr -d '[]' | sort | uniq)"
ami=$1
total_usages=0
ec2_usages() {
usages=$(AWS_DEFAULT_PROFILE=$profile aws --output=json ec2 describe-instances | grep ImageId | sed -n 's|.*"\(ami-[^"]*\).*|\1|p' | grep $ami | wc -l | tr -d " ")
echo "$profile has $usages usages on ec2"
@padilo
padilo / kafka-burrow-query.sh
Last active April 7, 2017 11:43
Query kafka burrow consumer status http endpoint
#/usb/bin/env bash
if [[ $# -ne 2 ]]; then
echo "usage $0 <jq query> <monitor host>"
exit -1
fi
jq_query=$1
host=$2
@padilo
padilo / retry_cmd.sh
Last active March 20, 2017 14:52
bash script retry command every some seconds
#!/usr/bin/env bash
if [ $# -ne 3 ]; then
echo 'usage: retry <num tries> <wait retry secs> \"<command>\"'
exit 1
fi
tries=$1
wait_retry=$2
command=$3
@padilo
padilo / check_zookeeper.sh
Last active December 28, 2016 15:44
Check zookeeper's IP registered on a hostname and returns its mode
#!/usr/bin/env bash
if [ $# -ne 1 ]; then
echo "usage: $0 <hostname>"
echo "It show the mode the zookeepers are running"
exit 1
fi
hosts=$(dig $1 +short | sort)
for host in $hosts; do
echo -n "${host} -> "; echo stat | nc -w2 $host 2181 | grep Mode

Keybase proof

I hereby claim:

  • I am padilo on github.
  • I am pablodiaz (https://keybase.io/pablodiaz) on keybase.
  • I have a public key whose fingerprint is 2569 6174 B57A 5C6C 0155 FE4D 432B E7A3 F397 7DFF

To claim this, I am signing this object: