[Samba] share status information from api (python3)

Isaac Stone isaac.stone at som.com
Tue Oct 13 22:50:21 UTC 2020


Hmmm, I am looking right now for access to the same information in
`smbstatus`, only in a more scriptable way.

for example, I could get info on who all has write locked files:

```
processes = samba.get_processes()
data = {}
for process in processes;
  if process.service == 'IPC$':
    continue
  data[process.username] = [(l.share_path, l.name) for l in
process.get_locks() if l.deny_mode == 'DENY_WRITE']
```

Another thing I see in the docs we have `samba.join`, might be nice to have
something in there to get current join status, and fail early if the box
hasn't joined the domain properly. Something like `net ads testjoin` or `wbinfo
-P`

On Tue, Oct 13, 2020 at 2:25 PM Jeremy Allison <jra at samba.org> wrote:

> On Tue, Oct 13, 2020 at 01:23:49PM -0700, Isaac Stone via samba wrote:
> > Looking for advice for best practices on fetching status of the samba
> > server and share information.
> >
> > One option is to parse the output of `smbstatus` into a machine-readable
> > format. But I noticed there are some apis documented. We are using samba
> > 4.11 which is supposed to have full python3 api support.
> >
> > So the question is, can the share and lock information displayed in the
> > `smbstatus` command also be read from an API, such as the python3 samba
> > package? Glancing through the API documentation I did not see anything
> > obvious. Perhaps better to use the tdb package and read from the
> databases
> > directly.
> >
> > The purpose is to collect metrics and create a dashboard so we can track
> > mounts, locks, etc across all servers and shares. Any advice is welcome
>
> This would be a useful addition to the python Samba APIs.
>
> Can you define what you'd like such Python API calls
> to look like ?
>
>


More information about the samba mailing list