Dec 20, 2011

Online LUN Detection in RHEL

Online LUN Detection in RedHat Enterprise Linux

RedHat Enterprise Linux

Detect Newly assigned LUN in RHEL without reboot the server


1)       Install the required packages

                                # yum install sysfsutils sg3_utils

2)       We need the below parameters to rescan the scsi bus

                                H – HBA Number
                                C – Channel on the HBA
                                T – SCSI target id
                                L – LUN id

3)       We can get the above said parameters using the different command, for me I am using “systool” and “sg_map” command

            # systool -c fc_host -v
            Class Device = "host3"
            Class Device path = "/sys/class/fc_host/host3"
            port_name = "0x2100001b32882e82"

Note : In the above sample output class device path is “host3”. So 3 is the HBA number, if dual channel HBA means like the above host4 also will displayed. Here port name is the HBA's wwn id.

            # systool -c fc_transport -v
            Class Device = "0:0"
            Class Device path = "/sys/class/fc_transport/target3:0:0"
            port_name = "0x200400a0b84889b5"
Note: In the above command output, class device path is “3:0:0”, that is in the order of “HBA number:channel on HBA:SCSI Target id”  (H:C:T). Here port name is the storage's wwpn id.

            # sg_map -x

            /dev/sg0  0 0 0 0  0
            /dev/sg1  0 0 1 0  0
            /dev/sg2  0 1 0 0  0  /dev/sda
            /dev/sg3  3 0 0 0  0
            /dev/sg4  3 0 0 31  0
            /dev/sg5  3 0 1 0  0  /dev/sdb
            /dev/sg6  3 0 1 1  0  /dev/sdc
            /dev/sg7  3 0 2 0  0  /dev/sdd
            /dev/sg8  3 0 2 1  0  /dev/sde
Note: In the above command output, first four digits as represents “H C T L” also known as Host, Bus, Target, Lun  (H B T L). From this we can identify how many luns are already mapped.

4)       Now rescan the SCSI bus using the said parameters

                                # echo “C T L” > /sys/class/scsi_host/HostH/scan

Note: If u are having dual channel HBA card means scan both the HBA numbers using the above command .

5)       Now check with the fdisk command, whether the LUN is detected or  not. If not means use the below command

                                # echo “1” > /sys/class/fc_host/hostH/issue_lip

Note: The above command instruct the driver to rediscover the remote ports. LIP (Loop Initialization  Protocol).

6)       Now confirm with the fdisk command and use the LUN as usual.

Dec 10, 2011

GZIP Compression in Apache

GZIP Compression in Apache Webserver


            The mod_deflate module provides the DEFLATE output filter that allows output from your server to be compressed before being sent to the client over the network.
            The mod_deflate module does not have a lower bound for file size, so it attempts to compress files that are too small to benefit from compression. This results in files smaller than approximately 120 bytes becoming larger when processed by mod_deflate.

RedHat Enterprise Linux
Apache Webserver 2.x

Need to enable the gzip compression in the apache webaserver using the mod_deflate module.


1)       Make sure that mod_deflate module is loaded in the configuration file
2)       Mention what type of files gets compressed in the http configuration file

            BrowserMatch ^Mozilla/4 gzip-only-text/html
            BrowserMatch ^Mozilla/4\.0[678] no-gzip
            BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

3)       Add the exception using the blow syntax

            SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
            SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary

Note: The above two lines mention that don't compress the image files (gif,jpe and png) and the pdf files. Like the above syntax we can exclude any other format.

4)       If u want to enable the seperate log for the gzip compression use the blow entries in the http configuration file.

            <IfModule mod_deflate.c>
            DeflateFilterNote Input inputstream
            DeflateFilterNote Output outputstream
            DeflateFilterNote Ratio ratiostream
            LogFormat '"%r" %{outputstream}n/%{inputstream}n (%{ratiostream}n%%)' deflate

Note: In the log, how much the pages are compressed information available.

5)       Restart the http service to take the changes effect.

                        # service httpd restart

Dec 1, 2011

Webalizer Configuration in Linux

Webalizer Configuration for apache in Linux

            The Webalizer is a GPL application that generates web pages of analysis, from access log. It is simple to configure and easy to run.
RedHat Enterprise Linux

Need to monitor the webserver hits using webalizer.


1)    Install the webalizer rpm

                        # yum install webalizer

2)    Mention the webserver log path in the webalizer configuration file

            # vi /etc/webalizer.conf

            LogFile         /etc/httpd/logs/access_log.2.gz
            OutputDir       /opt/webalizer_apache
            Incremental     yes
            IncrementalName webalizer.current

