User avatar
RottenRonnie
Posts: 15
Joined: Thu Feb 26, 2015 1:15 am
Location: Charlottetown PE, Canada

Process troubleshooting - smbd

Wed Feb 08, 2023 2:18 pm

I'm a huge fan of the raspberrypi and have been using them for a number of years now, but I will be the first to admit that there are some processes that I don't understand in general.

I'd like to get some advice on how I can track down more information about a running process and perhaps what triggered it. I've noticed that smbd is running with 100% CPU and I'm trying to track down the root cause.

Code: Select all

PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
13636 pi        20   0  132212  25164  18156 R  94.1   0.3 503:25.52 smbd
HTOP shows a bit more information, owner is pi, command:

Code: Select all

/usr/sbin/smbd --foreground --no-process-group
Thank you in advance.
Last edited by RottenRonnie on Wed Feb 08, 2023 4:44 pm, edited 1 time in total.

User avatar
thagrol
Posts: 8900
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK

Re: Process troubleshooting - smbd

Wed Feb 08, 2023 2:40 pm

smbd is the samba server daemon.

I'm unsure why it would be running like that though. Do you have an active large transfer going on?
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

User avatar
RottenRonnie
Posts: 15
Joined: Thu Feb 26, 2015 1:15 am
Location: Charlottetown PE, Canada

Re: Process troubleshooting - smbd

Wed Feb 08, 2023 3:13 pm

I don't believe I have. I'm sitting at the office accessing headless via ssh at the moment.

User avatar
DougieLawson
Posts: 42393
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK

Re: Process troubleshooting - smbd

Thu Feb 09, 2023 9:08 am

thagrol wrote:
Wed Feb 08, 2023 2:40 pm
smbd is the samba server daemon.

I'm unsure why it would be running like that though. Do you have an active large transfer going on?
It's running as user `pi` as that's the user who is logged on from some remote station.
Languages using left-hand whitespace for syntax are ridiculous

DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.

The use of crystal balls and mind reading is prohibited.

hortimech
Posts: 758
Joined: Wed Apr 08, 2015 5:52 pm

Re: Process troubleshooting - smbd

Thu Feb 09, 2023 10:04 am

RottenRonnie wrote:
Wed Feb 08, 2023 3:13 pm
I don't believe I have. I'm sitting at the office accessing headless via ssh at the moment.
Could that mean that you are in place 'A' and the pi is in place 'B' and you are connecting via the internet rather than a lan ?

If that is the case, you could have been hacked.

User avatar
thagrol
Posts: 8900
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK

Re: Process troubleshooting - smbd

Thu Feb 09, 2023 12:55 pm

DougieLawson wrote:
Thu Feb 09, 2023 9:08 am
thagrol wrote:
Wed Feb 08, 2023 2:40 pm
smbd is the samba server daemon.

I'm unsure why it would be running like that though. Do you have an active large transfer going on?
It's running as user `pi` as that's the user who is logged on from some remote station.
Doh! Yes, I should have realised that.
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

User avatar
thagrol
Posts: 8900
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK

Re: Process troubleshooting - smbd

Thu Feb 09, 2023 12:58 pm

hortimech wrote:
Thu Feb 09, 2023 10:04 am
RottenRonnie wrote:
Wed Feb 08, 2023 3:13 pm
I don't believe I have. I'm sitting at the office accessing headless via ssh at the moment.
Could that mean that you are in place 'A' and the pi is in place 'B' and you are connecting via the internet rather than a lan ?

If that is the case, you could have been hacked.
Especially if the OP has exposed ssh to the internet while using the (old) default username and password.
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

User avatar
RottenRonnie
Posts: 15
Joined: Thu Feb 26, 2015 1:15 am
Location: Charlottetown PE, Canada

Re: Process troubleshooting - smbd

Thu Feb 09, 2023 1:23 pm

thagrol wrote:
Thu Feb 09, 2023 12:58 pm
hortimech wrote:
Thu Feb 09, 2023 10:04 am
RottenRonnie wrote:
Wed Feb 08, 2023 3:13 pm
I don't believe I have. I'm sitting at the office accessing headless via ssh at the moment.
Could that mean that you are in place 'A' and the pi is in place 'B' and you are connecting via the internet rather than a lan ?

If that is the case, you could have been hacked.
Especially if the OP has exposed ssh to the internet while using the (old) default username and password.


Guilty of using the pi user, but I changed the password to a complex one, use fail2ban and other limits in sshd_config such as AllowUsers and PAM = no, with ed25519 key exchange on a non standard port. /var/log/auth.log shows only accesses from two recognized external IPs. I would like to rule out hacked.

Is there a method for tracking down what started the process? To investigate the process itself?

The samba log config is bit of a rum go, as it logs by ip by default, and only a couple logs have content there. I tried setting it to log by share yesterday, but I don't think I succeeded and will revert the changes to the smb.conf.

Code: Select all

# This tells Samba to use a separate log file for each machine
# that connects
log file = /var/log/samba/log.%m
# log file = /var/log/samba/%S.log
Thank you.

User avatar
RottenRonnie
Posts: 15
Joined: Thu Feb 26, 2015 1:15 am
Location: Charlottetown PE, Canada

Re: Process troubleshooting - smbd

Fri Feb 10, 2023 5:12 pm

It might have been an app on my iPhone which I connected via a samba share to my media library. I've deleted the app, and rebooted the pi to test my theory.

Cheers,

User avatar
RottenRonnie
Posts: 15
Joined: Thu Feb 26, 2015 1:15 am
Location: Charlottetown PE, Canada

Re: Process troubleshooting - smbd

Mon Feb 13, 2023 5:18 pm

RottenRonnie wrote:
Fri Feb 10, 2023 5:12 pm
It might have been an app on my iPhone which I connected via a samba share to my media library. I've deleted the app, and rebooted the pi to test my theory.

Cheers,
A friend recommended Firecore Infuse app for iPhone which I installed and gave access to my samba share. The trouble there is the app would refresh at random intervals and cause the high CPU usage of the PI. I removed the app and it's no longer an issue. In future I may create a new samba user for situations like that, then I would be able to identify the process as belonging to user "xyz".

Thanks for your help.

"Nope, not hacked." ;)

Return to “Troubleshooting”