check an nfs mount in a script

Hi,
Ive been looking for a way to do this but cant figure it out.

I have a script that checks an nfs mount with this condition (linux
bash) and makes sure its not full:

dirpresent=`df -T | grep -w nfs | grep -w $nfsdir | grep -wv "100%"`
if [ -n "$dirpresent" ]; then
etc etc
fi

My problem is if the nfs server is down, then the df command hangs so
the whole script hangs. Is there a way I can time the reponse so if
say I dont get a response after 5 seconds, then abort the df check?

Thanks
0
cconnell_1
7/3/2008 10:04:40 PM
comp.unix.shell 15269 articles. 0 followers. Post Follow

5 Replies
1190 Views

Similar Articles

[PageSpeed] 16
On Thu, 03 Jul 2008 19:04:40 -0300, <cconnell_1@lycos.com> wrote:

> Hi,
> Ive been looking for a way to do this but cant figure it out.
>
> I have a script that checks an nfs mount with this condition (linux
> bash) and makes sure its not full:
>
> dirpresent=`df -T | grep -w nfs | grep -w $nfsdir | grep -wv "100%"`
> if [ -n "$dirpresent" ]; then
> etc etc
> fi
>
> My problem is if the nfs server is down, then the df command hangs so
> the whole script hangs. Is there a way I can time the reponse so if
> say I dont get a response after 5 seconds, then abort the df check?
>
> Thanks
> 


Try this:

read -t5 dirpresent < <(df -T | grep -w nfs | grep -w $nfsdir | grep -wv "100%")
0
mop2
7/3/2008 11:29:09 PM
On 4 Jul, 00:29, mop2 <inva...@mail.address> wrote:
> On Thu, 03 Jul 2008 19:04:40 -0300, <cconnel...@lycos.com> wrote:
> > Hi,
> > Ive been looking for a way to do this but cant figure it out.
>
> > I have a script that checks an nfs mount with this condition (linux
> > bash) and makes sure its not full:
>
> > dirpresent=`df -T | grep -w nfs | grep -w $nfsdir | grep -wv "100%"`
> > if [ -n "$dirpresent" ]; then
> > etc etc
> > fi
>
> > My problem is if the nfs server is down, then the df command hangs so
> > the whole script hangs. Is there a way I can time the reponse so if
> > say I dont get a response after 5 seconds, then abort the df check?
>
> > Thanks
>
> Try this:
>
> read -t5 dirpresent < <(df -T | grep -w nfs | grep -w $nfsdir | grep -wv "100%")- Hide quoted text -
>
> - Show quoted text -


thanks this worked well. one side effect is after the script it leaves
the df -t commands around and also the script says its running from
ps.
is there any way to terminate the df or send a control-c to it after
the timeout?

0
cconnell_1
7/4/2008 12:30:50 AM
On Thu, 03 Jul 2008 21:30:50 -0300, <cconnell_1@lycos.com> wrote:

> On 4 Jul, 00:29, mop2 <inva...@mail.address> wrote:
>> On Thu, 03 Jul 2008 19:04:40 -0300, <cconnel...@lycos.com> wrote:
>> > Hi,
>> > Ive been looking for a way to do this but cant figure it out.
>>
>> > I have a script that checks an nfs mount with this condition (linux
>> > bash) and makes sure its not full:
>>
>> > dirpresent=`df -T | grep -w nfs | grep -w $nfsdir | grep -wv "100%"`
>> > if [ -n "$dirpresent" ]; then
>> > etc etc
>> > fi
>>
>> > My problem is if the nfs server is down, then the df command hangs so
>> > the whole script hangs. Is there a way I can time the reponse so if
>> > say I dont get a response after 5 seconds, then abort the df check?
>>
>> > Thanks
>>
>> Try this:
>>
>> read -t5 dirpresent < <(df -T | grep -w nfs | grep -w $nfsdir | grep -wv "100%")- Hide quoted text -
>>
>> - Show quoted text -
>
>
> thanks this worked well. one side effect is after the script it leaves
> the df -t commands around and also the script says its running from
> ps.
> is there any way to terminate the df or send a control-c to it after
> the timeout?
>
> 


