LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-15-2017, 05:48 AM   #1
ddenial
Member
 
Registered: Dec 2016
Distribution: CentOS, Fedora, Ubuntu
Posts: 215

Rep: Reputation: 38
Find memory used by Services.


Hello

I know how to find memory used by processes by using ps or top command. But how do I find memory usage by services.

I want to see how much these each service are consuming ram.
Code:
systemctl list-unit-files --type service --state enabled
UNIT FILE                                   STATE  
abrt-journal-core.service                   enabled
abrt-oops.service                           enabled
abrt-vmcore.service                         enabled
abrt-xorg.service                           enabled
abrtd.service                               enabled
accounts-daemon.service                     enabled
akmods.service                              enabled
atd.service                                 enabled
auditd.service                              enabled
autovt@.service                             enabled
avahi-daemon.service                        enabled
bluetooth.service                           enabled
chronyd.service                             enabled
crond.service                               enabled
dbus-org.bluez.service                      enabled
dbus-org.fedoraproject.FirewallD1.service   enabled
dbus-org.freedesktop.Avahi.service          enabled
dbus-org.freedesktop.ModemManager1.service  enabled
dbus-org.freedesktop.network1.service       enabled
dbus-org.freedesktop.NetworkManager.service enabled
dbus-org.freedesktop.nm-dispatcher.service  enabled
dbus-org.freedesktop.resolve1.service       enabled
dbus-org.freedesktop.timedate1.service      enabled
dbxtool.service                             enabled
display-manager.service                     enabled
dmraid-activation.service                   enabled
fedora-import-state.service                 enabled
fedora-readonly.service                     enabled
firewalld.service                           enabled
gdm.service                                 enabled
getty@.service                              enabled
iscsi.service                               enabled
libvirtd.service                            enabled
lvm2-monitor.service                        enabled
mcelog.service                              enabled
mdmonitor.service                           enabled
ModemManager.service                        enabled
multipathd.service                          enabled
NetworkManager-dispatcher.service           enabled
NetworkManager-wait-online.service          enabled
NetworkManager.service                      enabled
ostree-remount.service                      enabled
rngd.service                                enabled
rtkit-daemon.service                        enabled
smb.service                                 enabled
spice-vdagentd.service                      enabled
sssd.service                                enabled
switcheroo-control.service                  enabled
systemd-networkd.service                    enabled
systemd-resolved.service                    enabled
timedatex.service                           enabled
udisks2.service                             enabled
vgauthd.service                             enabled
vmtoolsd.service                            enabled
vsftpd.service                              enabled

55 unit files listed.

Last edited by ddenial; 12-15-2017 at 05:57 AM.
 
Old 12-17-2017, 09:04 AM   #2
sevendogsbsd
Senior Member
 
Registered: Sep 2017
Posts: 1,262

Rep: Reputation: 507Reputation: 507Reputation: 507Reputation: 507Reputation: 507Reputation: 507
Give htop a try - it shows services and memory used on my box. Can't speak for whether it shows this data in distros using systemd because I use runit.
 
Old 12-17-2017, 10:47 AM   #3
Mill J
Member
 
Registered: Feb 2017
Location: 127.0.0.1 Sweet 127.0.0.1
Distribution: Void, MX, Haiku, Icaros, Puppy and many others
Posts: 977
Blog Entries: 2

Rep: Reputation: 408Reputation: 408Reputation: 408Reputation: 408Reputation: 408
Your using Ubuntu. right? Why don't you just use the system monitor? It's graphic and preinstalled on all the Ubuntus I have run.
 
Old 12-17-2017, 03:47 PM   #4
ddenial
Member
 
Registered: Dec 2016
Distribution: CentOS, Fedora, Ubuntu
Posts: 215

Original Poster
Rep: Reputation: 38
No. It's Fedora 27. System Monitor shows only processes. I'm referring to services.

Anyway came across this article monitoring systemd services by using systemd-cgtop. Will check and see if it works.
 
1 members found this post helpful.
Old 12-17-2017, 06:08 PM   #5
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,511

Rep: Reputation: 1006Reputation: 1006Reputation: 1006Reputation: 1006Reputation: 1006Reputation: 1006Reputation: 1006Reputation: 1006
So, you want to display only services in the output?
Code:
$ ps auxU root
 
Old 12-17-2017, 06:26 PM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 18,396

Rep: Reputation: 3048Reputation: 3048Reputation: 3048Reputation: 3048Reputation: 3048Reputation: 3048Reputation: 3048Reputation: 3048Reputation: 3048Reputation: 3048Reputation: 3048
That cgtop looks interesting - note on F27 you will have to enable most of that accounting yourself.
 
1 members found this post helpful.
Old 12-17-2017, 10:11 PM   #7
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 15,790
Blog Entries: 27

Rep: Reputation: 4635Reputation: 4635Reputation: 4635Reputation: 4635Reputation: 4635Reputation: 4635Reputation: 4635Reputation: 4635Reputation: 4635Reputation: 4635Reputation: 4635
I agree with syg00.

Look at man systemd-cgtop or check this link: https://www.freedesktop.org/software...emd-cgtop.html

Here's a bit of the output:

Code:
$ systemd-cgtop

Path                                     Tasks   %CPU   Memory  Input/s Output/s

/                                          193      -     2.1G        -        -
/system.slice/ModemManager.service           1      -        -        -        -
/system.slice/NetworkManager.service         2      -        -        -        -
/system.slice/abrt-oops.service              1      -        -        -        -
Most services, as opposed to daemons (processes) were using little or no memory.

Last edited by frankbell; 12-17-2017 at 10:15 PM.
 
Old 12-18-2017, 07:01 AM   #8
ddenial
Member
 
