Saturday, 27 April 2013

InnoDB vs MyISAM

InnoDB and MyISAM:

  • InnoDB is newer while MyISAM is older.

  • InnoDB is more complex while MyISAM is simpler.

  • InnoDB is more strict in data integrity while MyISAM is loose.

  • InnoDB implements row-level lock for inserting and updating while MyISAM implements table-level lock.

  • InnoDB has transactions while MyISAM does not.

  • InnoDB has foreign keys and relationship contraints while MyISAM does not.

  • InnoDB has better crash recovery while MyISAM is poor at recovering data integrity at system crashes.

  • MyISAM has full-text search index while InnoDB has not.

In light of these differences, InnoDB and MyISAM have their unique advantages and disadvantages against each other. They each are more suitable in some scenarios than the other.

Advantages of InnoDB:

  •     InnoDB should be used where data integrity comes a priority because it inherently takes care of them by the help of relationship constraints and transactions.
  •     Faster in write-intensive (inserts, updates) tables because it utilizes row-level locking and only hold up changes to the same row that’s being inserted or updated.

Disadvantages of InnoDB:

  •     Because InnoDB has to take care of the different relationships between tables, database administrator and scheme creators have to take more time in designing the data models which are more complex than those of MyISAM.
  •     Consumes more system resources such as RAM. As a matter of fact, it is recommended by many that InnoDB engine be turned off if there’s no substantial need for it after installation of MySQL.
  •     No full-text indexing.

Advantages of MyISAM

  •     Simpler to design and create, thus better for beginners. No worries about the foreign relationships between tables.
  •     Faster than InnoDB on the whole as a result of the simpler structure thus much less costs of server resources.
  •     Full-text indexing.
  •     Especially good for read-intensive (select) tables.

Disadvantages of MyISAM:

  •     No data integrity (e.g. relationship constraints) check, which then comes a responsibility and overhead of the database administrators and application developers.
  •     Doesn’t support transactions which is essential in critical data applications such as that of banking.
  •     Slower than InnoDB for tables that are frequently being inserted to or updated, because the entire table is locked for any insert or update.

The comparison is pretty straightforward. InnoDB is more suitable for data critical situations that require frequent inserts and updates. MyISAM, on the other hand, performs better with applications that don’t quite depend on the data integrity and mostly just select and display the data.

Friday, 12 April 2013

Comment specific lines in VI editor

To Comment specific lines in VI Editor:


:x,y s/^/#/g

x,y -> starting and ending line numbers.

^ -> points to line's begning

# -> usual way to comment in vim


:450,500 s/^/#/g


:.,+10 s/^/#/g

. is current line

+10 is ten lines from the current.

Tuesday, 9 April 2013

Difference Between VIRUS, TROJAN and ROOT-KIT


A virus is normally runs in "stealth mode", hiding itself by infecting executalbes and system files., It still typically runs as an application which is why anti-virus software can detect and remove it.


A trojan, which is an advanced virus, is meant to hide in a more soophisticated fashion.


A root-kit, on the other hand, subverts part of the operating system to hide it self and gain the maximum control possible. Due to this, it is capable of monitoring as well as performing all activities on a system. It can act as a vehicle for other root-kits and virues as well.

Root-Kits turn a computer into a remotely controllable victim, often also making it a spam-bot to send out unsolicited commercial email.

Monitor Remote Linux Host using Nagios:

Configuration steps on the Nagios monitoring server to monitor remote host:

Download NRPE Add-on:

Download nrpe-2.12.tar.gz from and move to /home/downloads:

Install check_nrpe on the nagios monitoring server:

# tar xvfz nrpe-2.12.tar.gz
# cd nrpe-2.1.2
# ./configure
# make all
# make install-plugin
./configure will give a configuration summary as shown below:

*** Configuration summary for nrpe date ***:

General Options:
NRPE port: 5666
NRPE user: nagios
NRPE group: nagios
Nagios user: nagios
Nagios group: nagios

Note: I got the “checking for SSL headers… configure: error: Cannot find ssl headers” error message while performing ./configure. Install openssl-devel as shown below and run the ./configure again to fix the problem.

# rpm -ivh openssl-devel-0.9.7a-43.16.i386.rpm krb5-devel-1.3.4-47.i386.rpm zlib-devel- e2fsprogs-devel-1.35-12.5.

Verify whether nagios monitoring server can talk to the remotehost.
#/usr/local/nagios/libexec/check_nrpe -H
NRPE v2.12

Note: in the ip-address of the remotehost where the NRPE and nagios plugin was installed as explained above.

Create host and service definition for remotehost:

Create a new configuration file /usr/local/nagios/etc/objects/remotehost.cfg to define the host and service definition for this particular remotehost. It is good to take the localhost.cfg and copy it as remotehost.cfg and start modifying it according to your needs.

host definition sample:

