Check SMB-Connections (Resources in use?)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Check SMB-Connections (Resources in use?)
# 1  
Old 12-08-2008
Check SMB-Connections (Resources in use?)

Hi,

is it possible to check smb-connections of my server? I want to see, which files are opened from which station (ip).

The command who only works local (via terminal).

Regards.
# 2  
Old 12-08-2008
Code:
root@isau02:/data/tmp/testfeld> netstat -an| grep -iE ":139 |:445 "
tcp        0      0 0.0.0.0:139             0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:445             0.0.0.0:*               LISTEN
tcp        0      0 10.10.10.86:445        11.11.11.23:3246       VERBUNDEN

I guess you will have no luck to see which files they use. I doubt you can make Samba that talkative in debug levels. But maybe check the documentation for it.
# 3  
Old 12-08-2008
Thank you

Hello zaxxon,

Thank you for your fast reply.

I found out that the command smbstatus will give information about opended connections and used files (LOCK).

I think this is the right way. But the output of smbstatus is not what I prefer. An output like this would be nice:
Code:
------------------------------------------------------------------------
IP                      RESOURCE                                TIME
192.168.1.40       /data/share/presentation.pps       connected since 10m
192.168.1.52       /data/share/text.txt                   connected since 2m
192.168.1.60       /data/share/movies/sample.mov   connected since 1h
------------------------------------------------------------------------

I think this topic should be moved in Shell Programming and Scripting.

Hope anyone can help me. :-)

Thanks again and best regards.
# 4  
Old 12-08-2008
You should not only post how it should look like ie. what you want but also how the input ie. the output of smbstatus looks like because maybe not all people that want to help you have such output available.

I move your post to Shell Programming and Scripting.
# 5  
Old 12-08-2008
@ zaxxon

Sorry for this. Here is the addition.

This is the output of smbstatus -L to list all LOCKED (opened) files:
Code:
Locked files:
Pid          Uid        DenyMode   Access      R/W        Oplock           SharePath   Name   Time
--------------------------------------------------------------------------------------------------
6482         503        DENY_NONE  0x100001    RDONLY     NONE             /data/share/dir01/  .         Mon Dec  8 10:32:43 2008
6482         503        DENY_NONE  0x100001    RDONLY     NONE             /data/shares/dir01/test.mov   Mon Dec  8 10:32:45 2008

Now I need the proper IP-addresses. With the Pid you can find out which IP is used. The command is smbstatus -S:
Code:
Service      pid     machine       Connected at
-------------------------------------------------------
dir01   32380   192.168.1.65  Sun Dec  7 17:42:08 2008
dir01   32380   192.168.1.65  Sun Dec  7 05:25:44 2008
dir01   32380   192.168.1.65  Sun Dec  7 17:44:45 2008
dir01   32380   192.168.1.65  Sun Dec  7 09:38:14 2008
dir01   32380   192.168.1.65  Mon Dec  8 09:38:57 2008
dir02   4472   192.168.1.56  Sun Dec  7 18:25:39 2008
dir01   32380   192.168.1.65  Sun Dec  7 13:30:59 2008
dir02   31340   192.168.1.58  Sat Dec  6 02:06:57 2008
dir01   6482   192.168.1.100  Mon Dec  8 10:18:44 2008
dir01   32380   192.168.1.65  Sat Dec  6 09:30:13 2008
dir01   32380   192.168.1.65  Mon Dec  8 13:29:12 2008
dir02   19565   192.168.1.54  Mon Dec  1 13:41:11 2008
dir02   32380   192.168.1.65  Sat Dec  6 09:29:40 2008
dir01   32380   192.168.1.65  Sun Dec  7 17:41:18 2008
dir01   4027   192.168.1.62  Sun Dec  7 13:55:09 2008
dir02   6482   192.168.1.100  Mon Dec  8 10:09:08 2008
dir02   4027   192.168.1.62  Sun Dec  7 13:54:24 2008
dir01   32380   192.168.1.65  Sat Dec  6 13:24:46 2008

