Skip to content

Instantly share code, notes, and snippets.

View MBtech's full-sized avatar

M. Bilal MBtech

View GitHub Profile
@MBtech
MBtech / Disable hyperthreading
Created June 6, 2016 11:39
Script to disable CPU cores. It can be used to disable hyperthreading
# Replace "31" with the total number of procs - 1 reported by nproc. Use "echo 0" or "echo 1" to disable or enable hyperthreading
sudo bash -c 'for i in {1..31..2}; do echo 0 > /sys/devices/system/cpu/cpu$i/online; done'
@MBtech
MBtech / confcount_progression.sh
Last active June 1, 2016 09:17
This bash one liner can be used to display the number of configurations for all the branches of Storm and Flink
#For Storm
git ls-remote --heads origin | sed 's?.*refs/heads/??' | xargs -I {} sh -c 'git reset; git checkout .; git clean -fdx; git checkout origin/{} >/dev/null 2>&1; echo $(grep "[^#]" conf/defaults.yaml 2>/dev/null | wc -l ) {};' | sort -k 1 -n
#For Flink
git ls-remote --heads origin | sed 's?.*refs/heads/??' | xargs -I {} ../script.sh {} | sort -k 1 -n
#Script
#!/bin/bash
git reset
git checkout .
@MBtech
MBtech / setup_ssh.yaml
Created March 16, 2016 12:06
Ansible Playbook to allow ssh access between any pair of machines
---
- hosts: allnodes
vars:
user_name: 'ubuntu'
tasks:
- name: Download Public keys
fetch: src=/home/{{ user_name }}/.ssh/id_rsa.pub dest=keys/prefix-{{ ansible_hostname }} flat=yes
- name: create concatenated keys file
@MBtech
MBtech / SSH_Setup.md
Last active March 11, 2016 12:13
Setting up SSH access

$ mkdir .ssh

$ cd .ssh

$ ssh-keygen -t rsa

$ chmod 700 ~/.ssh

$ chmod 600 ~/.ssh/*

@MBtech
MBtech / useful_python.py
Created February 10, 2016 14:25
Useful python tricks
#Generate a list of 12 random integers between 0 10
values = [random.randint(0,10) for _ in xrange(12)]
@MBtech
MBtech / netflix_sysperf.sh
Created February 7, 2016 20:19
Netflix's 10 commands for 60s performance evaluation
#http://techblog.netflix.com/2015/11/linux-performance-analysis-in-60s.html
uptime
dmesg | tail
vmstat 1
mpstat -P ALL 1
pidstat 1
iostat -xz 1
free -m
sar -n DEV 1
sar -n TCP,ETCP 1
@MBtech
MBtech / bash_commands.sh
Last active February 9, 2016 18:15
Set of useful bash commands
#Getting the line number of a file from an ls command
ls -l reports/*.csv | grep -n "RollingCount_metrics_1454467885562.csv"
#Port forwarding with ssh (Port 80 from user@example.com is forwarded to port 9000 of imgur.com)
#http://blog.trackets.com/2014/05/17/ssh-tunnel-local-and-remote-port-forwarding-explained-with-examples.html
ssh -L 9000:imgur.com:80 user@example.com
@MBtech
MBtech / Storm_deploy
Last active February 16, 2016 12:09
Storm configuration and deployment
#Downloading storm
mkdir bilal
cd bilal
mkdir app
mkdir app/storm
wget http://www.gtlib.gatech.edu/pub/apache/storm/apache-storm-0.9.3/apache-storm-0.9.3.tar.gz
tar xvzf apache-storm-0.9.3.tar.gz
mkdir storm
mv apache-storm-0.9.3/* storm/
@MBtech
MBtech / conf_count.sh
Created January 28, 2016 11:35
Storm configuration count
#Get total number of configurations
cat defaults.yaml | grep "^[^#]" | wc -l
#Get configurations that are topology related
cat defaults.yaml | grep "^topology" | wc -l
@MBtech
MBtech / nearest_mirror.sh
Last active September 15, 2016 18:39
Getting URL of nearest apache mirror
curl 'https://www.apache.org/dyn/closer.cgi' | grep -o '<strong>[^<]*</strong>' | sed 's/<[^>]*>//g' | head -1 | xargs -I {} echo {}