Monit NFS share

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Monit NFS share

Josu Lazkano
Hello,

I have a little server that mount a NFS share from a NAS:

# cat /etc/fstab | grep nfs
192.168.1.2:/vol2/tvdata    /mnt/tvdata/    nfs    defaults    0 0

The problem is that sometimes it is not mounted at boot or the NAS could reboot and I need to force the mount by "mount -a".

How could monitor the NFS share and mount if the share is not mounted?

I try this way:

check filesystem tvdata with path /mnt/tvdata
  if not exist then exec "/bin/mount -a"

But it does not work.

I will appreciate your help.

Kind regards.

--
Josu Lazkano
Reply | Threaded
Open this post in threaded view
|

Re: Monit NFS share

Lutz Mader
Hello Josu,
are you using Monit 5.25 or 5.26 (use "monit -V" to check this)?

You are right, the filesystem check doesn't support "does not exist",
but check directory does.

> check filesystem tvdata with path /mnt/tvdata
>   if not exist then exec "/bin/mount -a"

Based on you snipped, the directory check should do the job.

check directory tvdata path "/mnt/tvdata"
  start program "/bin/mount -a"
  if not exist then start

A suggestion only,
Lutz

p.s.
I use dependencies to prevent endless recovery.

check host Nfs_Host with address your.host
# Prevent status "Online with all services" immediate after startup.
  every 5 cycles
  if failed port 2049 with timeout 30 seconds for 10 cycles then alert
#
check directory tvdata path /mnt/tvdata
  start program "/bin/mount -a"
  if not exist then start
  depends on Nfs_Host

As long as the address "your.host" port "2049" (the nfsd port) is not
available, the directory check hung in state "Initializing" or
"Connection Failed" and the directory check will not start the mount
command.

Reply | Threaded
Open this post in threaded view
|

Re: Monit NFS share

AEI Hannover
In reply to this post by Josu Lazkano
On Tue, 17 Sep 2019 22:10:55 +0200 Josu Lazkano <[hidden email]>
wrote about Monit NFS share:

> The problem is that sometimes it is not mounted at boot or the NAS could
> reboot and I need to force the mount by "mount -a".

What OS are you working on, and who would be responsible for mounting? Are
we talking about an issue with systemd here?


cu
  Gerrit

Reply | Threaded
Open this post in threaded view
|

Re: Monit NFS share

Josu Lazkano
El mié., 18 sept. 2019 7:09, Gerrit Kühn <[hidden email]> escribió:
On Tue, 17 Sep 2019 22:10:55 +0200 Josu Lazkano <[hidden email]>
wrote about Monit NFS share:

> The problem is that sometimes it is not mounted at boot or the NAS could
> reboot and I need to force the mount by "mount -a".

What OS are you working on, and who would be responsible for mounting? Are
we talking about an issue with systemd here?


cu
  Gerrit

Thanks both,

It works! I configure this way:

Create a test directory in the share.

check directory test path "/mnt/tvdata/test"
  start program "/bin/mount -a"
  if not exist then start

I have a Debian Stretch server with 5.20.0 monit version.

I have configured the NFS mount in fstab, I think that the problem is that it try to mount before the networking is ready.

Best regards.
Reply | Threaded
Open this post in threaded view
|

Re: Monit NFS share

AEI Hannover
On Wed, 18 Sep 2019 13:12:46 +0200 Josu Lazkano <[hidden email]>
wrote about Re: Monit NFS share:

> I have a Debian Stretch server with 5.20.0 monit version.
>
> I have configured the NFS mount in fstab, I think that the problem is
> that it try to mount before the networking is ready.

That's probably an issue with systemd, then. You can certainly use the
monit workaround, but you could also tell systemd to behave. Try adding
these options to your nfs mounts in fstab (given you don't have any other
method of automounting in place):

---
noauto,x-systemd.automount,x-systemd.device-timeout=10,timeo=14,x-systemd.idle-timeout=1min,x-systemd.requires=network-online.target
---


This should activate systemd's automounting capabilities once networking
is available.


cu
  Gerrit