Monitor SMB connectivity

When you are using a remote file share for data processing, you will need to check the connectivity continuously. Bellow script show how to check the connectivity of a file share through SMB command and execute a remote command.

Below checks the existence of files in a certain directory. This can be used as a script to output values or status and monitor through a tool like Nagios or Cacti.

for i in {1..200}; 
do smbclient \\\\remotefileshare.domain\\Shared\\MyFiles -U USERNAME -W WORKGROUP -c ‘cd directory;ls’ PASSWORD; sleep 0.5;
Like what you read? Give Dilan Asanga Gallage a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.