Monthly Archives: March 2016

Cacti a great tool for monitoring,SNMP polling and network graphing

In today’s world your network consist of multiple LAN’s, WAN’s leading to various switches,devices and routers.You need a centralized tool for monitoring, troubleshooting and graphing where Cacti serves the purpose outstandingly.

Installing cacti on Redhat/Centos/Fedora or Debian systems requires a bit of configuration and dependencies as follows :-

  1. Apache : A Web server to display network graphs created by PHP and RRDTool.
  2. MySQL : A Database server to store cacti information.
  3. PHP : A script module to create graphs using RRDTool.
  4. PHP-SNMP : A PHP extension for SNMP to access data.
  5. NET-SNMP : A SNMP (Simple Network Management Protocol) is used to manage network.
  6. RRDTool : A database tool to manage and retrieve time series data like CPU load, Network Bandwidth etc.

I followed a great blog  below to install Cacti and you an use it for installing on Centos 6/7.

http://blog.network-outsourcing.de/cacti-howtos/cacti/installing-cacti/

Please feel free for any comments or queries.

-Alok Thaker

Start with git

Git has been quite famous today being a subversion or a code repository choice for developers & administrators across the world but git has various advantages as compared to CVS,SVN and other famous versioning systems.

Benefits of using git are as follows :-

  • You Can Work OffilineGit use the concept is local repository where you can commit the changes to the project in your local repository. And therefore git allows you to work completely offline.
  • You Can Work Fast . Most of git’s functions are fast may be because of you have copy of your local repository
  • Repositories Are Smaller In SizeThe repositories of git are smaller in size with compared to subversion.
    You Can Ignore Certain FilesThere may be certain files which you do not require to host of git. These files may be generated by IDE itself. Example of this is log files. You can tell git to ignore these files by a file .gitingnor.
  • Create BranchesSometimes you need to experiment with some features without affecting the main code. Git provides you the new feature with creating branches and can work on that. Different developers can work on different branches without affecting the each other’s code.
  • You Can Check The Status Of Your ChangesIt is very simple that you can check the status of change of your project. The git status command provides you the facility to see what will happen if you commit some changes at a given point of time. It will help us to reduce our mistakes.

You can start using git with public repository on git hub.  Register on https://github.com/ and then on your linux console start with git..you would feel awesome :)

git config –global user.name “aloksai”
git config –global user.email “alok.akki@gmail.com”

echo “# test” >> README.md
git init
git add README.md
git commit -m “first commit”
git remote add origin https://github.com/aloksai/myproject.git
git push -u origin master

You might get permission denied error. So instead of using https use ssh and add your public keys to your github account.  To know how to do it you can use the below link.

https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/

You have to also change the URL after generating keys in .git/config file from https to ssh.

url = ssh://aloksai@github.com/aloksai/testproject.git

To know more git commands please go through this link https://confluence.atlassian.com/bitbucketserver/basic-git-commands-776639767.html

Feel free for any queries or comments.

-Alok Thaker

Open source storage solutions

There has been lot of talks about storage solutions for enterprise, on premise infrastructure,home users etc.  LUN’s, iSCSI,SMBFS,CIFS,NFS etc are different filesystems which can be used for network area storage.

iSCSI is one of my favourite where you can use LUN’s on LVM terminated through iscsi target initiator utils. LUN’s are basically logical unit number which are shared from iSCSI for storage along with slicing .SAN Storage’s are build with mostly Groups of LUNS to become a pool, LUNs are Chunks of a Physical disk from target server.

To know more how to create LUN’s from iSCSI please follow the below link  http://www.tecmint.com/create-luns-using-lvm-in-iscsi-target/.

I am also a big fan of freenas and openfiler which are ready to use open source storage solutions with a great GUI fulfilling all your needs to create network storage and SAN’s.

For freenas go to http://www.freenas.org/ and openfiler on https://www.openfiler.com/products.

Feel free for any comments or queries to me.

-Alok Thaker

Your Set Top Box using open source

STB’s are box-shaped device that converts a digital television signal to analogue for viewing on a conventional set, or that enables cable or satellite television to be viewed.

In the Internet realm, a set-top box is really a specialized computer that can “talk to” the Internet – that is, it contains a Web browser (which is really a Hypertext Transfer Protocol client) and the Internet’s main program, TCP/IP. The service to which the set-top box is attached may be through a telephone line as, for example, with WebTV, or through a cable TV company like TCI.

So if you are looking for an open source package for STB OpenPLi is the best choice supporting various boxes like DM500 : DM500+ : DM56xx : DM500HD :DM600 : DM7000 : DM7020 : DM7025 : DM800 : DM8000 : Vu+ Duo : Vu+ Solo2 : Vu+ Zero.

