TechNewsLetter Vol:4

Official Ansible Content on Docker Hub

What happens when you steal a hackers computer

Introducing Universal SSL

A PROPER SERVER NAMING SCHEME

Five Things Every Developer Should Know About Syslog

Bash remote vulnerability

Everything you need to know about the Shellshock Bash bug

DOCKER HUB OFFICIAL REPOS: ANNOUNCING LANGUAGE STACKS

Why Loggly Chose AWS Route 53 over Elastic Load Balancing

Keyless SSL: The Nitty Gritty Technical Details

Simplifying and securing multicloud development

Twitter’s Mobile Developers developer conference

Marathon v0.7.0 — Running Dockers at Scale and More

When Logstash and Syslog go wrong

Docker Networking

Decoupling packages

JavaScript Memory Management Masterclass

Be a happier developer with Docker

Get your internal IPv4 address

The Dockerfile is not the source of truth for your image.

FBI Not Happy With Apple & Google’s Encryption Policy

Collaborative “Google Docs” for code

Multi-model database with particularly strong fault tolerance, performance, and operational ease.

An open-source graph database

Use Python in Excel without add-ins

Turn dynamic websites into APIs

Material Design for AngularJS Apps

PayPal’s open source node.js automation framework

Simple Nodejs WebServer

Node.js is built on Chrome’s V8 JavaScript Engine. It’s useful for a range of applications and it brings JavaScript to the server. Applications written in Node.js are event-driven. For example, if you wanted to create a file, you would provide a callback function to be called upon the file’s successful creation. In this sort of model, your app doesn’t become stuck waiting for events to finish executing.

I hope you have installed nodejs. Then you need to install “forever”

Installing forever

forever, developed by nodejitsu, has functions to create applications that are always running—”forever” running. If the application dies, forever brings it back. It has built-in functionality to monitor processes. It also offers an API you can use to incorporate its features into your own code.

forever can be installed using npm. npm should have been installed as part of Node.js:

forever

Running the app

Create the file index.js with the following contents:

index

Then run:

indexx

Point your browser to http://127.0.0.1 or http://localhost. It should display the index.html”

Now we can use forever to manage our application:, instead of running the above command.

foreverr

To check, open the browser and point it to the http://127.0.0.1 or http://localhost. It should display the index.html

Stopping the app is similar:

stop

 

 

Script to take the DB backup by passing the db name and host names to S3

#!/bin/sh
DB=””
HOST=””
printhelp() {

echo “

Usage: sh mysql.sh [OPTION]…
-db, –database The database name which you need to take the backup

-host, –hostname The hostname

-h, –help Display help file

}
while [ “$1” != “” ]; do
case “$1” in
-db | –database ) DB=$2; shift 2 ;;
-host | –hostname ) HOST=$2; shift 2 ;;
-h | –help ) echo “$(printhelp)”; exit; shift; break ;;
esac
done

#### BEGIN CONFIGURATION ####
NOWDATE=`date +%Y-%m-%d`
LASTDATE=$(date +%Y-%m-%d –date=’1 week ago’)

# set dump directory variables
SRCDIR=’/tmp/s3backups’
DESTDIR=’test’
BUCKET=’vishnu-test’

# database access details
USER=’root’
#### END CONFIGURATION ####

# make the temp directory if it doesn’t exist and cd into it
mkdir -p $SRCDIR
cd $SRCDIR

# dump the selected sql file and upload it to s3
#for DB in $(mysql -h$HOST -u$USER -e ‘show databases’ | grep -Ev ‘mysql|information_schema|performance_schema|Database’)
#do
mysqldump -h$HOST -u$USER –single-transaction $DB > $DB.sql
tar -czPf $DB.tar.gz $DB.sql
mv $DB.tar.gz $NOWDATE-$DB.tar.gz
/usr/bin/s3cmd put $SRCDIR/$NOWDATE-$DB.tar.gz s3://$BUCKET/$DESTDIR/
#done

# delete old backups from s3
/usr/bin/s3cmd del –recursive s3://$BUCKET/$DESTDIR/$LASTDATE-$DB.tar.gz

# remove all files in our source directory
cd
rm -rf $SRCDIR/*

 SAVE THIS SCRIPT AND RUN 

FOR EXAMPLE:-  sh  mysql.sh -db <give database name> -host <give hostname>

PhantomJS and Load Speed test for websites

PhantomJS is an optimal solution for

1) Headless Website Testing

2) Screen Capture

3) Page Automation

4) Network Monitoring

Please check this link  http://phantomjs.org/

TO INSTALL PHANTOMJS

cd /usr/local/share
wget https://phantomjs.googlecode.com/files/phantomjs-1.9.1-linux-x86_64.tar.bz2
tar xjvf phantomjs-1.9.1-linux-x86_64.tar.bz2
ln -s /usr/local/share/phantomjs-1.9.1-linux-x86_64/bin/phantomjs /usr/local/share/phantomjs
ln -s /usr/local/share/phantomjs-1.9.1-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs
ln -s /usr/local/share/phantomjs-1.9.1-linux-x86_64/bin/phantomjs /usr/bin/phantomjs
# Additional package
apt-get install fontconfig

Then go to the location

root@machine# cd /usr/local/share/phantomjs-1.9.1-linux-x86_64/examples

root@machine# vim loadspeed.js

ADD OUR EDITED FILE TO GET THE LOAD PAGE SPEED

var args = require(‘system’).args;
    if(args[1] === undefined){
        console.log(‘you should provide an url’);
        phantom.exit();
    }

var namshiUrl = args[1];

var page = require(‘webpage’).create(),
    system = require(‘system’),
    t,address;

if (system.args.length === 1) {
    console.log(‘Usage: loadspeed.js ‘+ namshiUrl);
    phantom.exit(1);
} else {
    t = Date.now();
    address = system.args[1];
    page.open(address, function (status) {
      if (status !== ‘success’) {
            console.log(‘FAIL to load the address’);
        } else {
            t = Date.now() – t;
            console.log(‘Page title is ‘ + page.evaluate(function () {
                return document.title;
            }));
            console.log(‘Loading time ‘ + t + ‘ msec’);
        }
        phantom.exit();
    });
}

THEN TEST IT

root@vishnu-machine:~# for weburl in http://google.com http://yahoo.com ; do phantomjs /usr/local/share/phantomjs-1.9.1-linux-x86_64/examples/loadspeed.js ${weburl}; done

THEN INORDER TO DOING THIS WRITE A SCRIPT

#!/bin/bash
true=0
for weburl in http://google.com http://yahoo.com http://hotmail.com ; do /usr/local/bin/phantomjs /usr/local/share/phantomjs-1.9.1-linux-x86_64/examples/loadspeed.js ${weburl}; done  > abc.txt
cat abc.txt | awk ‘{print $3}’ | sed -n “2~2 p” > abc2.txt
for i in `cat abc2.txt`
do
if [ $i -gt 12000 ]
then
    true=1
fi
done
if [ $true -eq 1 ]
then
   mail -s loadtime mailadddress@domain.com < abc.txt
fi