Skip to content

Instantly share code, notes, and snippets.

View vkhatri's full-sized avatar

Virender Khatri vkhatri

  • Planet Earth
View GitHub Profile
@vkhatri
vkhatri / CKAD.md
Created July 26, 2019 16:32 — forked from veggiemonk/CKAD.md
CKAD exam preparation
@vkhatri
vkhatri / aws-ec2-asg-peer-instances.sh
Created January 31, 2018 17:20
list aws ec2 autoscaling group instances
#!/bin/bash
PEER_LIST_FILE=/etc/asg-peer-instances
SELF_IP=$(ifconfig eth0 | grep -o "inet .* netmask" | cut -f2 -d' ')
SELF_INSTANCE_ID=$(curl http://169.254.169.254/latest/meta-data/instance-id)
SELF_PLACEMENT=$(curl http://169.254.169.254/latest/meta-data/placement/availability-zone)
SELF_REGION="${SELF_PLACEMENT%?}"
SELF_ASG=$(aws ec2 describe-tags --filters "Name=resource-id,Values=${SELF_INSTANCE_ID}" --region $SELF_REGION --query 'Tags[?Key==`aws:autoscaling:groupName`].Value' --output text)
ASG_INSTANCE_IDS=$(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-name $SELF_ASG --region $SELF_REGION --query 'AutoScalingGroups[*].Instances[*].InstanceId' --output text | xargs)
AWS_INSTANCE_IPS=$(aws ec2 describe-instances --instance-ids $ASG_INSTANCE_IDS --region $SELF_REGION --query 'Reservations[*].Instances[*].PrivateIpAddress' --filters 'Name=instance-state-name,Values=running' --output text)
PEER_LIST=$(echo $AWS_INSTANCE_IPS | sed "s/${SELF_IP}//g" | xargs)
@vkhatri
vkhatri / run-transit-vpc-push-cisco-config.py
Created February 15, 2017 01:35
Python Wrapper to Execute Transit VPC Push Cisco Config Module for Testing
# Module Source - https://github.com/vkhatri/aws-transit-vpc/tree/feature-vrf
# http://docs.aws.amazon.com/AmazonS3/latest/dev/notification-content-structure.html
import ast
import logging
import sys
# symlink transit-vpc-poller.py module for import workaround
# ln -s transit-vpc-push-cisco-config.py transit_vpc_push_cisco_config.py
import transit_vpc_push_cisco_config
# Set Logging stream to STDOUT
@vkhatri
vkhatri / run-transit-vpc-poller.py
Last active February 8, 2018 21:08
Python Wrapper to Execute Transit VPC Poller Module for Testing
# Module Source - https://github.com/vkhatri/aws-transit-vpc/tree/feature-vrf
# Change Module Source accordingly, currently
import os
import ast
import logging
import sys
# symlink transit-vpc-poller.py module for import workaround
# ln -s transit-vpc-poller.py transit_vpc_poller.py
import transit_vpc_poller
---
exhibitor_storage_backend: static
oauth_enabled: false
telemetry_enabled: false
bootstrap_url: http://192.168.1.100:80
cluster_name: dev
master_discovery: static
master_list:
- 192.168.1.1
- 192.168.1.2
#!/bin/bash
set -e
if [ -f "/usr/bin/docker" ]; then
exited=$(docker ps -a -q -f status=exited | wc -l)
if [ $exited == "0" ]; then
echo "No exited container to Remove"
else
echo "Removing exited docker containers..."
@vkhatri
vkhatri / mesos-app-ip-port-env.sh
Created July 31, 2016 09:50
Shell Script to Create Environment Variables for Marathon Application Dynamic IP and Port
#!/bin/bash
# Info: Shell Wrapper to populate Marathon Application
# Containers IP & Port ENV Variables.
#
# Variables:
# MARATHON_GROUP: marathon group name
# e.g. Marathon APP - /group0/app
# MARATHON_GROUP=group0
# e.g. Marathon APP - /group0/group1/app
@vkhatri
vkhatri / handler-ntpd-restart.sh
Created January 2, 2016 02:15
consul event ntpd service restart
response=$(cat -)
payload=$(echo $response | sed -e 's/^.*"Payload":"\([^"]*\)".*$/\1/')
# action string "runme" == byte "cnVubWU=" , replace "runme" with your payload data
if [ "$payload" == "cnVubWU=" ]; then
logger restarting ntpd, consul triggered by payload $payload
# /usr/bin/sudo /sbin/service ntpd restart
else
logger skipping ntpd restart, consul triggered by payload $payload
fi
@vkhatri
vkhatri / elasticsearch-indice-purge.rb
Created September 20, 2015 09:38
ElasticSearch Indice Purge Script
#!/usr/bin/env ruby
require 'net/http'
require 'json'
require 'date'
enable = true # set to false for dry run
retention_days = 30 # retention period
today_date = Date.today
deleted_any = false
@vkhatri
vkhatri / ffmpeg
Created April 6, 2015 09:16
FFmpeg x264 multimedia toolkit setup
# Install Packages
yum install kernel-headers kernel-devel # reboot instance if possible
yum install autoconf automake gcc gcc-c++ git libtool make nasm pkgconfig zlib-devel patch telnet mdadm nfs-utils openssl-devel git libxml2 libxml2-devel libxslt libxslt-devel wget libtool pkgconfig nasm
# Set ENV Variables
export PATH=$PATH:/usr/local/bin
export FMP=/usr/local
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig