Day: January 2, 2008

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