Welcome to Coding : Sécurité Programmation Réseaux

Search   in  

 Create an Account Home | Submit News Your Account Content | Topics | Top 10  


Accueil
· Home
· Listing des Articles
· Top 10
· Repository des Exploits

Les sujets / parties
· C / C ++
· Visual Basic
· Asm
· Reseaux
· Java
· Securite
· Divers

Utile
· Listing des Articles

· Telecharger
· Le Forum
· Liens
· Proposer un article

Top20 des Downloads
· 1: Etude des reseaux generalites et protocoles
· 2: Cheval de troie en VB avec sources
· 3: Netcat 1.1
· 4: Keylogger
· 5: Etudes des reseaux hauts debits architectures et protocoles
· 6: Ecoute de port
· 7: Etude du Smart Spoofing
· 8: Win Packet Capture Utils
· 9: Tutorial on Traffic Interception on Switched Lan using ARP spoofing
· 10: Cours de C

User Info
Welcome, Anonymous
Nickname
Password
(Register)
Membership:
Latest: trapcodien
New Today: 1
New Yesterday: 0
Overall: 2207

People Online:
Visitors: 40
Members: 1
Total: 41

Online Now:
01: trapcodien

  
Coding : Sécurité Programmation Réseaux: Forums

Coding :: View topic - check an nfs mount in a script
 Forum FAQForum FAQ   SearchSearch   UsergroupsUsergroups   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

check an nfs mount in a script

 
Post new topic   Reply to topic    Coding Forum Index -> Scripting
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Fri Jul 04, 2008 8:10 am    Post subject: check an nfs mount in a script Reply with quote

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
Back to top
mop2
Guest





PostPosted: Fri Jul 04, 2008 1:10 pm    Post subject: Re: check an nfs mount in a script Reply with quote

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

Quote:
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%")
Back to top
Dan Stromberg
Guest





PostPosted: Fri Jul 04, 2008 1:10 pm    Post subject: Re: check an nfs mount in a script Reply with quote

On Thu, 03 Jul 2008 17:30:50 -0700, cconnell_1 wrote:

Quote:
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).
Back to top
mop2
Guest





PostPosted: Fri Jul 04, 2008 1:10 pm    Post subject: Re: check an nfs mount in a script Reply with quote

On Thu, 03 Jul 2008 21:30:50 -0300, <cconnell_1@lycos.com> wrote:

Quote:
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
Back to top
Guest






PostPosted: Fri Jul 04, 2008 1:10 pm    Post subject: Re: check an nfs mount in a script Reply with quote

On 4 Jul, 00:29, mop2 <inva...@mail.address> wrote:
Quote:
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?
Back to top
Maxwell Lol
Guest





PostPosted: Sat Jul 05, 2008 11:10 pm    Post subject: Re: check an nfs mount in a script Reply with quote

cconnell_1@lycos.com writes:

Quote:
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).
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Coding Forum Index -> Scripting All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2005 phpBB Group
PHP-Nuke Copyright © 2005 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.
Page Generation: 0.38 Seconds