Skip to content

Instantly share code, notes, and snippets.

View ashrithr's full-sized avatar
🎯
Focusing

Ashrith Mekala ashrithr

🎯
Focusing
View GitHub Profile
@ashrithr
ashrithr / check_dfs.sh
Last active January 14, 2019 06:01
nagios plugin to monitor dfs
#!/usr/bin/env bash
# ---
# => Nagios plugin to monitor hadoop dfs
# This script serves as base line for nagios plugins for hadoop
# Author: Ashrith
# ---
PROGNAME=`basename $0`
VERSION="Version 1.0"
@ashrithr
ashrithr / user_mng.sh
Created May 20, 2013 18:35
Script to manage Users on linux, created for training purpose (with lots of commenting)
#!/usr/bin/env bash
# ===
# Script to manage users on a Unix system
# Author: Ashrith
# ===
#Variables
SERVER=`uname -n`
#terminal coloring helper variables
CLR_GREEN="\033[01;32m"
CLR_RED="\033[1;31m"
@ashrithr
ashrithr / compare_file_age.sh
Created May 20, 2013 18:38
bash function to compare if a file is older than 28 hours or not
#######BEGIN SCRIPT############
#!/bin/bash
# This checks that the specified file is less than 28 hours old.
# returns 0 if younger than 28 hours.
# returns 1 if older than 28 hours.
#funtion arguments -> filename to comapre against curr time
function comparedate() {
if [ ! -f $1 ]; then
echo "file $1 does not exist"
@ashrithr
ashrithr / ruby_amp.rb
Created May 22, 2013 00:12
ruby &: usage
# Ruby has the & operator which can be used to "cast" any object to a block.
# This behaviour works out-of-the-box on Procs, Methods, and Symbols.
#Code below is equivalent
["1", "2", "3"].map{ |string| string.to_i }
#=> [1, 2, 3]
["1", "2", "3"].map(&:to_i)
#=> [1, 2, 3]
@ashrithr
ashrithr / A_maven.md
Last active October 11, 2023 08:45
build java projects using maven

Intro to Maven

###Create a project from Maven Template:

To start a new maven project, use the maven archetype plugin from the command line using the archetype:generate goal.

The following command will tell maven to create a java project from maven-archetype-quickstart template, if you ignore the archetypeArtifactId argument, then a list of the templates will be listed for you to choose.

@ashrithr
ashrithr / tmux.conf
Last active December 17, 2015 16:19
tmux configuration
# set command prefix for tmux as ctrl-a instead of ctrl-b
set-option -g prefix C-a
unbind C-a
# To use regular Ctrl-a to move cursor to beginning of line use Ctrl-a Ctrl-a
unbind-key C-b
bind-key C-a send-prefix
# set vi mode keys
setw -g mode-keys vi
@ashrithr
ashrithr / fork_bomb.sh
Created May 23, 2013 21:44
shell fork bomb
#warning, this might bring down your system
:(){ :|:& };:
@ashrithr
ashrithr / sshable.rb
Last active December 17, 2015 18:09
ruby function to check if passwordless is setup
def sshable?(nodes_arr, ssh_user, ssh_key, port=22)
nodes_arr.each do |instance|
`ssh -t -t -o ConnectTimeout=2 -o StrictHostKeyChecking=no -o BatchMode=yes -i #{ssh_key} #{ssh_user}@#{instance} "echo" &>/dev/null`
#ssh options used:
#ConnectTimeout => timeout the ssh session
#StrictHostKeyChecking => dont check for host key
#BatchMode => dont ask for password, of prompted for password exit out
#-t -t => Force pseudo-tty allocation, Multiple -t options force tty allocation, even if ssh has no local tty
unless $?.success?
puts "[Error]: cannot ssh into instance: #{instance}"
@ashrithr
ashrithr / change_pwd.rb
Created May 27, 2013 03:52
ruby script to change the passwords of remote servers using net-ssh
require 'net/ssh'
hosts = IO.readlines('servers.txt') # full path of servers' list
port = 22 # SSH port
user = 'root' # username
old_password = 'secret123'
new_password = 'secret@123'
hosts.each do |host|
Net::SSH.start(host, user , :password => old_password , :port=> port) do |ssh|
@ashrithr
ashrithr / os_info.sh
Created June 10, 2013 22:18
Detect OS info
#!/bin/bash
# Detects which OS and
# if it is Linux then it will detect which Linux Distribution,
# if Mac(Darwin) will detect mac os x version, build number
OS=`uname -s`
REV=`uname -r`
MACH=`uname -m`
GetVersionFromFile()