Posts

Showing posts from 2015

Requisites / difference between 'require and require_in' in SaltStack:

Image
     The Salt requisite system is used to create relationships between states. You can find more details about Requisites on here require: * This is the most basic requisite which allows us to specify that one state requires another state to be run successfully first. * Also ensures correct ordering and the requiring states runs only if the required state ran successfully. Ex: # cat req.sls require_check: # REQUIRING STATE  cmd.run:   - name: echo FIRST   - require:     - cmd: require_check1 require_check1: # REQUIRED STATE  cmd.run:   - name: echo SECOND If the REQUIRED STATE not successful: require_in: * Requisites of this form( _in ) force other states to depend on the state that contains the requisite. * The requiring states run first and then run the required state if requiring state run succcessful. Ex: # cat req.sls require_check: # REQUIRING STATE  cmd.run:   - name: echo FIRST   - require_in:     - cmd: require_check1 require_check1: # REQUIR

BASH SCRIPT AND CRON FOR mysqldump PROCESS(LINUX):

This script will help to take mysql dump particularly when you want to exclude few db in server. * kindly update the required database list on the file: db.list With password: #!/bin/bash #script will use for when you take db backup for selective range of db's for i in `cat db.list` do mysqldump --user="username" --password="password" $i > $i.sql if [ $? -ne 0 ] then echo $i Failed >> db_filed.txt else echo $i Success >> db_success.txt fi done Without password: #!/bin/bash #script will use for when you take db backup for selective range of db's for i in `cat db.list` do mysqldump $i > $i.sql if [ $? -ne 0 ] then echo $i Failed >> db_filed.txt else echo $i Success >> db_success.txt fi done Add to cron: # vi mysql_dump_cron.sh #!/bin/bash #script will use for when you take db backup for selective range of db's BACKUP=DB_BACKUP_`date +%Y-%m-%d-%H:%M` mkdir -p /path/to/BACKUP for i in `cat /path/to/db.list` do my

How To Find My Public IP Address From Command Line:

Image
To Find My Public IP Address From Command Line: # host myip.opendns.com resolver1.opendns.com | grep ^myip | awk '{print $4}' (or) # dig myip.opendns.com @resolver1.opendns.com +short (or) # dig TXT o-o.myaddr.l.google.com @ns1.google.com +short :-) !

How to disable domain lookup in cisco router(Translating "xxxxxx"...domain server (255.255.255.255)) ?

Lookup: Translating "xxxxxx"...domain server (255.255.255.255) ** Simply we can aborte the domain lookup by: ctrl + shift + 6 ** To disable the domain lookup [should be On config mode]: Router(config)# no ip domain lookup ** The same we can enable the domain lookup [should be On config mode]: Router(config)# ip domain lookup !=!=!=!=!=!=!=!

Coding attempt in PYTHON (bmi_calculator)

Image
This is my first attempt in python coding and tried-out to create a script in python for bmi_calculator. * create file as bmi_calculator.py * paste the below code * # python bmi_calculator.py #!/usr/bin/env python name = raw_input('Enter your Name:\t') height = input('Enter your Height "In Centimeter":\t') weight = input('shall we know your weight"In Kg":\t') he = float(height) / 100 # cm to m suwe = he * he maa = weight / suwe #print 'Name:', name #print 'Height:', height #print 'Weight:', weight ma = round(maa) print 'So, %s your BMI is:\t'  % name, ma print 'Rount of value:\t', int(ma) mx = int(ma) print 'Your Health status is:' if mx < 19:         print 'Underweight' elif mx >= 19 and mx <= 25:         print 'Normal' elif mx >= 25 and mx <= 30:         print 'Overweight' elif mx >= 30:         print 'Too Fat, kindly

shell script to gather Server information (after login):

Image
It will shows the server information when login. # create a file 'server_info.sh' # copy and paste the below code. ========================================= #!/bin/bash wait () { echo -en  "Gathering server information..." a=1 while [ $a -le 20 ] do echo -ne "." sleep .1 a=`expr $a + 1` done } pause () {    echo "Press [ Enter ] to continue..."    read -p "$*" } raw_mem=$(cat /proc/meminfo  | grep 'MemTotal\|MemFree\|^Cached' | awk '{print $2}') me=$(echo $raw_mem |awk '{print $1}') tot=$((me/1024)) mef=$(echo $raw_mem |awk '{print $2}') fre=$((mef/1024)) mec=$(echo $raw_mem |awk '{print $3}') cac=$((mec/1024)) use=$((tot-fre)) ho=$(hostname) os=$(cat /etc/redhat-release) ker=$(uname -sr) curc=$(who | awk '{print $1}'| wc -l) lo=$(uptime| cut -f3,4,5 -d',') wait clear echo -e "\nSYSTEM INFORMATION!" echo -e "===================" echo -e "\nOS info:&