Solved

Check samba connection

Posted on 2007-12-05
5
1,117 Views
Last Modified: 2013-12-16
Dear Experts,
I would like to write a script that checks if there is a connection and directory is really mounted (sometimes an entry it appears in /etc/mtab, but there is no connection in fact) This scripts will periodically (using cron) check if the mounted directory is still available.

I am mounting directory suing command (as root)

su - oracle -c "smbmount //192.168.3.1/BITEX_b /home/oracle/BITEX-backup -o username=oracle,password=oracle,rw"

What command should I use to check if SAMBA connection is still available?

Thanks for help

Groxy
0
Comment
Question by:adamgasior
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 40

Expert Comment

by:omarfarid
ID: 20418114
Hi,

Why don't you just create / delete a file in that mounted dir  and see if it succeeds or fails.

0
 
LVL 19

Accepted Solution

by:
alextoft earned 40 total points
ID: 20418599
Something quick and dirty like this perhaps?

#!/bin/bash
FILE="/home/oracle/BITEX-backup/a-file-on-your-remote-server
  if [ -f $FILE ];
    then
      echo Samba mount OK
    else
      umount -f /home/oracle/BITEX-backup
      su - oracle -c "smbmount //192.168.3.1/BITEX_b /home/oracle/BITEX-backup -o username=oracle,password=oracle,rw"
  fi


0
 
LVL 19

Expert Comment

by:alextoft
ID: 20418602
Hmm, it appears to have stripped the quotes round the echo statement when I posted, but you get what I mean...
0
 

Author Comment

by:adamgasior
ID: 20441415
it is not really working. When I physically disconnect machines, the touch command hangs
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 20441538
OK,

You may monitor the touch command while it is running in the the background

e.g.

touch /sambadir/file &
sleep 3
count=`ps -ef | grep -v grep | grep touch | wc -l`
if test $count -gt 0
then
      echo "not mounted"
      kill -9 `ps -ef | grep -v grep | grep touch | awk '{print $2}'`
else
      echo "mounted"
fi
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Network Interface Card (NIC) bonding, also known as link aggregation, NIC teaming and trunking, is an important concept to understand and implement in any environment where high availability is of concern. Using this feature, a server administrator …
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question