If the df survived, this may be a better solution:

if mount|grep -q ' nfs ' && df -T | grep -w nfs | grep -w $nfsdir | grep -q -wv "100%";then
etc etc
0
mop2
7/4/2008 12:50:01 AM
On Thu, 03 Jul 2008 17:30:50 -0700, cconnell_1 wrote:

> On 4 Jul, 00:29, mop2 <inva...@mail.address> wrote:
>> On Thu, 03 Jul 2008 19:04:40 -0300, <cconnel...@lycos.com> wrote:
>> > Hi,
>> > Ive been looking for a way to do this but cant figure it out.
>>
>> > I have a script that checks an nfs mount with this condition (linux
>> > bash) and makes sure its not full:
>>
>> > dirpresent=`df -T | grep -w nfs | grep -w $nfsdir | grep -wv "100%"`
>> > if [ -n "$dirpresent" ]; then
>> > etc etc
>> > fi
>>
>> > My problem is if the nfs server is down, then the df command hangs so
>> > the whole script hangs. Is there a way I can time the reponse so if
>> > say I dont get a response after 5 seconds, then abort the df check?
>>
>> > Thanks
>>
>> Try this:
>>
>> read -t5 dirpresent < <(df -T | grep -w nfs | grep -w $nfsdir | grep
>> -wv "100%")- Hide quoted text -
>>
>> - Show quoted text -
> 
> 
> thanks this worked well. one side effect is after the script it leaves
> the df -t commands around and also the script says its running from ps.
> is there any way to terminate the df or send a control-c to it after the
> timeout?

Another way of doing this is with http://stromberg.dnsalias.org/~strombrg/
maxtime.html  It's specifically written with NFS mounts in mind.

However, on a hard,nointr mount, maxtime will leave processes behind too, 
though they should die as soon as the mount comes back.

To get around that, you'll probably need to change the mount options on 
your NFS mount - probably in /etc/fstab, /etc/vfstab, /etc/checklist, or 
an automount map.  You could probably change it to soft (mount will time 
out and disappear after a while) or intr (processes attempting to use the 
mount are interruptible even if the NFS mount is timing out).

0
Dan
7/4/2008 12:53:15 AM
cconnell_1@lycos.com writes:

> dirpresent=`df -T | grep -w nfs | grep -w $nfsdir | grep -wv "100%"`
> if [ -n "$dirpresent" ]; then
> etc etc
> fi
>
> My problem is if the nfs server is down, then the df command hangs so
> the whole script hangs. Is there a way I can time the reponse so if
> say I dont get a response after 5 seconds, then abort the df check?


Decades ago when I had to deal with this (we had 100's of NFS file
servers), I seem to recall it was better to launch a job in the
background, if an NFS job might hang it up.

So it might be better to have a loop run the "df" command in the
background, and in another shell check the output. 

I did two other things to reduce the risk of server hanging:
  1) Keeping excess directories out of my searchpath

  2) creating a directory on the local machine that had symbolic links
  to the executables on remote diorectories, and use this directory in
  my searchpath instead of the other).

0
Maxwell
7/5/2008 11:45:04 AM
Reply:
Similar Artilces:

check one two check check
check check one twoo Stifler wrote: > check check one twoo You're supposed to say that into a microphone. Here it goes like this: "this is a test, please ignore." -- _______________________________________________________________________ Christopher R. Carlen Principal Laser/Optical Technologist Sandia National Laboratories CA USA crcarle@sandia.gov -- NOTE: Remove "BOGUS" from email address to reply. ...

Problem with PHP Server-Side Script
I got the JS fix I needed earlier, but now I have another problem. For some reason, I cannot get my PHP script for style switching to be recognized by any browser except Safari, which is ridiculous. I got it from http://www.webligo.com/products_styles.php and it has been the only PHP style switcher script that has worked thus far for me on any browser. Here is the test site: http://www.amandahenson.com/testsite/ Amanda H. wrote: > I got the JS fix I needed earlier, but now I have another problem. > For some reason, I cannot get my PHP script for style switching to be > recognize...

