Skip to main content


Iptables Rules For 2 Node Elasticsearch Cluster

Below shell script is useful for securing two node elasticsearch cluster. To apply suitable iptables rules, just run it on each of the ES Nodes.

With this script rules are applied for: Allowing traffic on loopback adapters. Allowing ES Nodes to communicate each other. Allowing incoming ssh connections. Allowing incoming icmp (ping) requests. Allowing outgoing DNS requests. Allowing Access to Elasticsearch HTTP Interface. Dropping all other traffic.
Recent posts

Logstash Grok Filter Example For Jboss Server Access Logs

Logstash is a great tool for centralizing application server logs. Here is an excerpt from a jboss application server's access logs and corresponding grok filter for them.
Jboss Access Logs:

Converting some fields' data types to numbers (in the example integer and float) are useful for later statistical calculations. Logstash Filter (Logstash Version 2.3.4)

When logs are sent to elasticsearch, string fields would be stored as analyzed fields.

Listing Volume Mount Information For Each Container in Docker

Docker inspect command returns container information in JSON format. While you want to get specific objects from the returning json array, --format or -f option formats the output using the Go’s text/template package. Sometimes I just want to get source and destination folders of the volume mounts for every container. I have written following bash script to achieve this:

Keeping TableSpace Statistics with Graphite

Most of the time, monitoring usable free size of oracle tablespaces is helpful. Especially for production systems. Keeping that statistical data for some time is also meaningful so as to see how much new data enter into the database.
With the following bash script each tablespace's free size can be sent to graphite database. Just query oracle data dictionary views (dba_tablespaces, dba_data_files, dba_free_space) then send each value to graphite using netcat.

On the side of graphite carbon storage-schemas.conf whisper file schema definitions must be updated like the following example. This file is scanned for changes every 60 seconds, so no need to reload any service.
[oracle_tablespace_free_space] pattern = ^ora_tbls.*.free_space_mb$ retentions = 10m:90d
I am using grafana to visualize the metrics. It looks like:

Nagios Plugin Return Codes

Nagios plugin scripts have to return two things:

1. Exit with a return value
2. A text output to STDOUT

Possible plugin return values are:


Managing Cisco Network Devices using Bash and Expect

Most of the time, managing lots of network devices are troublesome if you do not have a proper management software. In this post i will go through an example. The task that i want to achieve is getting existing tunnel configuration of cisco network devices, then creating a new tunnel configuration using them.

First install expect packages. In my case i use ubuntu:
# sudo apt-get install expect
Make a directory for logs:
# mkdir /tmp/expect_logs
There are some text files and bash, expect scripts: 1. devices_list : IP list of the cisco network devices. 2. : Main Bash script. 3. expect_get.exp : Expect script for getting existing device config. 4. expect_put.exp : Expect script for creating a new device config.
Contents of the scripts accordingly:
Running in a while loop should do the trick. # while read -r line; do ./ $line; done < devices_list