You are not logged in.

#1 2013-01-06 16:10:25

frojnd
Member
Registered: 2008-09-20
Posts: 114

[SOLVED] journalctl and samba stdout problem

Hi there,

I'm having problem configuring my /etc/samba/smb.conf so it would stdout and I'll be able to see logs with journalctl -u smbd
wiki is not so infomative about logging with samba and systemd.

Here is my current /etc/samba/smb.conf

[global]
   workgroup = MYGROUP
   server string = Samba Server
   security = user
   load printers = yes
   log level = 3
   log file = /var/log/samba/%m.log
   create mask = 0664
   directory mask = 0775
   force create mode = 0664
   force directory mode = 0775
   max log size = 50
   dns proxy = no 

[printers]
   comment = All Printers
   path = /var/spool/samba
   browseable = no
   guest ok = no
   writable = no
   printable = yes

[myshare]
   comment = toastman_logs
   path = /home/frojnd/router_logs
   valid users = frojnd
   read only = No
   available = yes
   ;public = no
   ;writable = yes
   ;printable = no
   ;create mask = 0765

If I understand correctly this samba needs to stdout logs so journalctl can print those logs and lines:

 log level = 3
 log file = /var/log/samba/%m.log

are not needed anymore?

How do I configure samba to stdout logs?

Last edited by frojnd (2013-01-08 16:38:57)

Offline

#2 2013-01-07 22:45:33

frojnd
Member
Registered: 2008-09-20
Posts: 114

Re: [SOLVED] journalctl and samba stdout problem

C'mon SyS admins smile Where are you?

Offline

#3 2013-01-08 00:53:16

djgera
Developer
From: Buenos Aires - Argentina
Registered: 2008-12-24
Posts: 697
Website

Re: [SOLVED] journalctl and samba stdout problem

/dev/stdout ?

Offline

#4 2013-01-08 00:58:27

djgera
Developer
From: Buenos Aires - Argentina
Registered: 2008-12-24
Posts: 697
Website

Re: [SOLVED] journalctl and samba stdout problem

or I guess reading man page:

syslog only (G)

    If this parameter is set then Samba debug messages are logged into the system syslog only, and not to the debug log files. There still will be some logging to log.[sn]mbd even if syslog only is enabled.

    Default: syslog only = no

syslog (G)

    This parameter maps how Samba debug messages are logged onto the system syslog logging levels. Samba debug level zero maps onto syslog LOG_ERR, debug level one maps onto LOG_WARNING, debug level two maps onto LOG_NOTICE, debug level three maps onto LOG_INFO. All higher levels are mapped to LOG_DEBUG.

    This parameter sets the threshold for sending messages to syslog. Only messages with debug level less than this value will be sent to syslog. There still will be some logging to log.[sn]mbd even if syslog only is enabled.

    Default: syslog = 1

Offline

#5 2013-01-08 01:23:36

Leonid.I
Member
From: Aethyr
Registered: 2009-03-22
Posts: 948

Re: [SOLVED] journalctl and samba stdout problem

frojnd wrote:

C'mon SyS admins smile Where are you?

I am assuming that you use the stock {s,n}mbd.service. Then, it starts smbd with -F = foreground. Now, the problem is that samba will produce an error, assume -D and fork into background (just check "systemct status smbd.service" as root). So, you'll need log files. Moreover,  journald does capture system logs, not necessarily from stdout.

For example, in my case

$ gr -v -e "^$" -e "^#" -e "^;" ../configs/metal-0/smb.conf 
[global]
   strict allocate = yes
   socket options = IPTOS_LOWDELAY TCP_NODELAY SO_SNDBUF=16384 SO_RCVBUF=16384
   workgroup = skynet
   server string = metal-0
   security = share
   hosts allow = 127.0.0.1 10.0.0.0/24
   hosts deny = 0.0.0.0/0
   interfaces = br0 lo
   bind interfaces only = yes
   load printers = no
   printcap name = /dev/null
   printing = bsd
   log file = /var/log/samba/samba.log
   dns proxy = no 
[public]
   path = /home/smb_nobody
   public = yes
   only guest = yes
   writable = yes
   printable = no

and

% journalctl -u smbd.service 
-- Logs begin at Wed, 2012-12-19 14:42:48 EST, end at Mon, 2013-01-07 20:20:32 EST. --
Dec 25 21:49:40 metal-0 smbd[400]: [2012/12/25 21:49:40.948679,  0] smbd/server.c:1082(main)
Dec 25 21:49:40 metal-0 smbd[400]: standard input is not a socket, assuming -D option
Jan 05 18:33:26 metal-0 smbd[7444]: [2013/01/05 18:33:26.954281,  0] smbd/process.c:244(read_packet_remai
Jan 05 20:10:17 metal-0 smbd[7639]: [2013/01/05 20:10:17.992591,  0] smbd/process.c:244(read_packet_remai
Jan 05 20:12:31 metal-0 smbd[7669]: [2013/01/05 20:12:31.105816,  0] smbd/process.c:244(read_packet_remai
Jan 05 20:12:31 metal-0 smbd[7669]: read_fd_with_timeout failed for client 10.0.0.11 read error = NT_STAT
Jan 05 21:25:46 metal-0 smbd[8099]: [2013/01/05 21:25:46.748860,  0] smbd/process.c:244(read_packet_remai
Jan 06 11:09:13 metal-0 smbd[8757]: [2013/01/06 11:09:13.462034,  0] smbd/process.c:244(read_packet_remai
Jan 06 11:09:13 metal-0 smbd[8757]: read_fd_with_timeout failed for client 10.0.0.11 read error = NT_STAT

Arch Linux is more than just GNU/Linux -- it's an adventure

Offline

#6 2013-01-08 14:02:09

frojnd
Member
Registered: 2008-09-20
Posts: 114

Re: [SOLVED] journalctl and samba stdout problem

Leonid.I,

yes I'm using stock {s,n}mbd service:

# systemctl status smbd.service
smbd.service - Samba SMB/CIFS server
          Loaded: loaded (/usr/lib/systemd/system/smbd.service; enabled)
          Active: active (running) since Thu, 1970-01-01 01:00:11 CET; 43 years and 0 months ago
        Main PID: 152 (smbd)
          CGroup: name=systemd:/system/smbd.service
                  ├─152 /usr/sbin/smbd -F
                  └─163 /usr/sbin/smbd -F

# systemctl status nmbd.service
nmbd.service - Samba NetBIOS name server
          Loaded: loaded (/usr/lib/systemd/system/nmbd.service; enabled)
          Active: active (running) since Thu, 1970-01-01 01:00:11 CET; 43 years and 0 months ago
        Main PID: 151 (nmbd)
          CGroup: name=systemd:/system/nmbd.service
                  └─151 /usr/sbin/nmbd -F

No log files. How do I change smbd parameters to -D? smbd -D as root does not change after service is already running.

And:

# journalctl -u smbd.service
-- Logs begin at Thu, 1970-01-01 01:00:02 CET, end at Tue, 2013-01-08 14:56:30 CET. --

EDIT: adding syslog = 1 (as djgera said) to smb.conf did the trick, and now I'm able to see logs with journalctl -u smbd.service so this thread is marked as [SLOVED].

But I still don't know why samba didn't write logs into /var/log/samba/ folder in the first place.

Last edited by frojnd (2013-01-08 16:35:42)

Offline

Board footer

Powered by FluxBB