PATH Check Code Not Updating Current Directory #2
Hello, A previous post by n6vc on Sep 15, 12:29 pm: \<< A B C D E BarSag 6 \->LIST "Foot Measurement" { { "A:" "Moveable Foot, Outbrd to Inbrd" } { "B:" "Movable Foot, Inbrd to Dial X" } { "C:" "Dial X to Dial Y" } { "D:" "Dial Y to Fixed Foot, Inboard" } { "E:" "Fixed Foot, Inboard to outboard" } { "BarSag" "Measure Bar Sag" } } { 2 1 } { 0 0 0 0 0 0 } 5 ROLL INFORM \>> was modified by me to ensure the current path is { HOME Alignment } before run...

Checking for XSS ?
All, Does the check below ensure that the files are originating from my server, i.e. to prevent or detect any type of XSS ? Or is the HTTP_HOST easily spoofed ? function test ($refer) { if (!stristr($refer, $_SERVER["HTTP_HOST"])) { die(); } else { } } test ($_SERVER["HTTP_HOST"]); Any better ideas ? Many thanks. "StinkFinger" <stinky@pinky.com> wrote in message news:<10alovs4861j233@corp.supernews.com>... > All, > Does the check below ensure that the files are originating from my server, > i.e. to prevent or detect > any type of XSS ...

very high iowait with Linux 2.6 and nfs
Hi NG, I've been googling and posting in some mailing lists without any success. In my private network, I have an NFS server (PI-200 with debian woody with vanilla 2.4.20) and two clients - Athlon 2000+ with debian woody and vanilla 2.6.2 and a Centrino Notebook with debian sarge and a vanilla 2.6.4. My problem is the same with both client systems. When I copy a large file (about >10MB) to or from the server, the iowait fills up the remaining free processor load and the responsiveness of the client becomes very bad. If I copy lots of small files, the processor load rises s...

Need help to check/extend a proof.
Another question from the archive: L = {<M1><M2><M3>|L(M1)!=L(M2) and L(M2)!=L(M3) and L(M1)!=L(M3)} Is this recursive? RE but not recursive? Not RE? <Mi> is the encoding of TM Mi. I started my proof with a 2 machine case: We know that 1. L2 = {<M1><M2>|L(M1)=L(M2)} is undecidable 2. L2' = {<M1><M2>|L(M1)!=L(M2)} is the complement of L2 So we know that L2' is not recursive. I try to proof that L2' is RE: To prove L(M1)!=L(M2), we only need one string that L(M1) accepts and L(M2) does not. So we construct a non-deterministic TM ...

NFS server/client
I've set up a Linux NFS server with 2 network cards on 2 different networks. Network A) eth0 has IP 151.89.63.10 on the net 151.89.63.0/255.255.255.0 Network B) eth1 has IP 172.31.1.16 on the net 172.31.1.0/255.255.255.0 NFS works fine on workstation on network A, doesn't work on network B. Networks are identical and NFS clients (workstations Linux) are, too. Everything is open, I can ping, telnet... almost everything. This is the error on the workstation on network B when trying to mount: # mount gess10:/nas3 /CS1 mount: RPC: Port mapper failure - RPC: Unable to recei...

calling ksh script from python
hi all, I'm trying to call ksh script from python. I have a file (toto.env) with a scirpt looking like: -- begin --- #!/bin/ksh # export TOTO_ENV=/home/toto -- end --- I call it from python like that: -- begin --- import commands commands.getstatusoutput('. toto.env') -- end --- but it always return an error saying: sh: TOTO_ENV=/home/home: is not an identifier doesn anyone know why ? no matter what I use (popen,system...) it's always the same error... if I directly try to do commands.getstatusoutput('export TOTO_ENV=/home/toto') it's the same error... and what...

Dev-Pascal Range checking.
Hi Guys, I am trying out the Dev-Pascal compiler and am trying to implement range checking with the following code: program Untitled; type grade = 'A'..'E'; var my_grade : grade; begin my_grade := 't'; writeln('expecting some sort of runtime error'); readln end. I kind of expected a runtime error, but the assignment to my_grade is happily accepted, any ideas. Thanks, Kevin Wright. On 2004-10-14, news.ntlworld.com <kwright@nospam.com> wrote: > Hi Guys, > > I am trying out the Dev-Pascal compiler and am trying to im...

