How to check socket connection ?

How to check socket connection between filebeat, logstash and elasticseearch ?

netstat -anp | grep 9200
netstat -anp | grep 5044

a – Show all listening and non-listening sockets
n – numberical address
p – process id and name that socket belongs to

9200 – Elasticsearch port
5044 – Filebeat port

ESTABLISHED” status for the sockets that established connection between logstash and elasticseearch / filebeat.

LISTEN” status for the sockets that listening for incoming connections.

To view the count of socket, use

 wc -l


How to install npm and nodejs in offline on linux ?

How to install npm and nodejs in offline on linux ?

Download the latest Linux binaries from the site

Extract it TAR file to the desired location.

cd /opt/mohan/
tar -xvf node-v6.11.0-linux-x64.tar.gz

set the soft link to npm and node

ln -s /opt/mohan/node-v6.10.3-linux-x64/bin/node /usr/bin/node
ln -s /opt/mohan/node-v6.10.3-linux-x64/bin/npm /usr/bin/npm

Check the npm  and node version

npm -v
node -v



Elasticdump is the import and export tool for Elasticsearch indexes.

How to install elasticdump and how to copy elasticsearch index?

Install npm and node if not installed already.

Set the proxy if required as below.

npm config set proxy
npm config set http_proxy=

Install the elasticdump as below.

npm install elasticdump -g

-g is the global mode. It means it installs the current working directory as a global package directory.

Set the soft link to elasticdump

ln -s /opt/mohan/node-v6.10.3-linux-x64/bin/elasticdump /usr/bin/elasticdump

Go to the help to check all the commands in the elasticdump.

elasticdump --help


To export to a file:

elasticdump --input=http://localhost:9200/mohan-index-2017.05.* --output=/opt/mohan/mydata.json --type=data

elasticdump --input=http://localhost:9200/mohan-index-2017.05.* --output=/opt/mohan/mydata.json --type=mapping

if elasticsearch is secured with certs, then use NODE_TLS_REJECT_UNAUTHORIZED as 0 in the beginning of the command.

# NODE_TLS_REJECT_UNAUTHORIZED=0 elasticdump --input=http://localhost:9200/mohan-index-2017.05.* --output=/opt/mohan/mydata.json

if elasticsearch authorized with shield then, use –httpAuthFile option. Create a file with below user and password.



# NODE_TLS_REJECT_UNAUTHORIZED=0 elasticdump --httpAuthFile=/opt/mohan/myAuth.file --input=http://localhost:9200/mohan-index-2017.05.* --output=/opt/mohan/mydata.json

If need to zip the output file, use as below.

# NODE_TLS_REJECT_UNAUTHORIZED=0 elasticdump --httpAuthFile=/opt/mohan/myAuth.file --input=http://localhost:9200/mohan-index-2017.05.* --output=$ | gzip > /opt/mohan/mydata.json.gz



RegEx Pattern

RegEx Pattern

 / open and close
 ^ Begin
 $ End
 ? preceding character
 [] group
 | choice
 + one or more


/^([a-zA-Z]+)-([a-zA-Z]+)-([a-zA-Z]+)-([0-9]+)) $/

How to check valid number / integer?

 "123456" =~ /\A\d+\z/ ? true: false

Username in lowercase, number, underscore or hyphen. minmum 6 and maximum 12 char length.


Hex values with length 6 OR 3.


Name with letters, numbers or hyphens:





/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/






# chroot –userspec “$TB_USER”:”$TB_GROUP” “/” sh -c ”
# cd \”/$TB_HOME\”
# exec \”$program\” $args
# ” >> $TB_LOG_DIR/$name.stdout 2>> $TB_LOG_DIR/$name.err &

rpm relocate

rpm -ivh package.rpm –relocate=/Owner=/myonwer –relocate=/Group=/mygroup
rpm -ivh package.rpm –relocate /oldlocation=/newlocation

Unix vi Editor

Unix Vi editor find and replace


Cut, Copy and Paste

Command Description
x delete (cut) character under the cursor
24x delete (cut) 24 characters
dd delete (cut) current line
4dd delete (cut) four lines
D delete to the end of the line from the cursor
dw delete to the end of the current word
yy copy (without cutting) current line
5yy copy (without cutting) 5 lines
p paste after current cursor position/line
P paste before current cursor position/line