Month: January 2008

Does your past impact your future?

Does your past impact your future?

Have you ever think about this question ? One and half year back Nirav (Nirav Mehta, Chief mentor of Magnet Technologies) introduced me to Landmark forum. Before completing this forum , I am also thinking that the past alway impact your future and whatever you are today is because of our past!!. Now I know that my past doesn’t impact my future and who I am today is not because of the past but because of future and the possibilities I have created for my future. This possibilities and action I am taking on, will decide who I am today!!

So you might thinking how this is possible? Let me give you same small example,they give me one and half year back to convince me. Suppose when parent told to children that they are going to Goa for 2 days trip. What will be the natural reaction of children? The children will be very happy before going to Goa. So it does indicate that the children are happy because of there future, which is that they are going to Goa. And after two days, when they are on railway platform to return back to there native hometown. What would be the reaction of children? You can easily guess about what they were thinking and about there feeling. Now I think you have clear idea about this question? right!!

Think on it and create new possibilities for your future. So that you will be powerful and you can deal your life powerfully!!.

Thank you,

Arun Bagul

Configure the Tape Library in Linux

Configure the Tape Library in Linux

To check autoloader/library detected or not, give command

root@indiangnu.org:/home/arun# cat /proc/scsi/scsi

If it is not show changer, Do following steps

Check the version of Redhat Linux

If it is Redhat Linux 3

Add following line in /etc/modules.conf

“options scsi_mod max_luns=255”

“options scsi_mod scsi_noreportlun=1”

If it is Redhat Linux 4

Add following line in /etc/modprobe.conf

“options scsi_mod max_luns=255”

“options scsi_mod scsi_noreportlun=1”

 

Then create new initrd file…..

root@indiangnu.org:/home/arun# cd /boot

Rename initrd file

root@indiangnu.org:/home/arun# mv initrd-`uname –r.img initrd-`uname-r.main

e.g. mv initrd-2.6.9-42.EL.img initrd-2.6.9-42.EL.main

root@indiangnu.org:/home/arun# mkinitrd initrd-`uname –r`.img `uname –r`

e.g. mkinitrd initrd-2.6.9-42.EL.img 2.6.9-42.EL

At the end REBOOT your Linux box.

and again you have to re-scan. using first command cat /proc/scsi/scsi

Thank you,

Ravi Bhure

Shell script to monitor or watch the disk space

Shell script to monitor or watch the disk space

#!/bin/sh
# Shell script to monitor or watch the disk space
# It will send an email to $ADMIN, if the (free avilable) percentage
# of space is >= 90%
# ————————————————————————-
# Linux shell script to watch disk space (should work on other UNIX oses )
# SEE URL: http://www.indiangnu.org
# set admin email so that you can get email
ADMIN=”ravi@indiangnu.org”
# set alert level 90% is default
ALERT=90
df -H | grep -vE ‘^Filesystem|tmpfs|cdrom’ | awk ‘{ print $5 ” ” $1 }’ | while read output;
do
#echo $output
usep=$(echo $output | awk ‘{ print $1}’ | cut -d’%’ -f1 )
partition=$(echo $output | awk ‘{ print $2 }’ )
if [ $usep -ge $ALERT ]; then
echo “Running out of space \”$partition ($usep%)\” on $(hostname) as on $(date)” |
mail -s “Alert: Almost out of disk space $usep” $ADMIN
fi
done

=================

Thank You,

Ravi Bhure

Shell script to monitor running services such as web/http, ssh, mail etc.

Shell script to monitor running services such as web/http, ssh, mail etc.

#!/bin/bash
# Shell script to monitor running services such as web/http, ssh, mail etc.
# If service fails it will send an Email to ADMIN user
# ————————————————————————-
# See URL for more info
# http://www.indiangnu.org
# —————————————————
# service port
ports=”22 80 25″

# service names as per above ports
service=”SSH WEB MAIL”

# No of services to monitor as per (above ports+1)
SCOUNTER=4

#Email id to send alert
ADMINEMAIL=”ravi@indiangnu.org”

# counter
c=1
echo “Running services status:”