check it out this is awesome
http://www.darkwars.org/index.php?a=click&id=92490 kenshin13 wrote: >(snip) Who the fsck are you, and why should we follow a link, described merely as "awesome", posted by some idiot who has never-before posted in here? chrisv blithely blithered > kenshin13 wrote: > >>(snip) > > Who the fsck are you, and why should we follow a link, described > merely as "awesome", posted by some idiot who has never-before posted > in here? It has a click ID, most likely an advertisement. he could be getting paid by the click. That post is probably ...

Calling script from lookup
Hello, I need to put a text on a field that is the result of "collecting" sub strings from other records. I know how to write a script that collects the substrings and put them in the field. Now I would like to call the script from a lookup so that when the record is created (in a portal) the script is called. Is this possible? I am running FM7 Thanks There are a couple of free plugins that will activate a script upon change to a field. EventScript from http://www.softs4humans.com and zippScript from http://homepage.mac.com/jkornhaus/ Tip: I haven't really done anythi...

checkbox bug: never checked on read
Hi, the following problem only occurs with wvwtools, xharbour without wvwtools works correct: problem setting default value for checkbox as checked: #include "wvwtools.ch" local bVar1 := .t. local bVar2 := .f. @ 10,10 get bVar1 checkbox caption "bvar-1" @ 12,10 get bVar2 checkbox caption "bvar-2" read don't show bVar1 as checked. both checkboxes are unchecked. how can I set bVar1 as checked?!? regards Dirk On 8 nov, 17:23, dirk <dirk.bl...@t-online.de> wrote: > Hi, > > the following problem only occurs with wvwtools, xharbour without >...

Upload file format checking
Hi, What is the best way to validate that an uploaded file (using CGI.pm) is a tab delimited table of the correct format? I.e. every line has the same number of columns as the header, and the header has to match a predefined set of table headers. Should it be done as the file is read in? After I store it to disk? Suggestions for implementations? Thanks, B Bryan <spam@nospam.com> wrote: > Hi, > > What is the best way to validate that an uploaded file (using CGI.pm) is > a tab delimited table of the correct format? I.e. every line has the > same number of columns...

how to check installed RAM module and free slots
hi, please let me know how to check installed RAM module and slot information. SUN Sol8,Sol9 search google for memconf. /Arjun On Mar 6, 3:08 am, "nad" <prashanth.na...@gmail.com> wrote: > hi, > please let me know how to check installed RAM module and slot > information. SUN Sol8,Sol9 ...

spell checking in emacs
how can I add a dictionary to the predefined dict's list in emacs? -- �������� � M2 - ��������� �̦��Ԧ �������� Opera: http://www.opera.com/m2/ -- �������� � M2 - ��������� �̦��Ԧ �������� Opera: http://www.opera.com/m2/ ...

Printing asterix's when typing in passwords from a shell script
Hi, I'm trying to find a way to print *'s when a user types a password in after being prompted by my script to enter it. I've found a way to stop anything being printed using stty -echo and that will have to do if there's no other way but I'd at least like the user to get some feedback as they're typing. Any ideas people? Thanks in anticipation. Bryn Ellis <bryn.ellis@gmail.com> wrote: > I'm trying to find a way to print *'s when a user types a password in > after being prompted by my script to enter it. > I've found a way to stop anythi...

Script that checks for existence of file on remote server.
Hi - I would like to know if there is a way in shell scripting to check the existence of a file after FTP? Basically if the file does not exist in a certain directory, the shell script should fail. thanks, val vegas_girlie <minnie_valerie@hotmail.com> wrote: > I would like to know if there is a way in shell scripting to check the > existence of a file after FTP? Basically if the file does not exist in > a certain directory, the shell script should fail. if [ ! -f somefile ]; then exit 1 fi to check for the existence of a certain file. Yours, Laurenz Albe If I read the ...

