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
Last edited by methyl; 01-26-2012 at 05:25 PM..
Reason: please use code tags
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.
Please help me... Thank you in advance.
Last edited by methyl; 01-26-2012 at 05:28 PM..
Reason: please use code tags
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. :/
Try giving the mount point that you have given in the 1st example as exception and then give it a try.
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.
......
When parsing I am getting a error saying cannot be parsed. Please help.
Thanks,
Chandra
Last edited by methyl; 01-26-2012 at 05:29 PM..
Reason: please use code tags
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).
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 .
Last edited by methyl; 01-26-2012 at 06:47 PM..
Reason: typos, layout, errors, clarification, more typos, correct variable name, more, nearly finished, omg that will do, more typos
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.
Hi
This is script to move log files from one location to other which is working fine. I need to add exception handling in this new to scripting. Please help
#!/bin/ksh
DB=QACCABOP
dumppath='/udb/udbpa032/dump_data/offshore/Tran_logs'
msg='/udb/udbpa032/utilities/DBAscripts/msg/msg.out'... (4 Replies)
Hi All,
Is it possible to compare 2 files using the contents of a third file as a guide using a bash script?
I have 2 files I want t compare (1 and 2 below) the difference between the two is the first line (a)
I want my script to ignore this difference if the difference is stored in file... (5 Replies)
Hi Folks,
please advise , I have logs generated on unix machine at location /ops/opt/aaa/bvg.log , now sometimes there come exception in these logs also, so I want to write such a script such that it should continuously monitor these logs and whenever any exception comes that is it try to find... (3 Replies)
Hi all,
Can u pls guide me in the following requirement,
Am capturing the exceptions and the cause of that exception from a log file.
i cud capture the exceptions by simple grep ie., with the following command
cat logfile | grep "Exceptions"
But i couldn't able to capture the cause... (8 Replies)
The below code throws error in the line number 32 where the function is defined.
But How to find the line where the function is called.
That is I want to throw the error at the line number 43 (as here the function is called).
The code is:
#include <iostream>
#include <string>... (9 Replies)
I have a Netra T1 server running Solaris 8, It was installed by jump start, it does not have a cdrom drive.
Recetly it crashed so I rebooted it from >LOM poweron
and it came to run level 3, all file systems listed in /etc/vfstab are mounted, but /dev and / root are not writeable though in... (3 Replies)
Hi all
Im trying to call a PL SQl block from a ksh file like this :
sqlplus -s $DB_USERID/$DB_PASSWD@$DB_NAME<<eof
whenever SQLERROR exit 1
var varError VARCHAR2(200);
exec ODAS_BATCH_JOBS_RETRIEVE.retrieve_user_info(:varError);
eof
If there is a error then varError will return a... (1 Reply)
Hi all,
I am trying to write a script for an application server log file where i want to put this script as a cron tab entry and it will check the server log file last 1000/500 line for every fifteen minute.
i am using the script like this.
count=`tail -n 1000 Trace.log | grep -c... (1 Reply)
Hi all,
I am writing a set of scripts and some of these are nested within others. I want to be able to execute a single high-level script at the command-line, which in turn may invoke other scripts as required, and when a failure occurs in any of the nested scripts, I want to be able to track... (2 Replies)
hi,
I want to know the date the file was created or modified. I can do this using ls, ll -ltr etc...
I want to do this in a function (so If the file date is older then a week I can report it), is there a way?
another thing...
In sql function, I can catch exceptions, is there a way to do this... (1 Reply)