# use sudo if you want i.e. sudo /bin/netstat
/bin/netstat -tulpn | grep -vE ‘^Active|Proto’ | while read LINE
do
sendMail=0
# get active port name and use : as delimiter
t=$(echo $LINE | awk ‘{ print $4}’ | cut -d: -f2)
[ “$t” == “” ] && t=-1 || :
# get service name from $services and : as delimiter
sname=$(echo $service | cut -d’ ‘ -f$c)
sstatus=”$sname: No”
# now compare port
for i in $ports
do
if [ $i -eq $t ]; then
sstatus=”$sname: Ok”
sendMail=1
fi
done
# display service status as OK or NO
echo “$sstatus”
#next service please
c=$( expr $c + 1 )
[ “$sendMail” == “0” ] && echo $sstatus | mail -s “service down $sstatus” $ADMINEMAIL || :
# break afer 3 services
[ $c -ge $SCOUNTER ] && break || :
done

==========================

Thank you

Ravi Bhure

Start & stop oracle service

Start & stop oracle service

This script is useful for start and stop oracle services in *nix OS.

Put this script in /etc/init.d/ with name oracle-start-stop-service.sh & change its permission to 555 (-r-xr-xr-x).

====================

#!/bin/bash
# oracle-start-stop-service.sh
# Run level script to start Oracle 10g services on RedHat Enterprise Linux (RHAS 4)
# Script should work on other UNIX like oses

# ————————————————————————-
# chkconfig: 345 91 19
# description: Startup/Shutdown Oracle service
# ————————————————————————-
# Before using this script check & edit what are your appropriate path and user credentials.
#

OUSER=”oracle”
OPATH=”/home/oracle/oracle/product/10.2.0/db_1″

# check Oracle db status
function chkdb_status() {

# set username
SUSER=”scott”
# set password
SPASS=”123456″

sqlplus -s /nolog > /dev/null 2>&1 <<EOF
whenever sqlerror exit failure
connect $SUSER/$SPASS
exit success
EOF

if [ $? -ne 0 ]; then
echo “Connection failed : DB is down”
exit 1
else
echo “Connection succeeded : DB is up”
fi
}

case “$1” in
start)
echo “*** Starting Oracle *** ”
su – $OUSER -c “$OPATH/bin/lsnrctl start”
su – $OUSER -c “$OPATH/bin/dbstart”
;;
stop)
echo “*** Stopping Oracle *** ”
su – $OUSER -c “$OPATH/bin/lsnrctl stop”
su – $OUSER -c “$OPATH/bin/dbshut”
;;
restart)
$0 stop
$1 start
;;
isqlstart)
echo “*** Starting Oracle iSQL Plus *** ”
su – $OUSER -c “$OPATH/bin/isqlplusctl start”
echo “*** Note: You can access service at url: http://$(hostname):5560/isqlplus”
;;
isqlstop)
echo “*** Stopping Oracle iSQL Plus *** ”
su – $OUSER -c “$OPATH/bin/isqlplusctl stop”
;;
emstart)
echo “*** Starting Oracle Enterprise Manager 10g Database Control ***”
su – $OUSER -c “$OPATH/bin/emctl start dbconsole”
echo “*** Note: You can access service at url: http://$(hostname):1158/em”
;;
emstop)
echo “*** Stopping Oracle Enterprise Manager 10g Database Control ***”
su – $OUSER -c “$OPATH/bin/emctl stop dbconsole”
;;
status)
echo “*** Oracle database status ***”
chkdb_status
;;
*)
echo $”Usage: $0 {start|stop|isqlstart|isqlstop|emstart|emstop}”
exit 1
esac
exit 0

===================

Thank you

Ravi Bhure

Quick editing of a command

Quick editing of a command

Sometimes when you try to execute a long command, it scrolls beyond the screen. Then if you want to modify the command and re-execute it, there is an easy way for it. Just type “fc” which will load the command in your default editor; in my case vi. Now you can modify the command in the editor and exit the editor, and your modified command is executed automatically.

For example try typing the following command in the bash shell and type “fc“.

$ find /etc -iname '*.conf' -exec grep -H 'log' {} \;

$ fc

“fc” will bring the last command typed into an editor, “vi” if that’s the default editor. Of course you can specify a different editor by using the -e switch as follows:

$ fc -e emacs

To list last few commands, type:

$ fc -l

For the last 10 commands it will be:

$ fc -l -10

To seach for a command, type “CTRL+r” at the shell prompt for starting a search as you type prompt. Once you found your command, press enter to execute it.

If you want to transpose two characters say you typed ‘sl’ instead of ‘ls’. Then move the cursor between ‘sl’ and type “CTRL+t“.

Thank you,

Ravi Bhure