Shell script to unmonitor the mounts in exception file

I am trying to write a shell script for monitoring the file system mount.
command I am using will retrieve a output as shown below.
/dev/fsv29 2% /apps/rj/pgl/bslSys
I also need to add exception mounts in a file and I would like script to ignore the mount which I specify.
If I add the following entry in exception file /apps/rj/pgl/bslrys , this should be ignored from my alert and should not print the used space.
Please help with some ideas.

Thanks,
Chandra

df -k | awk '{print $1 "        " $5 "       " $6}' | sed '/$1.*/d'

where $1 will be the input input given to that script or the file-name

Thank you for your reply. I will be trying around this. It will be really helpful if you can provide me with a snippet where comparing monitoring mounts and exception file mounts.

Thanks,
Chandra

---------- Post updated at 01:21 PM ---------- Previous update was at 01:06 PM ----------

While I was trying to write the code for this,
I have executed,
df -k | tail +2 | egrep -v '/dev/cd[0-9]|/proc'\ | awk '{print $1, $4, $7}' | wc -l and output is 85. After adding the exception file in the sed command, still it shows 85.

ExceptionFile=/home/apps/Chandra/Exception.txt
MountOut=/home/apps/Chandra/out.txt
df -k | tail +2 | egrep -v '/dev/cd[0-9]|/proc'\ | awk '{print $1, $4, $7}'| sed '/$ExceptionFile.*/d' >> $MountOut

Please help me... Thank you in advance.

egrep -v '/dev/cd[0-9]|/proc'\

In this remove the \ you have... Not sure why is it being used...

And the execption file that you have pasted here, are you sure that this is a mount point?
/home/apps/Chandra/Exception.txt. I have never seen a txt file as a mount point. :confused:

Try giving the mount point that you have given in the 1st example as exception and then give it a try.

Hi,

Thank you for your prompt response. I am trying to put the /apps/PSA/OSAProd
the mount in exception file [ Some text file] and parse that exception mount the command listed above in the while loop.

#!/bin/ksh
ExceptionFile=/home/apps/Chandra/Exception.txt
MountOut=/home/apps/Chandra/out.txt
while read FSexception
do 

df -k |awk '{print $1, $4, $7}'| sed '/$ExceptionFile.*/d' >> Mount.out

done < $ExceptionFile

......

When parsing I am getting a error saying cannot be parsed. Please help.

Thanks,
Chandra

Okay, without testing or looking too closely at the script a some points arise:

1) In Shell code any $ variable between single quote characters is not expanded. The "sed" command never saw the value of $ExceptionFile (but see item 5 below).
2) When dealing with a variable containing a solidus character "/" a solidus is a very bad choice of character for the delimiter in "sed". The delimiter is easily changed.
3) It would really help to see the output from df -k on your system. There is much variety in the output from this command across unix and Linux systems.
4) If you get an error message, please post the exact error message verbatim.
5) Surely the variable in this script is $FSexception not $ExceptionFile.

Let's try "X" as the delimiter in "sed" and change single quotes to double quotes. Not tested beause I know nothing about what Operating System you have or what Shell this is. Hopefuly your "sed" command is correct (I avoid "sed" wherever possible).

df -k |awk '{print $1, $4, $7}'| sed "X${FSexception}.*Xd" >> Mount.out

Personally when I write disc space monitoring scripts I make a positive list in a file of the mountpoints and the upper percentage limit. I seed the initial values once from the current position and make my script tell me when things change in a timely manner. The art of writing this sort of script is to never alert more than once a day for a 1% change, but to continue to alert daily .

Hi Methyl,

Thank you for your prompt response. I will play with the sed and let you know the outcome. This one really looks like a complicated one.
I liked the idea that is posted at the bottom and hopefully I can go with. If possible could you shed us with some raw skeleton code that would be really helpful.

Thanks,
Chandra