NFS mount Script Modification

Source: Internet
Author: User
Tags nfsd

NFS will certainly be widely used. In addition to network and storage applications, it can often be applied to monitoring modules. Here we will discuss the content of NFS mounting. In the previous article, we have also introduced related scripts. Here I have made some modifications and hope they will be useful to you. If the nfs mounting sequence is not mounted in the order written in fstab, the monitor will issue a warning of warning, but the hard disk information not mounted in the alarm information is empty, actually, all the machines are mounted normally. So I adjusted my script, run the check_mount function in advance, and then judge whether the mount is normal according to the LIST variable content. After the adjustment, the script is as follows:

 
 
  1. #! /Bin/bash
  2.  
  3. # VERSION = "1.1"
  4. # AUTHOR by wenzizone.cn
  5.  
  6. ./Usr/local/nagios/libexec/utils. sh
  7.  
  8. CHECKNAME = "Mount NFS" // NFS mounting
  9.  
  10. RESULT = ""
  11. EXIT_STATUS = $ STATE_ OK
  12.  
  13. NFSFSTAB = 'lc _ ALL = C awk '! /^ #/& Amp; $3 ~ /^ Nfs/& $3! = "Nfsd" & $4 !~ /Noauto/{print $1} '/etc/fstab'
  14. NFSMTAB = 'lc _ ALL = C awk '$3 ~ /^ Nfs/& $3! = "Nfsd" & $2! = "/" {Print $1} '/proc/mounts'
  15.  
  16. Theend (){
  17. Echo $ RESULT
  18. Exit $ EXIT_STATUS
  19. }
  20.  
  21. CHECK_MOUNT (){
  22. LIST = ""
  23. For list in $ NFSFSTAB
  24. Do
  25. NFS_MOUNT = $ (LC_ALL = C cat/proc/mounts | cut-d ""-f 1 | grep "$ {list} $ ")
  26. If [-z "$ {NFS_MOUNT}"]; then
  27. LIST = "$ LIST $ list"
  28. Fi
  29. Done
  30. }
  31.  
  32. If [-n "$ {NFSMTAB}"]; then
  33. CHECK_MOUNT
  34. If [-z "$ {LIST}"]; then
  35. RESULT = "$ checkname OK-NFS BE MOUNTED PROPERLY"
  36. EXIT_STATUS = $ STATE_ OK
  37. Else
  38. RESULT = "$ checkname warning-$ {LIST} not be mounted"
  39. EXIT_STATUS = $ STATE_WARNING
  40. Fi
  41. Else
  42. RESULT = "$ checkname critical-all nfs not be mounted"
  43. EXIT_STATUS = $ STATE_CRITICAL
  44. Fi
  45.  
  46. Theend

In this way, NFS mount monitoring should be okay.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.