Checking on a checked radio-button
I have a few radio-buttons in my gui application. I want to implement the following behavior: If the user clicks on a radio-button that is already checked, it will stay checked. I tried the following code on a radio-button called �radioModeA�, but it doesn�t work. Can someone help please? (I�m working with Matlab 6.5, so I don�t have button-group). function radioModeA_Callback(hObject, eventdata, handles) Val = get(hObject,'Max'); if (get(hObject,'value') ==Val) set(hObject, 'value', Val); set(handles.radioModeB, 'value', 0); else set(handles.radio...

how to check if autogenerated checkbox is checked or not ?
Hello, I have small script which generates some listboxes. Their names are listXX (list01, list02, list03....). How to check if there are checked or not ? If I have 1 listbox and have it's name I do $_POST['list01']. But what to do in that situation ? Sincerely, Dmitrij I am sorry for my mistake. I mean check box and not $_POST... but $list01 = "on" :) <dkultasev@gmail.com> wrote in message news:1192224080.641241.93210@v23g2000prn.googlegroups.com... > Hello, > I have small script which generates some listboxes. Their names are > listXX (list01, lis...

How to open html page in python resource file? ActiveX and Java script addEventListener? Options
Hi friends, I have an interesting question. Is it possible to open HTML page from python resources (Sorry, I don't know how to use the resources) like we can open using Win32 from .rc files. Can that page contain references to scrips in the resource file? Another question is reagrding ActiveX on win32. ActiveX usually calls Java Script function to notify. In webpage we can add it using document.addeventlistener but those are not available using CallFunction method of ActiveX. But if we decided to use it directly (without web browser) then how can we register Listeners? There ...

Virus Checker Blocked a Script, But...
Hi All My Norton blocked a script from a web site yesterday and after disconnecting from my default dial-up connection today, I am no longer able to click on IE6 and dial-up, it always says no connection available. On my PC I have 3 dial up connections set up with "dial when no connection present" selected. In the past, when I clicked on IE6 it used to bring me the connection box with my default dial up selected and then I would always click connect with no problems. I tried to re-set my default as follows: IE6 tools, internet options, connections, set as default, click apply...

Re: Check for empty dataset #3
Dear Nicole, During the compilation (so far before execution) phase the number of observations (NOBS) already is set to your variable HowMany. Now, if the dataset is really empty the implicit DATA step loop terminates right after the SET statement, so your code never runs. The easiest and nicest solution in your case is to combine the code for both empty and non-empty datasets in one data step as below. The tric is to force running at least some code with an empty dataset by moving that code to before the SET statement; and as HowMany already is known there (from the compilation phase) this i...

Writing a Script/Program to use a DNS Block List for spam?
Hello, I've been looking high and low for the protocol required to communicate with a DNSBL, such as the one at spamhaus.org. That is, I'd like to know how to send commands and get and decipher responses from such servers. I want to write a program to filter email via this and other similar lists, but I can't find the technical information. I do find information on how to configure pre-existing software, but nothing on how I can write my own software to check one of these DNSBLs against an IP address to determine if an email is spam. When I say technical information, ...

Can't mount VMS-TCPIP-NFS served disk on SunOS 4.1.4 client
For no very good reason, I recently resurected a SPARCstation IPC running SunOS 4.1.4, and tried to NFS-mount a VMS-served disk. It failed: ipc# cd /net/alp/dka0 /net/alp/dka0: No such file or directory The same Sun client can mount a Tru64-served file system, and that Tru64 system can mount the VMS-served disk. All the VMS TCPIP proxy and export settings look the same for the SunOS and Tru64 systems. Does anyone already know what's wrong or where I should look? ALP $ tcpip sho ver Compaq TCP/IP Services for OpenVMS Alpha Version V5.3 - ECO 2 on a AlphaStation 200 4/233...

Check the color of a plot
Hello, I am drawing different plot in the same XYgraph. I would like to check the color of the current plot is drawn. I tried to use plotcolor but it gave to me only the clor of the first plot. Any ideas? thank you very much You are so close! LV is returning the color for plot "0" becuase you have not told it what plot you want info for. On the property node that you are using now to get the plotcolor, add an input just above the plotcolor terminal and select "active plot". THen wire an index to let LV know which of the plots you are interested in. I hope this helps, B...