Wednesday, 24 December 2014

Resovled: /lib/ bad ELF interpreter: No such file or directory after installing HDSentinel:

For: Debian/Ubuntu

# apt-get update
# apt-get install ia32-libs

For: CentOS/RedHat/Fedora/Suse/Mandriva

# yum -y install glibc.i686

Monday, 25 August 2014

Nagios: CRITICAL - Could not interpret output from ping command

PING     UNKNOWN /bin/ping -n -U -w 10 -c 5 xx.xx.xx.xx

Nagios monitoring page showing above error when configuring in the client host ?

'Set-user-ID-on-execution permission' to fix the issue,

# ls -al /bin/ping
-rwxr-xr-x. 1 root root 40760 xxx xx  xxxx /bin/ping

# chmod u+s /bin/ping  // fix the issue.

# ls -la /bin/ping
-rwsr-xr-x. 1 root root 40760 xxx xx  xxxx /bin/ping

Nagios: -bash: /usr/local/nagios/libexec/check_nrpe: No such file or directory

To fix "check_nrpe: No such file or directory"

# cd
# wget http://prdownloads.
# tar zxvf nrpe*.tar.gz
# cd nrpe*
# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
# cd ./src/
# make check_nrpe
# mv ./check_nrpe /usr/local/nagios/libexec/

Now you can find: /usr/local/nagios/libexec/check_nrpe !!!

Thursday, 21 August 2014

STOP :: logging query cache denied to /var/log/messages :: named

How to stop logging query cache denied to /var/log/message and /var/named/data/ ?


Adding the following to your /etc/named.conf will stop logging the cache denied messages:

category security { null; };

So named.conf will looking like below:


