FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 05-05-2012, 05:55 PM
ron ramos
 
Default check a file within a certain time

Hi All,

This is more of a general linux question. I would like to test if a
file if exists, and if the test does not respond in 5 seconds it'
considered failed.

reason for this is that i have web servers that has mounted nfs
volumes, but when the NFS server is high on load accessing the nfs
mount on the web servers seems slow.
the mount is not disconnected, it's just that there is a delay accessing it

so what i'd like to do is test a file in the nfs mount e.g.
/var/www/nfsmount/checknfs.txt if it was detected within 5 seconds it
is ok if not i will send me an email alert about it.
i was trying the "read" command: read -t 5 <
/var/www/nfsmount/checknfs.txt or cat /var/www/nfsmount/checknfs.txt
| read -t 5 but it does not give me anything.

any idea how this can be done? TIA.

Regards,
Ron


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: CAAXo3XK9hOXQqSrGqH3AWdVK2PFGZW+0tJjzARuBcON5J8dtY A@mail.gmail.com">http://lists.debian.org/CAAXo3XK9hOXQqSrGqH3AWdVK2PFGZW+0tJjzARuBcON5J8dtY A@mail.gmail.com
 
Old 05-05-2012, 07:31 PM
"Jesús M. Navarro"
 
Default check a file within a certain time

Hi Ron:

En fecha Sábado, 5 de Mayo de 2012, ron ramos escribió:
> Hi All,
>
> This is more of a general linux question. I would like to test if a
> file if exists, and if the test does not respond in 5 seconds it'
> considered failed.
>
> reason for this is that i have web servers that has mounted nfs
> volumes, but when the NFS server is high on load accessing the nfs
> mount on the web servers seems slow.

/usr/bin/time -f'%e' [ -e /mnt/mynfs/somefile ]

That will return the "real time" in seconds.

I'm using the absolute path '/usr/bin/time' because time is also a Bash built-
in; you'll need to install the "time" package if not already so.

It might happen that due to caching `[ -e /mnt/mynfs/somefile ]` returns fast
even if the NFS mount point is clogged, reading a file might be better:

/usr/bin/time -f'%e' cat /mnt/mynfs/somefile > /dev/null

Cheers.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 201205052131.32490.jesus.navarro@undominio.net">ht tp://lists.debian.org/201205052131.32490.jesus.navarro@undominio.net
 
Old 05-06-2012, 03:16 AM
Arnt Karlsen
 
Default check a file within a certain time

On Sun, 6 May 2012 01:55:24 +0800, ron wrote in message
<CAAXo3XK9hOXQqSrGqH3AWdVK2PFGZW+0tJjzARuBcON5J8dt YA@mail.gmail.com>:

> Hi All,
>
> This is more of a general linux question. I would like to test if a
> file if exists, and if the test does not respond in 5 seconds it'
> considered failed.

..you want to do a test within a deadline.
The deadline is 5 seconds, and,
you want to test if a file is existing.

> reason for this is that i have web servers that has mounted nfs
> volumes, but when the NFS server is high on load accessing the nfs
> mount on the web servers seems slow.
> the mount is not disconnected, it's just that there is a delay
> accessing it

..so, the test should be _read_ the file to verify it _is_ useful,
rather than test whether it was on a mounted disk before it died?

> so what i'd like to do is test a file in the nfs mount e.g.
> /var/www/nfsmount/checknfs.txt if it was detected within 5 seconds it
> is ok if not i will send me an email alert about it.
> i was trying the "read" command: read -t 5 <
> /var/www/nfsmount/checknfs.txt or cat /var/www/nfsmount/checknfs.txt
> | read -t 5 but it does not give me anything.
>
> any idea how this can be done? TIA.

.."timeout -k 5 test " (chk "man timeout")
or "until [timeout -k 5] ;do test ;done"?
(I assume you know how to do your tests.)
Note that an until loop tests for the terminating
condition at the _top_ of the loop.
http://tldp.org/LDP/abs/html/loops1.html

> Regards,
> Ron
>
>


--
..med vennlig hilsen = with Kind Regards from Arnt Karlsen
...with a number of polar bear hunters in his ancestry...
Scenarios always come in sets of three:
best case, worst case, and just in case.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20120506051645.11f1b1ea@celsius.lan">http://lists.debian.org/20120506051645.11f1b1ea@celsius.lan
 

Thread Tools




All times are GMT. The time now is 08:20 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2007 - 2008, www.linux-archive.org