No I need a script to compare these two outputs, so that I get a list like this:
Code:
------------------------------------------------------------------------
IP                      RESOURCE                                TIME
192.168.1.40        /data/share/presentation.pps    connected since ??m
192.168.1.52        /data/share/text.txt            connected since ??m
192.168.1.100       /data/share/movies/test.mov     connected since ??h
------------------------------------------------------------------------

It's important to weed out duplicates (users that are connected to several samba shares).

I found an article with a similar problem, but I have no idea about shell-scripts. So I hope anyone can help me an this Link is helpful.

Thanks and regards.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Smb.conf config help

So what i am trying to accomplish is the following: a share that is browse-able by every one on the network with a group of people that can write to it with out ownership problems. I am extremely new to samba/linux and any help would be greatly appreciated. It is a stand alone server running samba... (3 Replies)
Discussion started by: dcs
3 Replies

2. Solaris

Solaris 11.2 - smb with AD

Hello I used the following procedure in S11.1, everything worked. As we reinstalled some servers, i tried the exact same with s11.2. Now i can't join my AD domain, and smb will not allow my users to access files. Procedure: Configured NTP Configured DNS Configured Name Service Switch... (3 Replies)
Discussion started by: embedded
3 Replies

3. Red Hat

check system resources (VPS) to see if match what I paid?

-bash-3.2$ cat /etc/redhat-release CentOS release 5.8 (Final) Hello, Our company recently paid a hosting company (who shall remain nameless) with certain service guarantees. Is there a simple way to list the CPU speed, RAM, Disk Space etc. It is supposed to be; 25GB Disk Space, 500GB... (2 Replies)
Discussion started by: Astrocloud
2 Replies

4. Solaris

SMB + Windows sharing

Hi guys I need to create one directory on my Solaris 11 box and then share that directory on my LAN. I have only one disk of 500 GB which is more than enough for my needs. I read SMB guide for Solaris and there is no guide how to achive share only on one directory, it has only tutorials for... (3 Replies)
Discussion started by: solaris_user
3 Replies

5. SCO

sco visionfs vs smb

i need to copy the entire contents of my sco server 5.0.5 it says its running vision fs 2.01.905 if i access it from windows i would like to be able to access it like a normal file share instead of only thru an ftp service i cannot find vison software on the server /usr/vision does not exist ... (1 Reply)
Discussion started by: crosbymook
1 Replies

6. Solaris

Terrible SMB performance!?

Hi, I tried this question on OTN Discussion Forum, but it seems that forum doesn't have as much activity so I thought I'd try here. I have a big performance problem with Samba server on a fresh install of Solaris Express 11 svn_151a, and a freshly created ZFS pool. I'm getting about 3 to 10 MB/s... (2 Replies)
Discussion started by: doublemeat
2 Replies

7. Shell Programming and Scripting

How to check if a Port is accepting connections.

Hi, I need to create a script which checks the availability of a particular service on a particular Port on HP-Unix. Is there any command in unix wherein we can check if any port is accepting the connections now. Thanks, Vihang. (5 Replies)
Discussion started by: vikings.svnit
5 Replies

8. UNIX for Dummies Questions & Answers

smb.conf question

Folks; I know this might sounds stupid, but please help with this: I have share in my smb.conf on my SUSE 10 box. How can i make this share accessible to outside IP range or a specific IP address without need for user/pass? Here's the share as it's written in smb.conf: ; ;comment =... (0 Replies)
Discussion started by: Katkota
0 Replies

9. UNIX for Dummies Questions & Answers

Samba - smb files

I found this tutorial "Setting Samba in 10 min". It says there that command "/etc/rc.d/init.d/smb start or stop, or /sbin/service/smb restart should do this functions. But this doesn't work for me. Wrong dir. I don't even have "rc.d" dir. Where should I look for this samba files? In samba dir all... (1 Reply)
Discussion started by: salvor_hardin
1 Replies

10. UNIX for Dummies Questions & Answers

check resources

Hi all I would like to check my production machine and find out which application is using up the resources of the Unix machine, is there a way to display individual applications that are running and the percentage of resources they are taking up? (2 Replies)
Discussion started by: handynas
2 Replies
Login or Register to Ask a Question