This file contains 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
#!/bin/bash | |
# replace any with a specific interface you want to monitor or just use any to capture all interfaces | |
tcpdump -i any 'dst port 53' >> /var/log/dnsqueries.log | |
#### If using supervisord, use this template for setting up the program entry: | |
# [program:dnsworker] | |
# command=bash dnsquerylogger.sh | |
# autostart=true | |
# autorestart=true |
This file contains 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
# Command to run pt online schema change | |
pt-online-schema-change \ | |
D=<dbname>,t=<table_name>,h=<hostname>,u=<username> \ | |
--alter="<alter sql>" \ | |
--ask-pass \ | |
--execute \ | |
--max-load 100 \ | |
--critical-load 120 |
This file contains 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
--- Simple table to keep track of delete chunks | |
create table _delete_log | |
( | |
log varchar(200) null, | |
createdAt timestamp null | |
); | |
------------ Stored proc definition --------------- | |
DROP PROCEDURE IF EXISTS delete_chunks; | |
DELIMITER $$ |
This file contains 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
$(docker inspect my-sibling-dind-container --format '{{ .NetworkSettings.IPAddress }}') | |
-- Make sure both run on the same "network" (bridge by default in most cases) |
This file contains 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
### example for setting up a make workflow that can tag images based on the git tag | |
### the trailing ; are important: runs the commands in the same "shell" and the $$tag variable flows through | |
docker-build: | |
@echo "Latest 3 tags: "; \ | |
git ls-remote --sort='v:refname' --tags ./. | tail -n 3; \ | |
read -p "Enter New Tag:" tag; \ | |
echo "Releasing new tag: $$tag"; \ | |
git tag $$tag; \ | |
git push origin $$tag -f; \ |
This file contains 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
#!/usr/bin/env bash | |
###### ERROR TRAP - DONT WRITE OTHER COMMANDS BEFORE THIS ############ | |
set -eEx | |
function HANDLE_ERROR() { | |
echo "SCRIPT FAILED" | |
echo "FAILED AT: $(caller)" | |
# Do any other commands here | |
exit 1 | |
} |
This file contains 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
# This script will send a signal to a container | |
# Sleep for a random time b/w 1 to 3 seconds to avoid restarting at the exact same time | |
# This bc format of finding random doesn't print scientific notation which sometimes sleep doesn't like a lot | |
/bin/sleep "$(echo "scale=3; 0.5 + 2.5 * $RANDOM / 32767" | bc)s" | |
## Running in silent curl mode (-s and > /dev/null) - remember while debugging | |
if curl --silent --show-error --output /dev/null --unix-socket /var/run/docker.sock -X POST "http/containers/${CONTAINER_ID}/kill?signal=SIGUSR2" ; then | |
echo "Successfully sent signal to $CONTAINER_ID" | |
else | |
echo "Failed to send signal to $CONTAINER_ID. Triggering alarms." |
This file contains 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
# https://help.datadoghq.com/hc/en-us/articles/206441345-Send-metrics-and-events-using-dogstatsd-and-the-shell | |
# Send an event to DD based on success or failure | |
echo "_e{${#title},${#text}}:$title|$text|t:${alert_type}" | nc -u -w1 "${HOST_IP}" 8125 | |
if [ "$CMD_EXIT_CODE" -eq 0 ]; | |
echo "foo.bar.success:1|g" | nc -u -w1 "${HOST_IP}" 8125 | |
then | |
echo "foo.bar.failure:1|g" | nc -u -w1 "${HOST_IP}" 8125 | |
fi |
This file contains 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
#!/bin/bash | |
###################################################################### | |
# Waits for Mongodb, Redis and Mysql to be ready | |
# usage examples: | |
# wait-for-dependencies.sh echo "READY TO GO" | |
# wait-for-dependencies.sh make build | |
# Exit Codes: 0 for success, 2 if wait command timed out | |
###################################################################### |
This file contains 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
#!/bin/bash | |
set -e | |
export CONSUL_HTTP_ADDR="https://my-consul-address" | |
VALUE=$(consul kv get <key>) | |
if [ "$VALUE" != "locked" ]; then | |
# Unlocked, check the timeout | |
TIMEOUT=$(echo $VALUE | jq 'reduce .[] as $num (0; .+$num)') |
NewerOlder