Home » Infrastructure » Unix » shell scripting
shell scripting [message #225342] Mon, 19 March 2007 13:37 Go to next message
plshelp
Messages: 205
Registered: January 2007
Senior Member
Hi all,

I need to change the below script to ignore the monitoring for the cdrom..This script checks the entire filesystem.. Can somebody help me what to add in the script to ignore the monitoring for the cdrom? Thank you.

##set the oraenv profile
if [ -s /home/ora/oracle10.profile ]
then
. /home/ora/oracle10.profile
fi
##
export SCRATCH_DIR=/temp
export FILE_FULL=$SCRATCH_DIR/file_full$hostname.log
hostname=`hostname`
if [ ! -d $SCRATCH_DIR ]
then
mkdir $SCRATCH_DIR
fi
# Delete old files.
rm -f $SCRATCH_DIR/db_filesys*
cat /dev/null > $SCRATCH_DIR/db_filesys.$hostname
#
# Find all the file systems that needs to be monitored.
#
echo "****** Monitoring the File System for `hostname` ******
`date`"> $SCRATCH_DIR/db_filesys.$hostname
df -k >> $SCRATCH_DIR/db_filesys.$hostname
# Check filesystem is full
egrep -i "95%|96%|97%|98%|99%|100%" < $SCRATCH_D\
IR/db_mon_filesys.$hostname > $FILE_FULL
# Check file is not empty
if [ -s $FILE_FULL ]
then
echo " Filesystem full->$hostname"
echo "
Filesystem full->$hostname">>$SCRATCH_DIR\
/db_filesys.$hostname
mailx -s "File system full->`hostname` " michelle_g@getch.com < $SCRATCH_DIR/db_filesys.$hostname
else
mailx -s "File System on `hostname` " michelle_g@getch.com < $SCRATCH_DIR/db_filesys.$hostname
fi
exit

LOGFILE:

Filesystem kbytes used avail capacity Mounted on
/vol/dev/dsk/c1t0d0/sol_9_905_sparc/s5 31 2 26 8% /cdrom/sol_9_905_sparc/s5
/vol/dev/dsk/c1t0d0/sol_9_905_sparc/s4 31 2 26 8% /cdrom/sol_9_905_sparc/s4
/vol/dev/dsk/c1t0d0/sol_9_905_sparc/s3 31 2 26 8% /cdrom/sol_9_905_sparc/s3
/vol/dev/dsk/c1t0d0/sol_9_905_sparc/s2 31 2 26 8% /cdrom/sol_9_905_sparc/s2
/vol/dev/dsk/c1t0d0/sol_9_905_sparc/s1 506399 479106 0 100% /cdrom/sol_9_905_sparc/s1
/vol/dev/dsk/c1t0d0/sol_9_905_sparc/s0 2405544 2405544 0 100% /cdrom/sol_9_905_sparc/s0
/dev/md/dsk/d220 106447246 63601395 41781379 61% /bkup
/dev/md/dsk/d60 34190853 4851724 28997221 15% /ora
.
.
.
.
.

Please advise how I can ignore the checking for cdrom space in the script..Help appreciated..Thanks..

Re: shell scripting [message #225371 is a reply to message #225342] Mon, 19 March 2007 15:49 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10708
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
Use grep.
Selectively ignore whatever you want to ignore.
Here, i am ignoring my mounted mp3 filesystem.
bigfoot:~ mahesh_rajendran$ df -k
Filesystem              1K-blocks     Used    Avail Capacity  Mounted on
/dev/disk0s3             29168832 18487732 10425100    64%    /
devfs                          96       96        0   100%    /dev
fdesc                           1        1        0   100%    /dev
<volfs>                       512      512        0   100%    /.vol
automount -nsl [220]            0        0        0   100%    /Network
automount -fstab [224]          0        0        0   100%    /automount/Servers
automount -static [224]         0        0        0   100%    /automount/static
/dev/disk1s0               673810   673810        0   100%    /Volumes/Ilayaraja Hits 1
bigfoot:~ mahesh_rajendran$ df -k | grep -v "Hits"
Filesystem              1K-blocks     Used    Avail Capacity  Mounted on
/dev/disk0s3             29168832 18487732 10425100    64%    /
devfs                          96       96        0   100%    /dev
fdesc                           1        1        0   100%    /dev
<volfs>                       512      512        0   100%    /.vol
automount -nsl [220]            0        0        0   100%    /Network
automount -fstab [224]          0        0        0   100%    /automount/Servers
automount -static [224]         0        0        0   100%    /automount/static
bigfoot:~ mahesh_rajendran$ 
Re: shell scripting [message #225601 is a reply to message #225342] Tue, 20 March 2007 08:06 Go to previous message
plshelp
Messages: 205
Registered: January 2007
Senior Member
Thank you very much Mahesh..that worked.
Previous Topic: How to run batch jobs parallely using shell script
Next Topic: Junk Character in VI editor
Goto Forum:
  


Current Time: Thu Nov 28 16:01:17 CST 2024