logging {
    category security { null; };
    channel default_debug {
            file "data/";
            severity dynamic;


Thursday, 14 August 2014

HowTo : Execute BASH Shell Commands over MySQL environment in Linux?

Yes, We can execute shell commands over mysql environment without exit by adding "\! " before commands as like "\! command",

mysql> \! uptime
 06:52:18 up 36 min,  1 user,  load average: 0.00, 0.00, 0.00

mysql> \! pwd

(or) We can get the shell prompt here by doing,

mysql> \! bash


mysql> \! sh

HowTo: Get current working database information in mysql?

Add the below lines in /etc/my.cnf


your  mysql environment will be,


To revert this,

HowTo: Get hostname in mysql environment?

Add the below lines in /etc/my.cnf


Also in /root/.my.cnf should have below,

please make sure the hostname should be valid and added in /etc/hosts

If you would like to return default PROMPT of mysql(this time only)

Returning to default PROMPT of mysql>

Enjoy !!....

Sunday, 13 July 2014

Insert another file's content to current file - VI Editor

Easy way to insert another file's content to current file using VI is,

> Open the file

# vi myfile.txt

:r myanotherfile.txt

Here we can use r or read to load myanotherfile.txt on myfile.txt, Now the myanotherfile.txt's contents placed immediately after the current line.

If you wish to place the contents in particular line ?

Okay, If you wish to place the myanotherfile.txt's contents on myfile.txt at 5th line,

> Open the file

# vi myfile.txt

:4r myanotherfile.txt

so that the contents of myanotherfile.txt were placed immediately after the 4th line ( obviously on 5th line as we required).

You can do this without opening the myfile.txt:

Below command to insert myanotherfile.txt's contents on myfile.txt:

# sed -i 'r myanotherfile.txt' myfile.txt

now myanotherfile.txt's contents on myfile.txt at second line( I hop we already know why it placed on second line ! ),

If you wish to place this on 5th line, then:

# sed -i '4r myanotherfile.txt' myfile.txt

If you would like to insert a word on particular line ?

yes we can, the same way:

# sed -i '4a NEW LINE ADDED' myfile.txt

You can see the 'NEW LINE ADDED' on myfile.txt at 5th line.


Monday, 30 June 2014

Libxml error while compiling dual php - "make: *** [ext/dom/node.lo] Error 1"

Libxml error while compiling dual php - "make: *** [ext/dom/node.lo] Error 1"

ext/dom/node.c: In function 'dom_canonicalization':
ext/dom/node.c:1953:21: error: dereferencing pointer to incomplete type
ext/dom/node.c:1955:5: error: dereferencing pointer to incomplete type
make: *** [ext/dom/node.lo] Error 1

This is a PHP error when compile the older version when install libxml2 from bigger version 2.9.0.


Need to update patch.

+ vi libxml29_compat.patch

+ copy and paste below code in the file: 'libxml29_compat.patch'


--- ext/dom/node.c    2012-08-06 17:49:48.826716692 +0800
+++ ext/dom/node.c    2012-08-06 17:52:47.633484660 +0800
@@ -1895,9 +1895,17 @@ static void dom_canonicalization(INTERNA
     } else {
         if (mode == 0) {
+            ret = xmlOutputBufferGetSize(buf);
             ret = buf->buffer->use;
             if (ret > 0) {
+                RETVAL_STRINGL((char *) xmlOutputBufferGetContent(buf), ret, 1);
                 RETVAL_STRINGL((char *) buf->buffer->content, ret, 1);
             } else {
--- ext/dom/documenttype.c    2012-08-06 18:02:16.019640870 +0800
+++ ext/dom/documenttype.c    2012-08-06 18:06:16.612228905 +0800
@@ -205,7 +205,13 @@ int dom_documenttype_internal_subset_rea
         if (buff != NULL) {
             xmlNodeDumpOutput (buff, NULL, (xmlNodePtr) intsubset, 0, 0, NULL);
+            ZVAL_STRINGL(*retval, xmlOutputBufferGetContent(buff),
+                         xmlOutputBufferGetSize(buff), 1);
             ZVAL_STRINGL(*retval, buff->buffer->content, buff->buffer->use, 1);
             return SUCCESS;
--- ext/simplexml/simplexml.c    2012-08-06 18:10:44.621017026 +0800
+++ ext/simplexml/simplexml.c    2012-08-06 18:12:48.016270419 +0800
@@ -1417,7 +1417,12 @@ SXE_METHOD(asXML)

             xmlNodeDumpOutput(outbuf, (xmlDocPtr) sxe->document->ptr, node, 0, 0, ((xmlDocPtr) sxe->document->ptr)->encoding);
+            RETVAL_STRINGL((char *)xmlOutputBufferGetContent(outbuf),
+                           xmlOutputBufferGetSize(outbuf), 1);
             RETVAL_STRINGL((char *)outbuf->buffer->content, outbuf->buffer->use, 1);
     } else {


+ run the bleow commnad from php-source path:

# patch -p0 < libxml29_compat.patch

Am sure, Now you can go-ahead with # ./configure --your modules.......


Sunday, 29 June 2014

Boot Failure after Latest Kernel Update - "warning: selinux targeted policy relabel is required"

warning: selinux targeted policy relabel is required

When rebooting the server due to kernel upgrade we may face below error due to "SELinux is in permissive mode, the operation would have been denied but was permitted due to permissive mode."


Warning -- SELinux targeted policy relabel is required. Relabeling could take a very long time, depending on file system size and speed of hard drives.


SELinux is preventing access to files with the label, file_t.


We have done below steps to overcome the issue,

> Login the server through KVM

> Enter into single user mode.

> Edit the file: "/etc/selinux/config" as below




> exit from single user mode

Now the box will boot-up normally. :) !!!

Thursday, 12 June 2014

KVM disk performance: raw vs qcow2 & Steps to Convert raw to qcow2

Disk Format: Raw vs. Qcow2:

The libvirt(The virtualization API. libvirt is: A toolkit to interact with the virtualization capabilities of recent versions of Linux (and other OSes))  snapshots can only be performed on certain type of disk formats. There are several types of VM disk formats, but the most  common are raw and qcow2 (copy-on-write).

    * qcow2 [ "QEMU Copy-On-Write" ]

    * qcow2 is an updated version of the qcow format, intended to supersede it. The main difference with the original is that qcow2 supports multiple virtual machine snapshots through a new, flexible model for storing snapshots.

*   Users can easily convert qcow disk images to the qcow2 format. QEMU and Xen have retained the qcow format for backwards compatibility.

How qcow2 works:

*   Raw disks are presented as-is to the VM without any disk layering and do not support snapshots, whereas qcow2 disks support a range of special features including snapshots, compression and encryption.

*   Raw disks have better I/O performance than qcow2 because the VM disk space is pre-allocated before the VM is created, as opposed to qcow2, where VM disk space is thinly provisioned and allocated on-the-go as the VM requires it.

*   If you create a VM with a raw disk of 10 GB, you?ll see that the disk image size for the VM will be exactly 10 GB, whereas for a VM with a qcow2 disk the actual file size will be a fraction of 10 GB (say 2-3 GB) and it will grow as you occupy disk space inside the VM.

Verify VM disk format:

# file /vm-images/vm1.img
/vm-images/vm1.img: Qemu Image, Format: Qcow, Version: 2

# qemu-img info /vm-images/vm1.img
image: /vm-images/vm1.img
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 3.2G
cluster_size: 65536

Converting disk format from raw to qcow2:

It is easy to convert from a raw VM image (which doesn?t support libvirt snapshots) to qcow2 format. In this example, we convert an image file of size 10 GB for a VM called vm2.

1. Shut down the VM:

# virsh shutdown vm2

2. Let's take a look at the image file format:

# cd /vm-images

# qemu-img info vm2.img
image: vm2.img
file format: raw
virtual size: 10G (10737418240 bytes)
disk size: 10G

3. The conversion process actually makes a qcow2 copy of the raw image and leaves the raw image intact.

The command is:

# qemu-img convert -f raw vm2.img -O qcow2 vm2.qcow2

* The new image file extension is irrelevant; we use “qcow2” to help us identify the different image format.

* The conversion process will take a few minutes, depending on the size of the image file.

4. Let's take a look at the new image file format:

# qemu-img info vm2.qcow2
image: vm2.qcow2
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 3.2G
cluster_size: 65536

* Notice that the virtual size remains unchanged, it is still 10 GB.

* The disk size (as the OS sees it) will be less than 10 GB. In our case, it is 3.2 GB. If you run the „ls –l? command on the file, its reported size will match the “disk size” reported here. As you add files inside the VM disk, this file size will increase, up to a maximum of 10 GB.

Friday, 2 May 2014

kernel: EXT3-fs warning (device hda3): ext3_dx_add_entry: Directory index full!

kernel: EXT3-fs warning (device hda3): ext3_dx_add_entry: Directory index full!

To trace the actual directory limit:

find / -type d | ( while read A; do B=`ls -l "$A" | wc -l`; echo $B $A; done) | sort -n

It was not a bug, but a limit. Ext3's hash directores are limited to depth of 3 blocks, which normally is not a problem if a 4k blocksize is being used, since each internal node is small; only 8 bytes. So there is a fanout of 508 for each internal node, and two internal nodes gets to over 250,000 4k directory blocks. But with a 1k blocksize, the internal node fanout is only 124, so that only gets a bit more than 15,000 1k directory blocks.

The enduser recreated the file system using the default 4k blocksize to avoid this situation.


Tuesday, 15 April 2014

How to FIX Ownership issues under cPanel based server ?

Here is a simple script to solve the ownership issue under cPanel based server,

# echo -e “Checking ownership”
for i in `ls /var/cpanel/users/`

if [ "$i" != "root" ]; then
chown -R $i:$i /home/$i
chown $i:nobody /home/$i/public_html /home/$i/.htpasswds
chown $i:mail /home/$i/etc /home/$i/etc/*/shadow /home/$i/etc/*/passwd
echo $i


Yeah !!!

Monday, 10 March 2014

Swap space calculation | Unix / Linux:

In general,

* 2GB swap space for 4GB of RAM or less.
* 4GB swap space for 4-16GB of RAM
* 8GB swap space for 16-64GB of RAM
* 16GB swap space for 64-256GB of RAM
* 32GB swap space for 256-512GB of RAM

But, Here is some-more detailed information about calculating swap space,

Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.

Swap should equal 2x physical RAM for up to 2 GB of physical RAM, and then an additional 1x physical RAM for any amount above 2 GB, but never less than 32 MB.

So, if:

M = Amount of RAM in GB, and S = Amount of swap in GB, then

Using this formula, a system with 2 GB of physical RAM would have 4 GB of swap, while one with 3 GB of physical RAM would have 5 GB of swap. Creating a large swap space partition can be especially helpful if you plan to upgrade your RAM at a later time.

For systems with really large amounts of RAM (more than 32 GB) you can likely get away with a smaller swap partition (around 1x, or less, of physical RAM).


Sunday, 9 March 2014

LINUX - Detailed history of the commands:

Through 'history' command, We can see what are all the commands used before,

Normal 'history' command output:

#  history
    1  ls
    2  cd /
    3  cd
    4  cd /var/log/
    5  cd ..
    6  cd /
    7  cd
    8  history
Can we get more / exact details about when the commands were performed ?

Yes, we can get more information by usgin " export HISTTIMEFORMAT='%F %T ' "

After performing " export HISTTIMEFORMAT='%F %T ' ", the output goes like,

# export HISTTIMEFORMAT='%F %T '
# history
    1  2014-03-07 07:11:57 ls
    2  2014-03-07 07:12:00 cd /
    3  2014-03-07 07:12:01 cd
    4  2014-03-07 07:12:18 cd /var/log/
    5  2014-03-07 07:12:21 cd ..
    6  2014-03-07 07:12:24 cd /
    7  2014-03-07 07:12:25 cd
    8  2014-03-07 07:12:28 history
    9  2014-03-07 07:13:31 export HISTTIMEFORMAT='%F %T'
   10  2014-03-07 07:13:3 4history

Cheers !!!

Thursday, 6 March 2014

measuring exact IO wait:LINUX

iostat - Report Central Processing Unit (CPU) statistics and input/output statistics for devices and partitions.

We can get detailed report from iostat with N for LABEL.

# iostat -xN 1

Device:         rrqm/s   wrqm/s     r/s     w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util
sda               0.00     4.00   51.00    2.00 11640.00    48.00   220.53     0.08    1.49   1.42   7.50
zz_root     0.00     0.00    2.00    6.00    48.00    48.00    12.00     0.00    0.00   0.00   0.00
yyy_swap     0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
xxxxx_home     0.00     0.00   49.00    0.00 11592.00     0.00   236.57     0.08    1.61   1.53   7.50

fuser: command lists the process numbers of local processes that use the local or remote files specified by the File parameter.

-v        verbose output
-m        show all processes using the named filesystems

# fuser -vm xxxxx_home

Friday, 10 January 2014

su: cannot set user id: Resource temporarily unavailable - Linux

   Restricting direct root login and using Wheel user always make better security, but some cases we may face below error,

"su: cannot set user id: Resource temporarily unavailable" 

To overcome this issue, we need to add / increase the number of processes value in /etc/security/limits.conf.

A quick check about the number of operating system processes.

# ps -U wheel-user | wc -l

To add / increase the below value in /etc/security/limits.conf

# wheel-user soft nproc(maximum number of processes) value
admin soft nproc 2048

If this won't work,

vi /etc/security/limit.conf
# add / change on these line:
*          soft   nproc       2047
*         hard   nproc       16384
*         soft   nofile       2048
*         hard   nofile      65536

Now you can try to login once again.. it will works.