Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

we're running samba and nfs servers on an Ubuntu LTS 04.10 machine. Is there a way detect on the server, whether any client is connected to one of the shares? The clients are Windows 7,Linux or OS X systems.

I would like to know this in order to restart the server without disturbing my users.

Thanks, Kathrin

share|improve this question

2 Answers 2

up vote 2 down vote accepted

You can use smbstatus for the Samba shares . It will print a list of users connected with machine, share, etc...

PID     Username      Group         Machine 

-------------------------------------------------------------------
  870   username1     Domain Users  machine1       (111.11.11.111)

  586   username2     Domain Users  machine2       (111.12.11.112)

With nfs, you can use showmount for a list of machines and mounted shares in the machine:

showmount

Hosts on server.domain.com:

111.11.0.0/16,machine1.domain.com

111.11.0.0/16,machine2.domain.com

111.11.0.0/16,machine3.domain.com

Hope it helps.

Cheers,

Bruno

share|improve this answer
    
smbstatus is nice. Just wondering why I haven't found it myself. It just does not show mounts done via OS X. But the more important ones are there. With showmount I somehow see more mounts than currently active. So, I need to have a look at the different options. –  Kathrin Geilmann Apr 23 '12 at 11:03
    
yes.. showmount shows also the mounts defined in /etc/exports... –  Feiticeir0 Apr 23 '12 at 11:10
    
As smbstatus and showmount solves my problems in about 98% of the cases, i have accepted this answer. The remaining 2% will be handled by walking to the corresponding offices. –  Kathrin Geilmann Apr 24 '12 at 14:45

You could use netstat -tp | grep smbd to see whether there were any open smbd connections.

tcp        0      0 lo-app-31:microsoft-ds      <ip address of the other machine>:49225 ESTABLISHED 17700/smbd
tcp        0      0 lo-app-31:microsoft-ds      <ip address of the other machine>:49222 ESTABLISHED 27256/smbd

If they are ESTABLISHED then a machine is connected to smbd using TCP.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.