Note: For my webserver i used logrotate to rotate all my logs. So i mentioned the rotated log file to update the hits. We can mention any webserver access log file (if you didn't have logrotate "/etc/httpd/logs/access_log" will be your default log location of apache webserver). "Incremental"  keyword allows to rotate the logs.

3)    Logrorate script used by me is

            # vi /etc/logrotate.d/apache

            /etc/httpd/logs/*log {
            rotate 20
            /bin/kill -HUP `cat /etc/httpd/logs/ 2>/dev/null` 2> /dev/null || true

Note: If  you want to know more about logrotate refer

4)    Log rotate will rotate the logs in every day morning. So i put one cron entry to update the webserver hits  in the daily basics.

            # crontab -e

            4 30 * * * /usr/local/bin/webalizer -c /etc/webalizer.conf

5)    In that output directory “index.html” file will be there using that we can browse webserver hits history
6)    Or we can add the webalizer output directory to the webserver “Document Root” by creating one symbolic link.

            # ln -s /opt/webalizer_apache /var/www/html/webalizer_apache

Note: Here “/var/www/html” is my “Document Root” in apache web server.

7)    Now we can access the webalizer page from the webserver itself by using the below URL


Nov 11, 2011

db documentation using schemaspy in linux

SchemaSpy in Linux

            SchemaSpy is a Java-based tool that analyzes the metadata of a schema in a database and generates a visual representation of it in a browser-displayable format. It lets you click through the hierarchy of database tables via child and parent table relationships as represented by both HTML links and entity-relationship diagrams.
RedHat Enterprise Linux
MSSQL 2005

Need to create database documentation using SchemaSpy utility.


1)    JVM 1.5 or above
2)    Graphviz (graph visualization software)
3)    JTDS 1.2.5
4)    HTTP Server (Optional)


1)    Download the JVM from the below URL


2)    Give the executable permission and install the downloaded java

            # chmod +x jdk-1_5_0_22-linux-amd64.bin
            # ./jdk-1_5_0_22-linux-amd64.bin

3)    Then download the graphviz package from the below URL

4)    Install the downloaded the rpm using rpm or yum

                        # yum install graphviz

5)    Downlad the JTDS from the below link


6)    JTDS is used to connect the MSSQL database. JTDS does not need any special installation.

7)    Download the SchemaSpy from the below link


8)    Before running the schemaspy make sure that, the “dot” program should be in your PATH. If not present then we need to mention the path of that command using “-gv” option.
9)    Now execute the below command to create the relationship diagrams

                        # /opt/jdk1.5.0_22/bin/java -jar /asp/data/schemaSpy_5.0.0.jar -t mssql05-jtds -u user -p password -db database  -host IPAddress -port 1433 -o /opt/test_schema/ -s schemaname -dp /opt/jtds/jtds-1.2.5.jar

            -t → Type of database (e.g. ora, db2, etc.). Defaults is ora
            -u → Valid database user id with read access.
            -p → Password associated with that user. Defaults to no password.
            -db → Name of database to connect to
            -host → database server ip or hostname
            -port → tcp port used to connect the database
            -o → Directory to write the generated HTML/graphs
            -s → Database schema
            -dp → Looks for drivers here before looking in driverPath

10)  The above command takes some time that depends upon your schema size and generate the graphs in the given output directory (in my case /opt/test_schema/).
11)  In that output directory “index.html” file will be there using that we can browse everything.
12)  If we have http server installed in the same server means we can include this directory to the “Document Root” by creating on symbolic link.

                        # ln -s /opt/test_schema/ /var/www/html/test_schema

Note: Here “/var/www/html” is my “Document Root” in apache web server.

13)  Now we can access the schemaspy graphs through the webserver.

Nov 9, 2011

Install Expect in Linux

Install Expect in Linux


As per wiki "Expect is a Unix automation and testing tool for interactive applications such as telnet, ftp,  fsck, rlogin, ssh, and others".

From man page "Expect is a program that "talks" to other interactive programs according to a script".

RedHat Enterprise Linux

Need to install the "expect" package in RHEL Server for scripting.


1)    Download the ecpect package from the below link


2)    Install the required dependecy packages "Tcl/Tk" language toolkit

                        # yum install tcl

3)    Install the "expect" package using the below commands

            # tar -zxvf expectx.xx.tar.gz
            # ./configure
            # make
            # make install