Registered: Dec 2016
Distribution: CentOS, Fedora, Ubuntu
Posts: 215

Original Poster
Rep: Reputation: 38
After following the steps (except last one) as mentioned on this website, I'm getting the following result:

Code:
# systemd-cgtop -m
Control Group                          Tasks   %CPU   Memory  Input/s Output/s
/                                          -    5.9     5.3G        -        -
/system.slice                            113    0.0   544.1M        -        -
/system.slice/packagekit.service           3      -    44.6M        -        -
/init.scope                                1    0.0    11.1M        -        -
/system.slice/crond.service                1      -     2.3M        -        -
/system.slice/sssd-kcm.service             1      -     2.2M        -        -
/system.slice/sssd-secrets.service         1      -     1.8M        -        -
/system.slice/smb.service                  4      -     1.7M        -        -
/system.sli…systemd-journald.service       1      -     1.1M        -        -
/system.slice/cups.service                 1    0.0   396.0K        -        -
/system.slice/dbus.service                 5      -   396.0K        -        -
/system.slice/NetworkManager.service       3      -   328.0K        -        -
/system.slice/sssd.service                 3    0.0   196.0K        -        -
/system.slice/auditd.service               5      -   180.0K        -        -
/system.slice/udisks2.service              5      -   176.0K        -        -
/system.slice/systemd-logind.service       1      -   128.0K        -        -
/system.slice/systemd-udevd.service        1      -   128.0K        -        -
/system.slice/chronyd.service              1      -   116.0K        -        -
/system.slice/colord.service               3      -    48.0K        -        -
/system.slice/upower.service               3      -    12.0K        -        -
/system.slice/abrt-xorg.service            1      -     8.0K        -        -
/system.slice/abrt-oops.service            1      -     4.0K        -        -
/system.slice/geoclue.service              3      -     4.0K        -        -
But, If I check the total residential memory usage of samba through ps, I get this result.

Code:
 
# pidof smbd
971 905 904 823

# ps -o pid,user,rss,comm -C $(pidof smbd)
  PID USER       RSS COMMAND
  823 root     20800 smbd
  904 root      4956 smbd-notifyd
  905 root      4232 cleanupd
Please note that for samba systemd-cgtop show memory usage of 1.7mb, whereas ps show the usage of nearly 30mb. Also, both systemd-cgtop and pidof smbd shows same 4 tasks. But in pf command, only 3 tasks are shown, PID 971, in this case, is missing.

How come there is a difference. Appreciate if someone explains why.

Thanks
 
Old 12-18-2017, 12:52 PM   #9
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.7.1908
Posts: 4,267

Rep: Reputation: 1495Reputation: 1495Reputation: 1495Reputation: 1495Reputation: 1495Reputation: 1495Reputation: 1495Reputation: 1495Reputation: 1495Reputation: 1495
I don't know the answer to your last question about the missing pid (although I note that the -C wants process names, not pids, so I don't understand how it works at all... -p wants a pidlist), but isn't the ps total shown nearly 30Kb -- not 30Mb???

Last edited by scasey; 12-18-2017 at 12:56 PM.
 
1 members found this post helpful.
Old 12-18-2017, 09:55 PM   #10
ddenial
Member
 
Registered: Dec 2016
Distribution: CentOS, Fedora, Ubuntu
Posts: 215

Original Poster
Rep: Reputation: 38
Quote:
Originally Posted by scasey View Post
I don't know the answer to your last question about the missing pid (although I note that the -C wants process names, not pids, so I don't understand how it works at all... -p wants a pidlist), but isn't the ps total shown nearly 30Kb -- not 30Mb???
You're right I should have used -p. For some good reason, Its now showing correctly. And I think its mb not kb.

Code:
$ systemd-cgtop -m | grep smb
/system.slice/smb.service                           4      -    22.8M        -        -

$ ps -o pid,user,rss,comm -p $(pidof smbd)
  PID USER       RSS COMMAND
  872 root     20368 smbd
 1009 root      4960 smbd-notifyd
 1010 root      4236 cleanupd
 1038 root      5580 lpqd

$ top
top - 08:20:17 up 12 min,  1 user,  load average: 0.05, 0.54, 0.51
Tasks: 277 total,   1 running, 209 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.6 us,  0.6 sy,  0.0 ni, 98.4 id,  0.2 wa,  0.1 hi,  0.0 si,  0.0 st
MiB Mem : 7920.203 total, 4493.922 free, 1943.145 used, 1483.137 buff/cache
MiB Swap:    0.000 total,    0.000 free,    0.000 used. 5575.648 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                
  872 root      20   0  448.9m  19.9m  17.5m S   0.0  0.3   0:00.06 smbd                                                                                                   
 1009 root      20   0  421.6m   4.8m   2.6m S   0.0  0.1   0:00.00 smbd-notifyd  
 1010 root      20   0  421.6m   4.1m   1.9m S   0.0  0.1   0:00.00 cleanupd                                                                                               
 1038 root      20   0  448.9m   6.1m   3.7m S   0.0  0.1   0:00.00 lpqd
Thanks

Last edited by ddenial; 12-18-2017 at 10:05 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find how many memory slot and max memory can be used in linux server QWE123 Linux - Newbie 10 10-26-2016 10:51 AM
Which services can I close on a low memory system ? banuazizi Linux - Newbie 15 07-22-2011 01:05 PM
Help, how to find boot order of scripts/services? Avatar Linux - Server 4 07-30-2008 08:48 AM
Where to find system services information joeyBig Linux - General 1 07-24-2004 09:52 AM
where can i find clear informations about SERVICES in MANDRAKE 9.0? kublador Linux - Distributions 2 07-06-2003 02:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration