Tuesday, January 28, 2014

You don't have permission to access /nagios/ on this server.

For this issue we have to just install php package and try to restart apache service and it should work with out any issue.

Friday, September 27, 2013

syntax error at line 10, near "$h ("

Perl language have bit different mechanism when dealing with errors. Some points you should know before debugging errors.

1)Always use shebang statement with  -w option as shown below.
#!/usr/bin/perl -w
2)Always use strict and warnings package to report all syntax errors.
use strict;
use warnings;

When you get above error do not just check error on the given line try to check before and after the line of error report. This tip will resolve most of your errors like missing closing brace "}", sentence termination like ";", etc.

Can't find string terminator "EOF " anywhere before EOF at line 21.

This issue will come when you are using EOF or EOM string to send multiple line to a perl print statement or a command. Just have look at below code

I have a file descriptor which will take input from a string as shown below.

printf FD1 "this my first line";

This will work with out any issue, but when you want to send multiple lines as shown below we have to use PERL here-docs as shown below.

printf FD1 << EOM;

other than this syntax, if you give any other thing it will fail. Observe that there is no double quotes before or after EOM and there is a ; colon after first EOM. We even have to remember that there should not be any space between << and EOM. Hope this helps some one who did this mistake.

Tuesday, September 17, 2013

Can't open /dev/sdb1 exclusively. Mounted filesystem?

This is an issue we will get for many reasons, one reason we get this error is when we try to use the partition which is already mounted or used in your machine. This occurs some times due to LVM which is not properly implemented

If you fee this is new partition and want to unlock the file from kernel follow below steps

Step1: Check what are the partitions known to the kernel by using proc file system as shown bleow

[root@gnani surendra]# cat /proc/partitions
major minor  #blocks  name

   8        0    8388608 sda
   8        1    5120000 sda1
   8        2    1024000 sda2
   8        3    2240906 sda3
   8       16    8388608 sdb
   8       17     112423 sdb1
   8       18     112455 sdb2
   8       19     112455 sdb3
 253        0     112423 dm-0
 253        1     112455 dm-1
 253        2     112455 dm-2

Step2: Check if your required partition is in the list or not? If yes, then try to check status of that disk by using dmsetup command as shown below

[root@gnani surendra]# dmsetup status
sdb3: 0 224910 linear
sdb2: 0 224910 linear
sdb1: 0 224847 linear

Step3: If you see your desired partition, try to unlink it from the kernel

dmsetup remove sdb1

Now try to use your partition and see if you still have issue. Hope this helps someone in need.

Wednesday, May 8, 2013

Perl Error: readdir() attempted on invalid dirhandle

Q. I am seeing "readdir() attempted on invalid dirhandle DIR at" error when attempting to open a directory using readdir function in Perl. How can I resolve this?

The error "readdir() attempted on invalid dirhandle DIR at" clearly states that PERL was unable to open directory by using readdir function. There are number of situations which causes this error

1)Check if user who executed perl script have permissions on that directory or not. User should have read permissions to open a directory in Perl. Check permissions by using ls command.

2)Check if directory exists or not? Sometimes users will forgot to check if directory exists or not before opening a directory. To avoid this we can use below code to check before opening a directory.

opendir DIR, $SRCDIR || die ("Can not open dir $SRCDIR");

Keep this line before readdir function so that it will give you a meaningful error message before reading a directory.

3) Are you reading an input from user? Then make sure that your variable which contain directory name should not contain newline character. So use chop or chomp function to remove last character.


This will chop of last character.

Hope this helps someone when dealing with open directory in perl.

Tuesday, May 7, 2013

Solution for: mv: cannot move `' to a subdirectory of itself,

Q. How can I move all my files in my working directory to a sub-directory with the working directory? I am getting error "mv: cannot move `' to a subdirectory of itself," Can I move all the files/folder to sub-directory with out this error?

Yes, you can move all your files/folders present in your directory to a sub-directory with out getting that error. This error will occure when mv command try to move this sub-directory as well which it can not do and throws this error. All you have to do set shopt extglop option and try below command

shopt -s extglob
mv !(subdir) subdir/

Know more about shopt here.

Thats it, you will not see the error as shown above. hope this helps some one.

Thursday, May 2, 2013

isohybrid: Warning: more than 1024 cylinders: isohybrid: Not all BIOSes will be able to boot this devic

Q. I am facing issue "isohybrid: Warning: more than 1024 cylinders:  isohybrid: Not all BIOSes will be able to boot this devic", How can I resolve this?

First this is not an issue or error. This is just a warning not an error and it is just a warnning. This warning will be displayed when you are trying to convert a normal ISO file to hybrid ISO file by using isohybrid command

isohybrid /path/to/normal/iso/file

This error will come when your ISO file is more than 1GB size.

Wednesday, February 27, 2013

error: Requested operation is not valid: Disk does not support snapshotting

error: Requested operation is not valid: Disk  does not support snapshot

This error arises when you try to take a snapshot of a VM hard disk with virsh command
as shown below

virsh snapshot-create Clusterbase

error: Requested operation is not valid: Disk '/path/to/kvm/clusterbase.img' does not support snapshot.

If you see image of this VM is .img format, by default Virsh snapshot will work only for qcow2 format as of time of this post writing. So first convert that image to qcow2 format and then try to do a snapshot t with same command.

Convert img file to  qcow2 format

qemu-img convert -f raw -O qcow2 /path/to/kvm/clusterbase.img /path/to/kvm/clusterbase.qcow2

Hope this helps to resolve this error.

Sunday, February 24, 2013

Loaded plugins:fastest mirror Loading mirror speed from cached hosfile Setting up install process Nothing to do

Q. I am seeing below error when installing some packages

 Loaded plugins:fastest mirror
  Loading mirror speed from cached hosfile
  Setting up install process
  Nothing to do

This error will come when you execute below command

yum install somepackage

and the repo is set with "enable=0", try to change it or use --enablerepo= as shown below.

yum --enablerepo=yourreponame install somepackage

If you set enable=0 that indicates that dont include this repo when installing RPM packages. And enable=1 will include this repo when installing packages.

Hope this helps some one.

Friday, February 22, 2013

error: command 'save' requires option

This error will come when you are trying to save VM using virsh command. When you try to save VM status using Virt-manager we no need to mention any file to save the status. Virt-manager will take care of saving it. But virsh have no mechanism like this. We have to provide a file to save the machine status.

virsh save domaname filename

virsh save linux1 /opt/linux1.stat