Friday, October 29, 2010

Directories and its size for CentOS /Fedora /RedHat

which directories and trees take up all the diskspace?
du -sm $(find /start/dir/* -type d -maxdepth 1 -xdev) | sort -g

If you want more human readable output try:
du -ha /var | sort -n -r | head -n 10

you want to see ALL directories in the tree
find $1 -type d | xargs du -sm | sort -g

To show all directories size including sub directories, type

du -h

To calculate the current directory size you are in (-s stand for summary)

du -sh

To show all the 1 level sub directories size (which you are not interested at sub sub directories.)

du -sh *

To show the size of specific directory

du -sh /home

To show the size of all sub directories of a specific directory

du -sh /home/*

Thursday, October 28, 2010

Setup private cloud computing on Cent OS Eucalyptus 2.0

Eucalyptus is software that implements scalable IaaS-style private and hybrid clouds. The Eucalyptus architecture is highly modular with internal components consisting of Web services, which make them easy to replace and expand. Eucalyptus' flexibility enables it to export a variety of APIs towards users via client tools. Currently Eucalyptus implements the Amazon Web Service (AWS) API, which allows interoperability with existing AWS-compatible services and tools. This also allows Eucalyptus users to group resources drawn both from an internal private cloud and external public clouds to form a hybrid cloud.

#yum install -y java-1.6.0-openjdk-devel ant ant-nodeps libvirt-devel curl-devel httpd httpd-devel apr-devel openssl-devel dhcp libxml2 libxml2-devel gnutls gnutls-devel xen-devel libgcrypt-devel zlib-devel perl-Convert-ASN1 perl-Crypt-OpenSSL-RSA perl-Crypt-OpenSSL-Random chkfontpath scsi-target-utils fuse-libs swig gcc ntp

First, make sure JAVA_HOME is defined. For example, on Centos 5:
export JAVA_HOME="/usr/lib/jvm/java-openjdk/"
export JAVA="$JAVA_HOME/jre/bin/java"
reboot server in xen-kernel

  • run system-config-securitylevel-tui
  • select Security Level: Disabled
  • select OK
#vi /etc/xend/xend-config.sxp
(xend-http-server yes)
(xend-unix-server yes)
(xend-unix-path /var/lib/xend/xend-socket)
(xend-address localhost)
(network-script network-bridge)
(vif-script vif-bridge)
(dom0-min-mem 196)
(dom0-cpus 0)
(vncpasswd '')
download from




















#yum localinstall eucalyptus*

Now start up your Eucalyptus services. On the front-end: 

/etc/init.d/eucalyptus-cloud start
/etc/init.d/eucalyptus-cc start
On the node:
/etc/init.d/eucalyptus-nc start
At this point you should be ready to go through the first-time
Point your browser to, https://front-end-ip:8443 Since Eucalyptus is using a self-signed certificate, your browser is likely to prompt you to accept the certificate. On some machines it may take few minutes after the starting of the Cloud Controller for the URL to be responsive the first time you run Eucalyptus. You will be prompted for a user and password both of which are set to admin initially. Upon logging in the first time you will be asked to
  1. change the admin password,
  2. set the admin's email address, and
  3. confirm the IP of the Cloud Controller host.
    #mkdir $HOME/.euca
    #unzip -d $HOME/.euca 
    #. $HOME/.euca/eucarc

    Adding Images

    To enable a VM image as an executable entity, a user/admin must add a root disk image, a kernel/ramdisk pair (ramdisk may be optional) to Walrus and register the uploaded data with Eucalyptus. Each is added to Walrus and registered with Eucalyptus separately, using three EC2 commands. The following example uses the test image that we provide. Unpack it to any directory: #wget #cd euca-centos-5.3-i386
    #euca-bundle-image -i  --kernel true
    #euca-upload-bundle -b  -m /tmp/.manifest.xml
    #euca-register /.manifest.xml
    Next, add the root filesystem image to Walrus: #euca-bundle-image -i #euca-upload-bundle -b -m /tmp/.manifest.xml #euca-register /.manifest.xml Our test kernel does not require a ramdisk to boot. If the administrator would like to upload/register a kernel/ramdisk pair, the procedure is similar to the above: #euca-bundle-image -i --ramdisk true #euca-upload-bundle -b -m /tmp/.manifest.xml #euca-register /.manifest.xml

Sending mails from command line

Sending mails using mail:
mail (mailx is the newer version) is a fantastic program that can be used for sending email from command line or from within scripts.
The following example will send an email to, with subject “Apache is down” and text “Please check Apache at host name of the server”
echo “Please check Apache at `hostname`” | mail -s “Apache is down”
We can cat the contents of any text file, for example, log file and it will be sent to the recipient specified
cat “/var/log/apache2/error.log” | mail -s “Apache is down”
To attach a file, other than a text one, we need to uuencode (unix to unix encode) it before sending
uuencode banner.jpg banner_out.jpg | mail
The banner.jpg is the name of input file and banner_out.jpg is the output uuencoded file that we will be sent by mail.
To have text sent alogwith the attachment, we can cat or echo that text too
(cat /var/log/apache2/error.log;uuencode banner.jpg banner.jpg) | mail -s pic

Sending mails from using mutt:
With mutt, its same as using mail.
echo “Please check Apache at `hostname`” | mutt -s “Apache is down”
or we can cat the contents of a text file to show as body text
cat /var/log/apache2/error.log | mutt -s “Apache is down”
mutt -s “Apache is down”
To send an empty body mail, use an empty line as the mail body:
echo | mutt -s “Software upgrades for `hostname`”
To attach a binary file, its even easier with mutt, just use the -a option
echo | mutt -s “New logo for the company” -a logo.gif

Wednesday, October 27, 2010

Linux Find FC ID WWNN of a disk/LUN

If your server is connected to more than two SANs of the same type it is really hard to find what disk is on what SAN and how it is connected to your server. You can get the Fiber Channel addresses of the HBAs by typing the following commands:
# systool -c fc_host -v
Type the following command to determine the fibre channel target WWN:
# systool -c fc_transport -v