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:
- #! /Bin/bash
-
- # VERSION = "1.1"
- # AUTHOR by wenzizone.cn
-
- ./Usr/local/nagios/libexec/utils. sh
-
- CHECKNAME = "Mount NFS" // NFS mounting
-
- RESULT = ""
- EXIT_STATUS = $ STATE_ OK
-
- NFSFSTAB = 'lc _ ALL = C awk '! /^ #/& Amp; $3 ~ /^ Nfs/& $3! = "Nfsd" & $4 !~ /Noauto/{print $1} '/etc/fstab'
- NFSMTAB = 'lc _ ALL = C awk '$3 ~ /^ Nfs/& $3! = "Nfsd" & $2! = "/" {Print $1} '/proc/mounts'
-
- Theend (){
- Echo $ RESULT
- Exit $ EXIT_STATUS
- }
-
- CHECK_MOUNT (){
- LIST = ""
- For list in $ NFSFSTAB
- Do
- NFS_MOUNT = $ (LC_ALL = C cat/proc/mounts | cut-d ""-f 1 | grep "$ {list} $ ")
- If [-z "$ {NFS_MOUNT}"]; then
- LIST = "$ LIST $ list"
- Fi
- Done
- }
-
- If [-n "$ {NFSMTAB}"]; then
- CHECK_MOUNT
- If [-z "$ {LIST}"]; then
- RESULT = "$ checkname OK-NFS BE MOUNTED PROPERLY"
- EXIT_STATUS = $ STATE_ OK
- Else
- RESULT = "$ checkname warning-$ {LIST} not be mounted"
- EXIT_STATUS = $ STATE_WARNING
- Fi
- Else
- RESULT = "$ checkname critical-all nfs not be mounted"
- EXIT_STATUS = $ STATE_CRITICAL
- Fi
-
- Theend
In this way, NFS mount monitoring should be okay.