How to display partition name on mounted on using this script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to display partition name on mounted on using this script
# 1  
Old 07-03-2008
How to display partition name on mounted on using this script

Hi All Guys....

root> df -k|grep /u0

/dev/vx/dsk/oradg/u02vol 12582912 8717924 3744252 70% /u02
/dev/vx/dsk/oradg/u01vol 8796160 5563610 3131556 64% /u01
/dev/vx/dsk/oradg/u04vol 10035200 1247888 8519534 13% /u04
/dev/vx/dsk/oradg/u03vol 12582912 2524060 9744542 21% /u03

root> df -k|grep /u0|awk '{ print $4 }'

3744252
3132546
8519534
9744542
----------------------------------------------------
check_oracle_filesystem.ksh
----------------------------------------------------
#!/bin/ksh

for i in `df -k|grep /u0|awk '{ print $4 }'`
do
# Convert the file size to a numeric value
filesize=`expr i`

# If any filesystem has less than 4000000k, issue an alert
if [ $filesize -lt 4000000 ]
then
echo "Call Fauzi" | mailx -r oraadm@juwpkl.gov.my -s "Oracle filesystem $i has less than 4000000k free"\
adzuan@nc.com.my
fi
done
--------------------------------------------------------------------------------------------------------------
Based on that script, it will display at subject header of the email with " Oracle 3744252 3132546 has less than 4000000k free

My question is, how to display the Partition Name (mounted on) to be display at subject header???



Smilie
# 2  
Old 07-03-2008
i dont't know whether this will help..but i hope so

df -k|grep /u0 > file--->redirect to a temp file

In the main script
val=$(cat tempfile | wc -l ) --> counting the no of lines

execute the loop that many times only

Inside the loop ..read one line from the file

cat tempfile | while read LINE
#LINE --> each line from the file
val1= echo LINE | awk { print $4 }--->get the size
val2 =echo line | cut -d ' ' -f1 ----> this will store the partition name

now you can continue with the if test if a partcular value matches your condition then use the corresponding partition info already stored for mssging

.....hopefully this will work if not ......sorry in advance
# 3  
Old 07-07-2008
Hi Mobydisck
TQ for the suggestion
I'm not very good instead very poor in knowledge about this script
Kindly can u advise me step by step on how to integrate your suggestion into my original script previously...

When u ask me to do "if" test, i'm really out of idea on how to start running the test with your suggestionSmilie.
# 4  
Old 07-07-2008
Try this:

Code:
df -k | awk '$6 ~ /\/u0/ && $4 < 4000000/ { system("echo Call Fauzi | mailx -r oraadm@juwpkl.gov.my -s \"Oracle filesystem " $6 " has less than 4000000k free\" adzuan@nc.com.my") }'


Last edited by Annihilannic; 07-07-2008 at 01:26 AM.. Reason: Forgot destination email address
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to check if file systems are mounted

Hi I have the following piece of code, running on a solaris 10 O.S., that is not working for NFS file systems: for vol in `grep -E 'vxfs|ufs|nfs' /etc/vfstab | egrep -v '^#' | awk '{ print $3 }'` do if df -k $vol | grep $vol > /dev/null then outputOK "Filesystem: $vol mounted" else... (1 Reply)
Discussion started by: fretagi
1 Replies

2. Windows & DOS: Issues & Discussions

How to check if the folders in mounted on which partition?

Hi there, I am able to check which parition from Storage > Disk Management How is it possible to check if the folder is mounted on which partition. (1 Reply)
Discussion started by: alvinoo
1 Replies

3. How to Post in the The UNIX and Linux Forums

NFS mounted and unmounted shell script

Hi, I making a script to check nfs mount and unmount options. After various findings, i didn't get any solution for that. Can you please help me in making the script. 1) I have used, if grep -qs '/var/JETSHARE' /proc/mounts; then echo "It's mounted." else echo "It's not mounted. ... (2 Replies)
Discussion started by: Santosh101
2 Replies

4. Shell Programming and Scripting

sample code to display mounted devices

Hi all I need to write shell script to list out the mounted devices for a particular user. As i am new to shell script please help me. Here the problem is sometime unmounted devices also will be displayed in fstab. How to rectify that? Can anybody help me? Regards Ilamathi (0 Replies)
Discussion started by: ilamathi
0 Replies

5. Shell Programming and Scripting

How to check if a partition is mounted or not with bash?

How to check if a partition is mounted or not with bash? And when is $? variable one? Please give example. (10 Replies)
Discussion started by: cola
10 Replies

6. Ubuntu

display the mounted file system types

how can i list/display the mounted partitions in Ubunutu, mount command just display the devices but not the file system used. (4 Replies)
Discussion started by: XP_2600
4 Replies

7. Shell Programming and Scripting

bash script to get all mounted devices

Hi, to all I'm writing script with zenity to benchmark selected disk with tools like; hdparm, seeker (to found in here > How fast is your disk? | LinuxInsight) With this piece of code i try to get all mounted devices to variables to use it with selection menu, but i stuck and don't know how... (5 Replies)
Discussion started by: m0z4rt
5 Replies

8. Shell Programming and Scripting

bash script to check if mounted, and mount if not

I'd like to make a wrapper bash script that will make sure that an nfs mount is mounted before launching a program that depends on the mount being active. Basically: 1) Check to see if the mount is active 2) If it's not active, try to mount it 3) If it won't mount because the nfs server is... (3 Replies)
Discussion started by: graysky
3 Replies

9. Solaris

swap partition showing mounted in df -h

Dear All Anyone can help me what is the problem of swap partition? swap partition is showing mounted in df -h command output. Regards prakash (1 Reply)
Discussion started by: pshelke
1 Replies

10. SCO

/ partition is mounted but not present in mount

Hello , I 've got a problem with the root partition on my SCO 5.0.5 . When I check the disk with df or mount , I can 't see the root filesystem . # mount /stand on /dev/boot read only on Tue Sep 05 16:13:51 2006 /home on /dev/home read/write on Tue Sep 05 16:14:41 2006 But , if I try... (3 Replies)
Discussion started by: npn35
3 Replies
Login or Register to Ask a Question