Hi All..
Previously i've posted my question regarding this script and i managed to solve the problem but i need to modified my script so it will meet the new requirement.
Below is the script and output:
--------------------------------------------------------------
-bash-3.00$ more check_oracle_filesystem.ksh
#!/bin/ksh
for i in `df -k|grep /ek_|awk '{ print $4 }'`
do
# Convert the file size to a numeric value
filesize=`expr i`
#Display the partiton name that less than 6000000k
df -k|grep /ek_ > /ek_bkup/alert/part_info.txt
# If any filesystem has less than 6000000k, issue an alert
if [ $filesize -lt 6000000 ]
Kindly can u describe more where am i supposed to put that statement??
Is this correct ??
#!/bin/ksh
for i in `df -k|grep /ek_|awk '{ print $4,$6 } | while read avail Mounted on'`
do
# Convert the file size to a numeric value
filesize=`expr i`
# Per filesystem loop
echo "Available Kb = ${avail}"
echo "Mounted on = ${Mounted_on}"
#Display the partiton name
df -k|grep /ek_ > /ek_bkup/alert/part_info.txt
# If any filesystem has less than 6000000k, issue an alert
if [ $filesize -lt 6000000 ]
then
mailx -r oraadm@juwpkl.gov.my -c "encass@nc.com.my"\
-s "Oracle filesystem $i has less than 6000000k free"\ adzuan@nc.com.my < /ek_bkup/alert/part_info.txt
It's a free-standing example of the technique to pick out two values from the same input record using awk. In this case the variable "avail" and "Mounted_on" contain the values you need. Obviously you can call the variables what you like.
The technique can be used to replace your line starting "for i in ....".
In your script only one value can be passed to the do-done loop but you need the mountpoint as well. You will now be able to pass two variables to the do-done loop.
df -k|grep /ek_|awk '{ print $4,$6 }' | while read avail Mounted_on
do
# Per filesystem loop
echo "Available Kb = ${avail}"
echo "Mounted on = ${Mounted_on}"
done
# Convert the file size to a numeric value
filesize=`expr i`
#Display the partiton name
df -k|grep /ek_ > /ek_bkup/alert/part_info.txt
# If any filesystem has less than 6000000k, issue an alert
if [ $filesize -lt 6000000 ]
then
mailx -r oraadm@juwpkl.gov.my -c "encass@nc.com.my"\
-s "Oracle filesystem $ has less than 6000000k free"\ adzuan@nc.com.my < /ek_bkup/alert/part_info.txt