This article mainly introduces PHP and Shell implementation to check whether SAMBA and NFSServer exist. This article provides PHP check scripts and Shell check scripts respectively. If you need them, refer
This article mainly introduces PHP and Shell implementation to check whether SAMBA and NFS Server exist. This article provides PHP check scripts and Shell check scripts respectively. For more information, see
The mount settings are usually handled through/etc/fstab, and then the mount-a is used to re-confirm the mount, it is best to execute mount-a when the mounting directory is used by the scheduling program. The mount directory will not be automatically replied after the disconnection. The Timeout of mount-a is actually quite long, especially when the Server does not exist, it is best to use the corresponding client to check whether the server exists.
The client that checks NFS can use showmount for processing. The installation method on Ubuntu is as follows:
The Code is as follows:
Sudo aptitude install nfs-common
The SAMBA client uses smbclient. The installation method on Ubuntu is as follows:
The Code is as follows:
Sudo aptitude install smbclient
Process for checking whether the NFS Server exists
Check in Shell mode
The Code is as follows:
# Use the client to check whether the server exists
/Sbin/showmount 192.168.0.6>/dev/null 2> & 1
If ["j $? "! = "J0"]; then
Echo "NFS Server is not exist"
Exit 1
Fi
# Reconfirm mounting
Mount-a>/dev/null 2> & 1
If ["j $? "! = "J0"]; then
Echo "NFS Server mount failed"
Exit 1;
Fi
Check in PHP Mode
The Code is as follows:
/* Use the client to check whether the server exists */
$ State = shell_exec ('/sbin/showmount 192.168.0.6>/dev/null 2> & 1; echo $? ');
If (trim ($ state )! = '0 '){
Echo "NFS Server is not exist ";
Exit;
}
/* Re-confirm mounting */
If (shell_exec ('mount-a 2> & 1 ')){
Echo "NFS Server mount failed"
Exit;
}
Check the process of SAMBA Server
Check in Shell mode
The Code is as follows:
# Use the client to check whether the server exists
Smbclient-NL // 192.168.0.6>/dev/null 2> & 1
If ["j $? "! = "J0"]; then
Echo "SAMBA Server is not exist"
Exit 1
Fi
# Reconfirm mounting
Mount-a>/dev/null 2> & 1
If ["j $? "! = "J0"]; then
Echo "SAMBA Server mount failed"
Exit 1;
Fi
Check in PHP Mode
The Code is as follows:
/* Use the client to check whether the server exists */
$ State = shell_exec ('smbclient-NL // 192.168.0.6>/dev/null 2> & 1; echo $? ');
If (trim ($ state )! = '0 '){
Echo "SAMBA Server is not exist ";
Exit;
}
/* Re-confirm mounting */
If (shell_exec ('mount-a 2> & 1 ')){
Echo "SAMBA Server mount failed"
Exit;
}