define host{
use linux-server
host_name remotehost
alias Remote Host
contact_groups admins

Service definition sample:

define service{
use generic-service
service_description Root Partition
contact_groups admins
check_command check_nrpe!check_disk

Note: In all the above examples, replace remotehost with the corresponding hostname of your

Dont forget to include
 in /usr/local/nagios/etc/nagios.cfg

Restart the nagios service:

Restart the nagios as shown below and login to the nagios web (http://nagios-server/nagios/) to verify the status of the remotehost linux sever that was added to nagios for monitoring.

# service nagios reload


On Red Hat, For me the ./configure command was hanging with the the message: “checking for redhat spopen problem…”. Add --enable-redhat-pthread-workaround to the ./configure command as a work-around for the above problem.

You may also modify commands.cfg to add check_nrpe that was not by default in that file.

# ‘check_nrpe’ command definition
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -t 30 -c $ARG1$

add the following in /objects/commands.cfg of the Nagios server.

define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$

Sunday, 7 April 2013

chkrootkit installation.

chkrootkit installation steps:

# cd /usr/local/src/

– Down load the chkrootkit.
# wget

- Unpack the chkrootkit you just downloaded.
# tar -xvzf chkrootkit.tar.gz

- Change to new directory
# cd chkrootkit-*
(select the version )

- Compile chkrootkit
# make sense

- Run chkrootkit
# ./chkrootkit

How to setup a daily scan report?

- Load crontab
# crontab -e

- Add this line to the top:
0 1 * * * (cd /usr/local/src/chkrootkit*; ./chkrootkit 2>&1 | mail -s “chkrootkit output”

Nagios: CRITICAL - Socket timeout after 10 seconds

Socket timeout after 10 seconds:

As any other monitoring system Nagios can produce false alarms. Usually it happens when Nagios fails to get the reply from the host being monitored during some pre-defined timeout. In order to mark service as down Nagios does three checks and if all of them are failed then the service is marked down and administrator will got an alert about its critical status. At the same time even if one of those checks fails Nagios will report administrator about it depending on configuration.

If you face some false alarms occasionally but the service is actually online then it makes sense to increase timeout value from default 10 seconds to, let’s say, 20 seconds.


Open one of nagios’ configs where check commands are defined (usually it’s /etc/nagios/commands.cfg file) and find there a block named check_nrpe, add “-t 20″ to the end of its command_line so it will look like below:

define command {
    command_name    check_nrpe
    command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -t 20

And restart Nagios.

Besides check_nrpe there are also other commands like check_http, check_smtp and others: all of them supports -t options so just modify them like check_nrpe depending on your Nagios timeout conditions.

NagiOS Server Monitoring Tool- LINUX

Quick installation steps:

Nagios is an enterprise-class open source computer/network monitoring software with on-going enhancements from its vibrant community made up of worldwide supporters.

User account and group ID:

[root@ranjith ~]# useradd -m nagios
[root@ranjith ~]# passwd nagios
[root@ranjith ~]# groupadd nagcmd
[root@ranjith ~]# usermod -a -G nagcmd nagios
[root@ranjith ~]# usermod -a -G nagcmd apache

Download the latest Nagios Core and Nagios Plugins source files or just use just uses wget to download as below,

Nagios Core:

[root@ranjith ~]# wget

compile and install the Nagios core:

[root@ranjith ~]# tar -zxvf nagios-3.2.3.tar.gz
[root@ranjith ~]# cd nagios-3.2.3

FYI: From next execution onwards, you may use tee command to duplicate output to a file for examination, which could be useful to trace errors that triggered when compiling source code.

[root@ranjith ~]# ./configure --with-command-group=nagcmd

Compile the Nagios source code (piping to tee command is optional)

[root@ranjith ~]# make all | tee make_all.nagios_core.log

Install the compiled binaries of Nagios Core:

[root@ranjith ~]# make install
[root@ranjith ~]# make install-init
[root@ranjith ~]# make install-config
[root@ranjith ~]# make install-commandmode

Edit contact.cfg file to update email address of nagiosadmin for receiving alerts:

[root@ranjith ~]# vi /usr/local/nagios/etc/objects/contacts.cfg

replace your personal email ID instead of "nagios@localhost".

Install Nagios web config file to Apache conf.d directory:

[root@ranjith ~]# make install-webconf

Create an user account for logging into the Nagios web interface:

[root@ranjith ~]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Restart Apache (httpd) to make the new settings take effect:

[root@ranjith ~]# service httpd restart

Add Nagios to System services and configure it to start up automatically when boots into runlevel 3 and 5:

[root@ranjith ~]# chkconfig --add nagios
[root@ranjith ~]# chkconfig --level 35 nagios on

Now, We need to install standard Nagios plugins which are used to monitor various computer/network status.

Nagios Plugins:

[root@ranjith ~]# wget

let’s unpack:

[root@ranjith ~]# tar -zxvf nagios-plugins-1.4.15.tar.gz
[root@ranjith ~]# cd nagios-plugins-1.4.15

Run configure file to explicitly set ownership to nagios:nagios respectively:

[root@ranjith ~]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios

Ready to compile and install Nagios Plugins binary files:

[root@ranjith ~]# make
[root@ranjith ~]# make install

Verify the sample Nagios configuration files (the files used to define how and what services or hosts to monitor by Nagios Core via the various plugins):

Through the file: /usr/local/nagios/etc/nagios.cfg you can modify the useful options such LOG ROTATION METHOD, DEBUG LEVEL, AUTO-RESCHEDULING OPTION, SLEEP TIME, TIMEOUT VALUES, FLAP DETECTION THRESHOLDS and TIMEZONE OFFSET.

[root@ranjith ~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Total Warnings: 0
Total Errors:   0

start up of Nagios:

[root@ranjith ~]# service nagios start

http://Your-server-IP/nagios ( kindly stop iptables )

To reset admin panel password:

[root@ranjith ~]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

If you face blank page on the browser! after the successfull reach on nagios home page.?

kindly check the error log:

script not found or unable to stat: somefile.cgi


[root@ranjith html]# chcon -R -t httpd_sys_content_t /usr/local/nagios