2

I would like to monitor the server "mount point status" using "monit".

Check filesystem is available to check whether that filesystem available or not on the systeam. But couldn't check filesystem mount point.Please correct me if its wrong. Since I tested this check locally , its not check the filesystem mount point, it checks only filesystem attached to server or not.

For some reason, my mount on the server getting disconnected frequently. so I would like to get an alert whenever mount gets disconnected.

Thanks in Advance

1

You could do it with a flag file (here server-nfs-a) located on the mounted point

check file mount-flag-nas-b with path /mount/NAS-A/server-nfs-a
      if does not exist then exec "/bin/mount /mount/NAS-A" else if succeeded then exec "/var/lib/monit/scripts/notifySuccess.sh"

Here I prefer to mount it when the file cannot be found due to missing mount.

| improve this answer | |
0

Create a script called test-mount.sh to test mount. I am using file create and delete as I find just reading a file unreliable.

set -e
/bin/touch /my-mounted-dir/test/mount.test
/bin/rm /my-mounted-dir/test/mount.test
exit 0
  1. set -e tells the script to stop execution and return error if any command fails.
  2. Use touch to create a file.
  3. Remove the file.
  4. exit 0 will tell monit script succeeded.

Create test on monit config. This will run the test-mount.sh and if it fails it will run remount-data.sh. You can replace this with anything you want to do in case of a failed mount.

    check program test-mount with path /root/test-mount.sh timeout 5 seconds 
      if status != 0 then exec "/root/remount-data.sh"
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.