You can check more about OpenPLi on http://wiki.openpli.org/installation

Feel free for any comment or queries

-Alok Thaker

Using Rsync and inotify tool

rsync as everyone knows it stands for remote sync which is used for file & folders-directories synchronization locally,remotely and also creating mirroring of directories,files between linux machines.

You can install rsync with following commands :-

#yum install rsync (for Redhat-centos systems)

#apt-get install rsync (Debian and ubuntu systems)

Some common options used with rsync commands
  1. -v : verbose
  2. -r : copies data recursively (but don’t preserve timestamps and permission while transferring data
  3. -a : archive mode, archive mode allows copying files recursively and it also preserves symbolic links, file permissions, user & group ownerships and timestamps
  4. -z : compress file data
  5. -h : human-readable, output numbers in a human-readable format

Below command would synch the folder to sync all the files of from one directory to a different directory in the same machine

#rsync -avzh /root/alok /tmp/alok

Suppose you want to sync the directory to a remote machine you can use the below command.

rsync -avzh root@192.168.100.1:/root/alok /tmp/alok

For knowing more in depth of rsync options you can use the following link http://www.tecmint.com/rsync-local-remote-file-synchronization-commands/ which I liked too.

The inotify tool from the inotify-tools provides a way to watch a directory and spit out a live list of changed files without much effort . rsync can handle sync but not persistent so you can use a script to do that.

#!/bin/bash

DEST=”$1″

if [ -z “$DEST” ]; then exit 1; fi

inotifywait -r -m -e close_write –format ‘%w%f’ . |\
while read file
do
echo $file
rsync -azvq $file ${DEST}/$file
echo -n ‘Completed at ‘
date
done

That will monitor the local directory and synchronize it to the remote host every time a file changes. I run it like this:

sync.sh alok@192.168.100.1:/root/alok/

For more details for inotifywait you can see this link :- http://linux.die.net/man/1/inotifywait.

There are other synchronization tools for linux such as cysnc (https://www.csync.org/)  &  freefilesync (http://www.freefilesync.org/) which you can explore.

Feel free to ask for any comment or queries.

-Alok Thaker

NIC Bonding interfaces in Linux

Network bonding is used for increasing bandwidth & redundancy. Bonding helps in acting 2 network cards as one. For eg:- if we have 2 network cards say eth0 and eth1 they can both be bonded and act as one interface as bond0.

Linux uses a special kernel module called bonding to allow users to bond multiple network interfaces into a single channel. NIC bonding may also be called NIC Teaming.

Once the bond is configured it acts like any other Ethernet device. For example, you can configure alias interfaces to handle multiple IP addresses.

mode=0 (balance-rr)
Round-robin policy: Transmit packets in sequential order from the first available slave through the last. This mode provides load balancing and fault tolerance.

mode=1 (active-backup)
Active-backup policy: Only one slave in the bond is active. A different slave becomes active if, and only if, the active slave fails. The bond’s MAC address is externally visible on only one port (network adapter) to avoid confusing the switch. This mode provides fault tolerance. The primary option affects the behavior of this mode.

mode=2 (balance-xor)
XOR policy: Transmit based on [(source MAC address XOR’d with destination MAC address) modulo slave count]. This selects the same slave for each destination MAC address. This mode provides load balancing and fault tolerance.

mode=3 (broadcast)
Broadcast policy: transmits everything on all slave interfaces. This mode provides fault tolerance.

mode=4 (802.3ad)
IEEE 802.3ad Dynamic link aggregation. Creates aggregation groups that share the same speed and duplex settings. Utilizes all slaves in the active aggregator according to the 802.3ad specification.

mode=5 (balance-tlb)
Adaptive transmit load balancing: channel bonding that does not require any special switch support. The outgoing traffic is distributed according to the current load (computed relative to the speed) on each slave. Incoming traffic is received by the current slave. If the receiving slave fails, another slave takes over the MAC address of the failed receiving slave.

mode=6 (balance-alb)
Adaptive load balancing: includes balance-tlb plus receive load balancing (rlb) for IPV4 traffic, and does not require any special switch support. The receive load balancing is achieved by ARP negotiation. The bonding driver intercepts the ARP Replies sent by the local system on their way out and overwrites the source hardware address with the unique hardware address of one of the slaves in the bond such that different peers use different hardware addresses for the server.

To configure bond0 you can use the following link which is quite nice.

https://oracle-base.com/articles/linux/nic-channel-bonding.

Even bond0 can help in running multiple instances of jboss & tomcat on the same port.

Feel free to comment for any queries or comments.

-Alok Thaker