How can I monitor the memory usage?
up vote
241
down vote
favorite
I have used top
to see the memory usage at the moment. But I would like to monitor the memory usage over a period of time. E.g start monitoring and then execute a few commands, and final stop the monitoring and see how much memory that have been used during the period.
How can I do this on Ubuntu Server?
I guess I could start a cronjob every 5th second or so, and invoke a command that log the current memory usage in a textfile. But what command should I use to get the current memory usage in a format that is easy to log to a text file?
server memory monitoring logging memory-usage
add a comment |
up vote
241
down vote
favorite
I have used top
to see the memory usage at the moment. But I would like to monitor the memory usage over a period of time. E.g start monitoring and then execute a few commands, and final stop the monitoring and see how much memory that have been used during the period.
How can I do this on Ubuntu Server?
I guess I could start a cronjob every 5th second or so, and invoke a command that log the current memory usage in a textfile. But what command should I use to get the current memory usage in a format that is easy to log to a text file?
server memory monitoring logging memory-usage
add a comment |
up vote
241
down vote
favorite
up vote
241
down vote
favorite
I have used top
to see the memory usage at the moment. But I would like to monitor the memory usage over a period of time. E.g start monitoring and then execute a few commands, and final stop the monitoring and see how much memory that have been used during the period.
How can I do this on Ubuntu Server?
I guess I could start a cronjob every 5th second or so, and invoke a command that log the current memory usage in a textfile. But what command should I use to get the current memory usage in a format that is easy to log to a text file?
server memory monitoring logging memory-usage
I have used top
to see the memory usage at the moment. But I would like to monitor the memory usage over a period of time. E.g start monitoring and then execute a few commands, and final stop the monitoring and see how much memory that have been used during the period.
How can I do this on Ubuntu Server?
I guess I could start a cronjob every 5th second or so, and invoke a command that log the current memory usage in a textfile. But what command should I use to get the current memory usage in a format that is easy to log to a text file?
server memory monitoring logging memory-usage
server memory monitoring logging memory-usage
edited Oct 26 '10 at 18:20
asked Oct 26 '10 at 16:50
Jonas
2,658132636
2,658132636
add a comment |
add a comment |
10 Answers
10
active
oldest
votes
up vote
296
down vote
accepted
I recommend combining the previous answers
watch -n 5 free -m
Note that Linux likes to use any extra memory to cache hard drive blocks. So you don't want to look at just the free Mem
. You want to look at the free
column of the -/+ buffers/cache:
row. This shows how much memory is available to applications. So I just ran free -m
and got this:
total used free shared buffers cached
Mem: 3699 2896 802 0 247 1120
-/+ buffers/cache: 1528 2170
Swap: 1905 62 1843
I know that I'm using 1528 MB and have 2170 MB free.
Note: To stop this watch
cycle you can just press Ctrl+C.
1
Thanks, that's informative. But on the used column you first have2896
and then1528
for buffers, doesn't this mean that you are using2896 + 1528
?
– Jonas
Oct 26 '10 at 17:48
8
Mem: used
is your total used memory.-/+ buffers/cache: used
is your total used memory minus buffers and cache. I know the output looks funny, but no arithmetic is required here. You're just looking for used/free in the -/+ buffers/cache row.
– Justin Force
Oct 26 '10 at 18:49
4
The -h option is a lot nicer
– frmdstryr
Oct 19 '17 at 20:11
1
@frmdstryr Good point! -h/--human did not exist when I wrote this, though. gitlab.com/procps-ng/procps/commit/…
– Justin Force
Oct 20 '17 at 18:51
2
@cbradsh1 You can just dofree -h
, e.g.watch -n 5 free -h
to get "human readable" output, e.g.2.1G
instead of2170
in the output.
– Justin Force
May 16 at 22:11
|
show 2 more comments
up vote
199
down vote
I think htop
is the best solution.
sudo apt-get install htop
This way you will notice what programs is using most RAM. and you can easily terminate one if you want to. Here's a screenshot!
2
htop
is nice because it's more "graphical" and possibly easier to read thanfree
.
– mjswensen
Nov 26 '13 at 22:32
1
i don't understand the output. IsRES
the memory used by that application in MB? THen what isSHR
?
– faizal
Aug 19 '14 at 13:51
1
@faizal: virtual, reserved & shared memory.
– WitchCraft
Sep 19 '15 at 7:47
1
how doeshtop
show you the ' the memory usage over a period of time'?
– dangel
Aug 7 '16 at 0:57
htop -s M_SHARE htop -s TIME
– Tomachi
Aug 21 at 5:08
add a comment |
up vote
39
down vote
If you looking for a nice breakdown of the memory used by each running process, then I might recommend checking out ps_mem.py (found here at pixelbeat.org).
I know in the comments above, you mentioned wanting a one-line snapshot from free, but I figured others might find this useful.
Example output:
user@system:~$ sudo ps_mem.py
[sudo] password for user:
Private + Shared = RAM used Program
4.0 KiB + 7.5 KiB = 11.5 KiB logger
4.0 KiB + 8.0 KiB = 12.0 KiB mysqld_safe
4.0 KiB + 10.0 KiB = 14.0 KiB getty
4.0 KiB + 42.0 KiB = 46.0 KiB saslauthd (5)
48.0 KiB + 13.0 KiB = 61.0 KiB init
56.0 KiB + 27.5 KiB = 83.5 KiB memcached
84.0 KiB + 26.5 KiB = 110.5 KiB cron
120.0 KiB + 50.0 KiB = 170.0 KiB master
204.0 KiB + 107.5 KiB = 311.5 KiB qmgr
396.0 KiB + 94.0 KiB = 490.0 KiB tlsmgr
460.0 KiB + 65.0 KiB = 525.0 KiB rsyslogd
384.0 KiB + 171.0 KiB = 555.0 KiB sudo
476.0 KiB + 83.0 KiB = 559.0 KiB monit
568.0 KiB + 60.0 KiB = 628.0 KiB freshclam
552.0 KiB + 259.5 KiB = 811.5 KiB pickup
1.1 MiB + 80.0 KiB = 1.2 MiB bash
1.4 MiB + 308.5 KiB = 1.7 MiB fail2ban-server
888.0 KiB + 1.0 MiB = 1.9 MiB sshd (3)
1.9 MiB + 32.5 KiB = 1.9 MiB munin-node
13.1 MiB + 86.0 KiB = 13.2 MiB mysqld
147.4 MiB + 36.5 MiB = 183.9 MiB apache2 (7)
---------------------------------
208.1 MiB
=================================
Private + Shared = RAM used Program
The only part I don't like is the fact that the script claims to require root privileges. I haven't had an opportunity yet to see exactly why this is the case.
I wonder whether memory is shared between threads. It is shared between processes, isn't it? At least on Windows...
– Thomas Weller
Dec 27 '14 at 12:51
So this case, the shared memory refers to pages that are mapped by multiple processes in the form of shared libraries. Additionally within the context of a multi-threaded applications the entire process memory space is accessible by all threads in that process.
– Jason Mock
Oct 1 '15 at 23:37
4
Now available in PyPI (pip install ps_mem
) and on GitHub.
– Leif Arne Storset
Jan 9 '17 at 14:39
@ThomasWeller: Yes, threads always share memory, whereas processes may share some or all of it under certain conditions.
– Leif Arne Storset
Jan 9 '17 at 14:44
for this I use gnome-system-monitor
– jms
Dec 26 '17 at 7:39
|
show 2 more comments
up vote
24
down vote
Use the free command.
For example, this is the ouput of free -m
:
total used free shared buffers cached
Mem: 2012 1666 345 0 101 616
-/+ buffers/cache: 947 1064
Swap: 7624 0 7624
free -m | grep /+
will return only the second line:
-/+ buffers/cache: 947 1064
Thanks, looks great. So this947
is memory usage minus the memory used for buffers and caches?
– Jonas
Oct 26 '10 at 17:54
add a comment |
up vote
10
down vote
The watch command may be useful. Try watch -n 5 free
to monitor memory usage with updates every five seconds.
Thanks, this was great! However, I would prefer to get the memory usage on a single line, so it's easy to log to a text file.
– Jonas
Oct 26 '10 at 17:44
add a comment |
up vote
5
down vote
You can do it using cat /proc/meminfo
.
MemTotal: 4039160 kB
MemFree: 309796 kB
MemAvailable: 3001052 kB
Buffers: 345636 kB
Cached: 2341288 kB
SwapCached: 8 kB
Active: 1725160 kB
Inactive: 1551652 kB
Active(anon): 538404 kB
Inactive(anon): 70076 kB
Active(file): 1186756 kB
Inactive(file): 1481576 kB
Unevictable: 32 kB
Mlocked: 32 kB
SwapTotal: 4194300 kB
SwapFree: 4194044 kB
Dirty: 0 kB
Writeback: 0 kB
AnonPages: 589988 kB
Mapped: 255972 kB
Shmem: 18596 kB
Slab: 374888 kB
SReclaimable: 310496 kB
SUnreclaim: 64392 kB
KernelStack: 6976 kB
PageTables: 26452 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 6213880 kB
Committed_AS: 3589736 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
HardwareCorrupted: 0 kB
AnonHugePages: 0 kB
ShmemHugePages: 0 kB
ShmemPmdMapped: 0 kB
CmaTotal: 0 kB
CmaFree: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 147392 kB
DirectMap2M: 4046848 kB
1
adding watch to the front of this command makes it awesome! as inwatch cat /proc/meminfo
– Elder Geek
Nov 9 '16 at 3:58
Thefree
command takes its information from/proc/meminfo
and presents them in a compact way. Usefree -h
for human-readable output.
– LoMaPh
Feb 17 at 8:51
add a comment |
up vote
4
down vote
For visual monitoring of overall RAM usage, if you use Byobu, it will keep your memory usage in the lower right-hand corner of the terminal and will run while you are in any terminal session.
As you can see from screenshot, my virtual machine has a 1h3m uptime, 0.00 load, has 2.8GHz (virtual) processor and 994MB (21%) of the RAM available on the system.
add a comment |
up vote
3
down vote
Single line solution and output:
free -m | grep "Mem:"
Here is an example of the expected output:
Mem: 3944 652 302 18 2990 2930
This will also let you see the memory-usage at the moment...
– mook765
Sep 27 '16 at 14:38
add a comment |
up vote
1
down vote
I would use Cacti. This will graph your memory usage etc over a period of time, and you will be able to check on usage using your web browser.
add a comment |
up vote
1
down vote
Monitoring Memory Usage
I'm more in line with one of the preceding posts that mentioned Cacti as a great way to monitor memory usage. However, since it appears cacti is no longer popular in the mainstream, there is an alternative graphing application called Graphite.
Graphite is relatively easy to install on a ubuntu server and to install it, you can check out this link for the easy to follow installation procedures.
After graphite has been installed, now, you can send memory metrics to it, at whichever interval you wish; every 5 seconds, every minute, every hour...etc.
To graph memory metrics, as already suggested in previous posts, you can write your own script using system tools to gather the necessary memory information. Or, you can use a prewritten snmp plugin that'll do all the work for you.
If you wish to write your own memory script, it'll be wise to ensure you account for buffered and cached memory when calculating used memory, otherwise, you'll end up gathering false data.
If you wish to instead utilize an snmp plugin that already does all the necessary calculations for you, here's a link to one that works pretty well: checkMemoryviaSNMP.
Pros of SNMP:
I have snmp installed on all the remote nodes I monitor. This allows me to monitor all my systems from one central server(s), without having to copy or put a plugin on the remote nodes.
Cons of SNMP:
You'd have to ensure the snmp agent is installed on each of the remote nodes you wish to monitor memory on. However, this installation will be a one time deal. If you're using automation tools such as chef or puppet or similar tools in your environment, then this isn't a problem at all.
Configuration of the SNMP agent on the remote node(s):
After the snmp agent has been installed, simply vi the /etc/snmpd/snmpd.conf file and add this line to it:
rocommunity (specify-a-community-string-aka-password-here)
Then restart the snmpd agent, with:
/etc/init.d/snmpd restart
Then, on your central server, from which you instead to monitor all your other servers, you can run the following command:
$ time ./checkMemoryviaSNMP -v2 public gearman001.phs.blah.com 30 90 graphite,10.10.10.10,2003,typical
WARNING: Used = [ 3.26154 GB ], Installed = [ 5.71509 GB ], PCT.Used = [ 57.069% ], Available.Memory = [ 2.00291 GB ]. Buffer = [ 137.594 MB ], Cached = [ 1.3849 GB ]. Thresholds: [ W=(30%) / C=(90%) ]. System Information = [ Linux gearman001.phs.blah.com 2.6.32-504.30.3.el6.x86_64 #1 SMP Thu Jul 9 15:20:47 EDT 2015 x86_64 ].
real 0m0.23s
user 0m0.03s
sys 0m0.02s
add a comment |
10 Answers
10
active
oldest
votes
10 Answers
10
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
296
down vote
accepted
I recommend combining the previous answers
watch -n 5 free -m
Note that Linux likes to use any extra memory to cache hard drive blocks. So you don't want to look at just the free Mem
. You want to look at the free
column of the -/+ buffers/cache:
row. This shows how much memory is available to applications. So I just ran free -m
and got this:
total used free shared buffers cached
Mem: 3699 2896 802 0 247 1120
-/+ buffers/cache: 1528 2170
Swap: 1905 62 1843
I know that I'm using 1528 MB and have 2170 MB free.
Note: To stop this watch
cycle you can just press Ctrl+C.
1
Thanks, that's informative. But on the used column you first have2896
and then1528
for buffers, doesn't this mean that you are using2896 + 1528
?
– Jonas
Oct 26 '10 at 17:48
8
Mem: used
is your total used memory.-/+ buffers/cache: used
is your total used memory minus buffers and cache. I know the output looks funny, but no arithmetic is required here. You're just looking for used/free in the -/+ buffers/cache row.
– Justin Force
Oct 26 '10 at 18:49
4
The -h option is a lot nicer
– frmdstryr
Oct 19 '17 at 20:11
1
@frmdstryr Good point! -h/--human did not exist when I wrote this, though. gitlab.com/procps-ng/procps/commit/…
– Justin Force
Oct 20 '17 at 18:51
2
@cbradsh1 You can just dofree -h
, e.g.watch -n 5 free -h
to get "human readable" output, e.g.2.1G
instead of2170
in the output.
– Justin Force
May 16 at 22:11
|
show 2 more comments
up vote
296
down vote
accepted
I recommend combining the previous answers
watch -n 5 free -m
Note that Linux likes to use any extra memory to cache hard drive blocks. So you don't want to look at just the free Mem
. You want to look at the free
column of the -/+ buffers/cache:
row. This shows how much memory is available to applications. So I just ran free -m
and got this:
total used free shared buffers cached
Mem: 3699 2896 802 0 247 1120
-/+ buffers/cache: 1528 2170
Swap: 1905 62 1843
I know that I'm using 1528 MB and have 2170 MB free.
Note: To stop this watch
cycle you can just press Ctrl+C.
1
Thanks, that's informative. But on the used column you first have2896
and then1528
for buffers, doesn't this mean that you are using2896 + 1528
?
– Jonas
Oct 26 '10 at 17:48
8
Mem: used
is your total used memory.-/+ buffers/cache: used
is your total used memory minus buffers and cache. I know the output looks funny, but no arithmetic is required here. You're just looking for used/free in the -/+ buffers/cache row.
– Justin Force
Oct 26 '10 at 18:49
4
The -h option is a lot nicer
– frmdstryr
Oct 19 '17 at 20:11
1
@frmdstryr Good point! -h/--human did not exist when I wrote this, though. gitlab.com/procps-ng/procps/commit/…
– Justin Force
Oct 20 '17 at 18:51
2
@cbradsh1 You can just dofree -h
, e.g.watch -n 5 free -h
to get "human readable" output, e.g.2.1G
instead of2170
in the output.
– Justin Force
May 16 at 22:11
|
show 2 more comments
up vote
296
down vote
accepted
up vote
296
down vote
accepted
I recommend combining the previous answers
watch -n 5 free -m
Note that Linux likes to use any extra memory to cache hard drive blocks. So you don't want to look at just the free Mem
. You want to look at the free
column of the -/+ buffers/cache:
row. This shows how much memory is available to applications. So I just ran free -m
and got this:
total used free shared buffers cached
Mem: 3699 2896 802 0 247 1120
-/+ buffers/cache: 1528 2170
Swap: 1905 62 1843
I know that I'm using 1528 MB and have 2170 MB free.
Note: To stop this watch
cycle you can just press Ctrl+C.
I recommend combining the previous answers
watch -n 5 free -m
Note that Linux likes to use any extra memory to cache hard drive blocks. So you don't want to look at just the free Mem
. You want to look at the free
column of the -/+ buffers/cache:
row. This shows how much memory is available to applications. So I just ran free -m
and got this:
total used free shared buffers cached
Mem: 3699 2896 802 0 247 1120
-/+ buffers/cache: 1528 2170
Swap: 1905 62 1843
I know that I'm using 1528 MB and have 2170 MB free.
Note: To stop this watch
cycle you can just press Ctrl+C.
edited Jan 27 '17 at 21:11
answered Oct 26 '10 at 17:40
Justin Force
3,22111114
3,22111114
1
Thanks, that's informative. But on the used column you first have2896
and then1528
for buffers, doesn't this mean that you are using2896 + 1528
?
– Jonas
Oct 26 '10 at 17:48
8
Mem: used
is your total used memory.-/+ buffers/cache: used
is your total used memory minus buffers and cache. I know the output looks funny, but no arithmetic is required here. You're just looking for used/free in the -/+ buffers/cache row.
– Justin Force
Oct 26 '10 at 18:49
4
The -h option is a lot nicer
– frmdstryr
Oct 19 '17 at 20:11
1
@frmdstryr Good point! -h/--human did not exist when I wrote this, though. gitlab.com/procps-ng/procps/commit/…
– Justin Force
Oct 20 '17 at 18:51
2
@cbradsh1 You can just dofree -h
, e.g.watch -n 5 free -h
to get "human readable" output, e.g.2.1G
instead of2170
in the output.
– Justin Force
May 16 at 22:11
|
show 2 more comments
1
Thanks, that's informative. But on the used column you first have2896
and then1528
for buffers, doesn't this mean that you are using2896 + 1528
?
– Jonas
Oct 26 '10 at 17:48
8
Mem: used
is your total used memory.-/+ buffers/cache: used
is your total used memory minus buffers and cache. I know the output looks funny, but no arithmetic is required here. You're just looking for used/free in the -/+ buffers/cache row.
– Justin Force
Oct 26 '10 at 18:49
4
The -h option is a lot nicer
– frmdstryr
Oct 19 '17 at 20:11
1
@frmdstryr Good point! -h/--human did not exist when I wrote this, though. gitlab.com/procps-ng/procps/commit/…
– Justin Force
Oct 20 '17 at 18:51
2
@cbradsh1 You can just dofree -h
, e.g.watch -n 5 free -h
to get "human readable" output, e.g.2.1G
instead of2170
in the output.
– Justin Force
May 16 at 22:11
1
1
Thanks, that's informative. But on the used column you first have
2896
and then 1528
for buffers, doesn't this mean that you are using 2896 + 1528
?– Jonas
Oct 26 '10 at 17:48
Thanks, that's informative. But on the used column you first have
2896
and then 1528
for buffers, doesn't this mean that you are using 2896 + 1528
?– Jonas
Oct 26 '10 at 17:48
8
8
Mem: used
is your total used memory. -/+ buffers/cache: used
is your total used memory minus buffers and cache. I know the output looks funny, but no arithmetic is required here. You're just looking for used/free in the -/+ buffers/cache row.– Justin Force
Oct 26 '10 at 18:49
Mem: used
is your total used memory. -/+ buffers/cache: used
is your total used memory minus buffers and cache. I know the output looks funny, but no arithmetic is required here. You're just looking for used/free in the -/+ buffers/cache row.– Justin Force
Oct 26 '10 at 18:49
4
4
The -h option is a lot nicer
– frmdstryr
Oct 19 '17 at 20:11
The -h option is a lot nicer
– frmdstryr
Oct 19 '17 at 20:11
1
1
@frmdstryr Good point! -h/--human did not exist when I wrote this, though. gitlab.com/procps-ng/procps/commit/…
– Justin Force
Oct 20 '17 at 18:51
@frmdstryr Good point! -h/--human did not exist when I wrote this, though. gitlab.com/procps-ng/procps/commit/…
– Justin Force
Oct 20 '17 at 18:51
2
2
@cbradsh1 You can just do
free -h
, e.g. watch -n 5 free -h
to get "human readable" output, e.g. 2.1G
instead of 2170
in the output.– Justin Force
May 16 at 22:11
@cbradsh1 You can just do
free -h
, e.g. watch -n 5 free -h
to get "human readable" output, e.g. 2.1G
instead of 2170
in the output.– Justin Force
May 16 at 22:11
|
show 2 more comments
up vote
199
down vote
I think htop
is the best solution.
sudo apt-get install htop
This way you will notice what programs is using most RAM. and you can easily terminate one if you want to. Here's a screenshot!
2
htop
is nice because it's more "graphical" and possibly easier to read thanfree
.
– mjswensen
Nov 26 '13 at 22:32
1
i don't understand the output. IsRES
the memory used by that application in MB? THen what isSHR
?
– faizal
Aug 19 '14 at 13:51
1
@faizal: virtual, reserved & shared memory.
– WitchCraft
Sep 19 '15 at 7:47
1
how doeshtop
show you the ' the memory usage over a period of time'?
– dangel
Aug 7 '16 at 0:57
htop -s M_SHARE htop -s TIME
– Tomachi
Aug 21 at 5:08
add a comment |
up vote
199
down vote
I think htop
is the best solution.
sudo apt-get install htop
This way you will notice what programs is using most RAM. and you can easily terminate one if you want to. Here's a screenshot!
2
htop
is nice because it's more "graphical" and possibly easier to read thanfree
.
– mjswensen
Nov 26 '13 at 22:32
1
i don't understand the output. IsRES
the memory used by that application in MB? THen what isSHR
?
– faizal
Aug 19 '14 at 13:51
1
@faizal: virtual, reserved & shared memory.
– WitchCraft
Sep 19 '15 at 7:47
1
how doeshtop
show you the ' the memory usage over a period of time'?
– dangel
Aug 7 '16 at 0:57
htop -s M_SHARE htop -s TIME
– Tomachi
Aug 21 at 5:08
add a comment |
up vote
199
down vote
up vote
199
down vote
I think htop
is the best solution.
sudo apt-get install htop
This way you will notice what programs is using most RAM. and you can easily terminate one if you want to. Here's a screenshot!
I think htop
is the best solution.
sudo apt-get install htop
This way you will notice what programs is using most RAM. and you can easily terminate one if you want to. Here's a screenshot!
edited Aug 15 '14 at 17:07
answered May 18 '12 at 0:11
Alvar
11.5k2677126
11.5k2677126
2
htop
is nice because it's more "graphical" and possibly easier to read thanfree
.
– mjswensen
Nov 26 '13 at 22:32
1
i don't understand the output. IsRES
the memory used by that application in MB? THen what isSHR
?
– faizal
Aug 19 '14 at 13:51
1
@faizal: virtual, reserved & shared memory.
– WitchCraft
Sep 19 '15 at 7:47
1
how doeshtop
show you the ' the memory usage over a period of time'?
– dangel
Aug 7 '16 at 0:57
htop -s M_SHARE htop -s TIME
– Tomachi
Aug 21 at 5:08
add a comment |
2
htop
is nice because it's more "graphical" and possibly easier to read thanfree
.
– mjswensen
Nov 26 '13 at 22:32
1
i don't understand the output. IsRES
the memory used by that application in MB? THen what isSHR
?
– faizal
Aug 19 '14 at 13:51
1
@faizal: virtual, reserved & shared memory.
– WitchCraft
Sep 19 '15 at 7:47
1
how doeshtop
show you the ' the memory usage over a period of time'?
– dangel
Aug 7 '16 at 0:57
htop -s M_SHARE htop -s TIME
– Tomachi
Aug 21 at 5:08
2
2
htop
is nice because it's more "graphical" and possibly easier to read than free
.– mjswensen
Nov 26 '13 at 22:32
htop
is nice because it's more "graphical" and possibly easier to read than free
.– mjswensen
Nov 26 '13 at 22:32
1
1
i don't understand the output. Is
RES
the memory used by that application in MB? THen what is SHR
?– faizal
Aug 19 '14 at 13:51
i don't understand the output. Is
RES
the memory used by that application in MB? THen what is SHR
?– faizal
Aug 19 '14 at 13:51
1
1
@faizal: virtual, reserved & shared memory.
– WitchCraft
Sep 19 '15 at 7:47
@faizal: virtual, reserved & shared memory.
– WitchCraft
Sep 19 '15 at 7:47
1
1
how does
htop
show you the ' the memory usage over a period of time'?– dangel
Aug 7 '16 at 0:57
how does
htop
show you the ' the memory usage over a period of time'?– dangel
Aug 7 '16 at 0:57
htop -s M_SHARE htop -s TIME
– Tomachi
Aug 21 at 5:08
htop -s M_SHARE htop -s TIME
– Tomachi
Aug 21 at 5:08
add a comment |
up vote
39
down vote
If you looking for a nice breakdown of the memory used by each running process, then I might recommend checking out ps_mem.py (found here at pixelbeat.org).
I know in the comments above, you mentioned wanting a one-line snapshot from free, but I figured others might find this useful.
Example output:
user@system:~$ sudo ps_mem.py
[sudo] password for user:
Private + Shared = RAM used Program
4.0 KiB + 7.5 KiB = 11.5 KiB logger
4.0 KiB + 8.0 KiB = 12.0 KiB mysqld_safe
4.0 KiB + 10.0 KiB = 14.0 KiB getty
4.0 KiB + 42.0 KiB = 46.0 KiB saslauthd (5)
48.0 KiB + 13.0 KiB = 61.0 KiB init
56.0 KiB + 27.5 KiB = 83.5 KiB memcached
84.0 KiB + 26.5 KiB = 110.5 KiB cron
120.0 KiB + 50.0 KiB = 170.0 KiB master
204.0 KiB + 107.5 KiB = 311.5 KiB qmgr
396.0 KiB + 94.0 KiB = 490.0 KiB tlsmgr
460.0 KiB + 65.0 KiB = 525.0 KiB rsyslogd
384.0 KiB + 171.0 KiB = 555.0 KiB sudo
476.0 KiB + 83.0 KiB = 559.0 KiB monit
568.0 KiB + 60.0 KiB = 628.0 KiB freshclam
552.0 KiB + 259.5 KiB = 811.5 KiB pickup
1.1 MiB + 80.0 KiB = 1.2 MiB bash
1.4 MiB + 308.5 KiB = 1.7 MiB fail2ban-server
888.0 KiB + 1.0 MiB = 1.9 MiB sshd (3)
1.9 MiB + 32.5 KiB = 1.9 MiB munin-node
13.1 MiB + 86.0 KiB = 13.2 MiB mysqld
147.4 MiB + 36.5 MiB = 183.9 MiB apache2 (7)
---------------------------------
208.1 MiB
=================================
Private + Shared = RAM used Program
The only part I don't like is the fact that the script claims to require root privileges. I haven't had an opportunity yet to see exactly why this is the case.
I wonder whether memory is shared between threads. It is shared between processes, isn't it? At least on Windows...
– Thomas Weller
Dec 27 '14 at 12:51
So this case, the shared memory refers to pages that are mapped by multiple processes in the form of shared libraries. Additionally within the context of a multi-threaded applications the entire process memory space is accessible by all threads in that process.
– Jason Mock
Oct 1 '15 at 23:37
4
Now available in PyPI (pip install ps_mem
) and on GitHub.
– Leif Arne Storset
Jan 9 '17 at 14:39
@ThomasWeller: Yes, threads always share memory, whereas processes may share some or all of it under certain conditions.
– Leif Arne Storset
Jan 9 '17 at 14:44
for this I use gnome-system-monitor
– jms
Dec 26 '17 at 7:39
|
show 2 more comments
up vote
39
down vote
If you looking for a nice breakdown of the memory used by each running process, then I might recommend checking out ps_mem.py (found here at pixelbeat.org).
I know in the comments above, you mentioned wanting a one-line snapshot from free, but I figured others might find this useful.
Example output:
user@system:~$ sudo ps_mem.py
[sudo] password for user:
Private + Shared = RAM used Program
4.0 KiB + 7.5 KiB = 11.5 KiB logger
4.0 KiB + 8.0 KiB = 12.0 KiB mysqld_safe
4.0 KiB + 10.0 KiB = 14.0 KiB getty
4.0 KiB + 42.0 KiB = 46.0 KiB saslauthd (5)
48.0 KiB + 13.0 KiB = 61.0 KiB init
56.0 KiB + 27.5 KiB = 83.5 KiB memcached
84.0 KiB + 26.5 KiB = 110.5 KiB cron
120.0 KiB + 50.0 KiB = 170.0 KiB master
204.0 KiB + 107.5 KiB = 311.5 KiB qmgr
396.0 KiB + 94.0 KiB = 490.0 KiB tlsmgr
460.0 KiB + 65.0 KiB = 525.0 KiB rsyslogd
384.0 KiB + 171.0 KiB = 555.0 KiB sudo
476.0 KiB + 83.0 KiB = 559.0 KiB monit
568.0 KiB + 60.0 KiB = 628.0 KiB freshclam
552.0 KiB + 259.5 KiB = 811.5 KiB pickup
1.1 MiB + 80.0 KiB = 1.2 MiB bash
1.4 MiB + 308.5 KiB = 1.7 MiB fail2ban-server
888.0 KiB + 1.0 MiB = 1.9 MiB sshd (3)
1.9 MiB + 32.5 KiB = 1.9 MiB munin-node
13.1 MiB + 86.0 KiB = 13.2 MiB mysqld
147.4 MiB + 36.5 MiB = 183.9 MiB apache2 (7)
---------------------------------
208.1 MiB
=================================
Private + Shared = RAM used Program
The only part I don't like is the fact that the script claims to require root privileges. I haven't had an opportunity yet to see exactly why this is the case.
I wonder whether memory is shared between threads. It is shared between processes, isn't it? At least on Windows...
– Thomas Weller
Dec 27 '14 at 12:51
So this case, the shared memory refers to pages that are mapped by multiple processes in the form of shared libraries. Additionally within the context of a multi-threaded applications the entire process memory space is accessible by all threads in that process.
– Jason Mock
Oct 1 '15 at 23:37
4
Now available in PyPI (pip install ps_mem
) and on GitHub.
– Leif Arne Storset
Jan 9 '17 at 14:39
@ThomasWeller: Yes, threads always share memory, whereas processes may share some or all of it under certain conditions.
– Leif Arne Storset
Jan 9 '17 at 14:44
for this I use gnome-system-monitor
– jms
Dec 26 '17 at 7:39
|
show 2 more comments
up vote
39
down vote
up vote
39
down vote
If you looking for a nice breakdown of the memory used by each running process, then I might recommend checking out ps_mem.py (found here at pixelbeat.org).
I know in the comments above, you mentioned wanting a one-line snapshot from free, but I figured others might find this useful.
Example output:
user@system:~$ sudo ps_mem.py
[sudo] password for user:
Private + Shared = RAM used Program
4.0 KiB + 7.5 KiB = 11.5 KiB logger
4.0 KiB + 8.0 KiB = 12.0 KiB mysqld_safe
4.0 KiB + 10.0 KiB = 14.0 KiB getty
4.0 KiB + 42.0 KiB = 46.0 KiB saslauthd (5)
48.0 KiB + 13.0 KiB = 61.0 KiB init
56.0 KiB + 27.5 KiB = 83.5 KiB memcached
84.0 KiB + 26.5 KiB = 110.5 KiB cron
120.0 KiB + 50.0 KiB = 170.0 KiB master
204.0 KiB + 107.5 KiB = 311.5 KiB qmgr
396.0 KiB + 94.0 KiB = 490.0 KiB tlsmgr
460.0 KiB + 65.0 KiB = 525.0 KiB rsyslogd
384.0 KiB + 171.0 KiB = 555.0 KiB sudo
476.0 KiB + 83.0 KiB = 559.0 KiB monit
568.0 KiB + 60.0 KiB = 628.0 KiB freshclam
552.0 KiB + 259.5 KiB = 811.5 KiB pickup
1.1 MiB + 80.0 KiB = 1.2 MiB bash
1.4 MiB + 308.5 KiB = 1.7 MiB fail2ban-server
888.0 KiB + 1.0 MiB = 1.9 MiB sshd (3)
1.9 MiB + 32.5 KiB = 1.9 MiB munin-node
13.1 MiB + 86.0 KiB = 13.2 MiB mysqld
147.4 MiB + 36.5 MiB = 183.9 MiB apache2 (7)
---------------------------------
208.1 MiB
=================================
Private + Shared = RAM used Program
The only part I don't like is the fact that the script claims to require root privileges. I haven't had an opportunity yet to see exactly why this is the case.
If you looking for a nice breakdown of the memory used by each running process, then I might recommend checking out ps_mem.py (found here at pixelbeat.org).
I know in the comments above, you mentioned wanting a one-line snapshot from free, but I figured others might find this useful.
Example output:
user@system:~$ sudo ps_mem.py
[sudo] password for user:
Private + Shared = RAM used Program
4.0 KiB + 7.5 KiB = 11.5 KiB logger
4.0 KiB + 8.0 KiB = 12.0 KiB mysqld_safe
4.0 KiB + 10.0 KiB = 14.0 KiB getty
4.0 KiB + 42.0 KiB = 46.0 KiB saslauthd (5)
48.0 KiB + 13.0 KiB = 61.0 KiB init
56.0 KiB + 27.5 KiB = 83.5 KiB memcached
84.0 KiB + 26.5 KiB = 110.5 KiB cron
120.0 KiB + 50.0 KiB = 170.0 KiB master
204.0 KiB + 107.5 KiB = 311.5 KiB qmgr
396.0 KiB + 94.0 KiB = 490.0 KiB tlsmgr
460.0 KiB + 65.0 KiB = 525.0 KiB rsyslogd
384.0 KiB + 171.0 KiB = 555.0 KiB sudo
476.0 KiB + 83.0 KiB = 559.0 KiB monit
568.0 KiB + 60.0 KiB = 628.0 KiB freshclam
552.0 KiB + 259.5 KiB = 811.5 KiB pickup
1.1 MiB + 80.0 KiB = 1.2 MiB bash
1.4 MiB + 308.5 KiB = 1.7 MiB fail2ban-server
888.0 KiB + 1.0 MiB = 1.9 MiB sshd (3)
1.9 MiB + 32.5 KiB = 1.9 MiB munin-node
13.1 MiB + 86.0 KiB = 13.2 MiB mysqld
147.4 MiB + 36.5 MiB = 183.9 MiB apache2 (7)
---------------------------------
208.1 MiB
=================================
Private + Shared = RAM used Program
The only part I don't like is the fact that the script claims to require root privileges. I haven't had an opportunity yet to see exactly why this is the case.
edited Oct 1 '15 at 23:47
community wiki
3 revs
Jason Mock
I wonder whether memory is shared between threads. It is shared between processes, isn't it? At least on Windows...
– Thomas Weller
Dec 27 '14 at 12:51
So this case, the shared memory refers to pages that are mapped by multiple processes in the form of shared libraries. Additionally within the context of a multi-threaded applications the entire process memory space is accessible by all threads in that process.
– Jason Mock
Oct 1 '15 at 23:37
4
Now available in PyPI (pip install ps_mem
) and on GitHub.
– Leif Arne Storset
Jan 9 '17 at 14:39
@ThomasWeller: Yes, threads always share memory, whereas processes may share some or all of it under certain conditions.
– Leif Arne Storset
Jan 9 '17 at 14:44
for this I use gnome-system-monitor
– jms
Dec 26 '17 at 7:39
|
show 2 more comments
I wonder whether memory is shared between threads. It is shared between processes, isn't it? At least on Windows...
– Thomas Weller
Dec 27 '14 at 12:51
So this case, the shared memory refers to pages that are mapped by multiple processes in the form of shared libraries. Additionally within the context of a multi-threaded applications the entire process memory space is accessible by all threads in that process.
– Jason Mock
Oct 1 '15 at 23:37
4
Now available in PyPI (pip install ps_mem
) and on GitHub.
– Leif Arne Storset
Jan 9 '17 at 14:39
@ThomasWeller: Yes, threads always share memory, whereas processes may share some or all of it under certain conditions.
– Leif Arne Storset
Jan 9 '17 at 14:44
for this I use gnome-system-monitor
– jms
Dec 26 '17 at 7:39
I wonder whether memory is shared between threads. It is shared between processes, isn't it? At least on Windows...
– Thomas Weller
Dec 27 '14 at 12:51
I wonder whether memory is shared between threads. It is shared between processes, isn't it? At least on Windows...
– Thomas Weller
Dec 27 '14 at 12:51
So this case, the shared memory refers to pages that are mapped by multiple processes in the form of shared libraries. Additionally within the context of a multi-threaded applications the entire process memory space is accessible by all threads in that process.
– Jason Mock
Oct 1 '15 at 23:37
So this case, the shared memory refers to pages that are mapped by multiple processes in the form of shared libraries. Additionally within the context of a multi-threaded applications the entire process memory space is accessible by all threads in that process.
– Jason Mock
Oct 1 '15 at 23:37
4
4
Now available in PyPI (
pip install ps_mem
) and on GitHub.– Leif Arne Storset
Jan 9 '17 at 14:39
Now available in PyPI (
pip install ps_mem
) and on GitHub.– Leif Arne Storset
Jan 9 '17 at 14:39
@ThomasWeller: Yes, threads always share memory, whereas processes may share some or all of it under certain conditions.
– Leif Arne Storset
Jan 9 '17 at 14:44
@ThomasWeller: Yes, threads always share memory, whereas processes may share some or all of it under certain conditions.
– Leif Arne Storset
Jan 9 '17 at 14:44
for this I use gnome-system-monitor
– jms
Dec 26 '17 at 7:39
for this I use gnome-system-monitor
– jms
Dec 26 '17 at 7:39
|
show 2 more comments
up vote
24
down vote
Use the free command.
For example, this is the ouput of free -m
:
total used free shared buffers cached
Mem: 2012 1666 345 0 101 616
-/+ buffers/cache: 947 1064
Swap: 7624 0 7624
free -m | grep /+
will return only the second line:
-/+ buffers/cache: 947 1064
Thanks, looks great. So this947
is memory usage minus the memory used for buffers and caches?
– Jonas
Oct 26 '10 at 17:54
add a comment |
up vote
24
down vote
Use the free command.
For example, this is the ouput of free -m
:
total used free shared buffers cached
Mem: 2012 1666 345 0 101 616
-/+ buffers/cache: 947 1064
Swap: 7624 0 7624
free -m | grep /+
will return only the second line:
-/+ buffers/cache: 947 1064
Thanks, looks great. So this947
is memory usage minus the memory used for buffers and caches?
– Jonas
Oct 26 '10 at 17:54
add a comment |
up vote
24
down vote
up vote
24
down vote
Use the free command.
For example, this is the ouput of free -m
:
total used free shared buffers cached
Mem: 2012 1666 345 0 101 616
-/+ buffers/cache: 947 1064
Swap: 7624 0 7624
free -m | grep /+
will return only the second line:
-/+ buffers/cache: 947 1064
Use the free command.
For example, this is the ouput of free -m
:
total used free shared buffers cached
Mem: 2012 1666 345 0 101 616
-/+ buffers/cache: 947 1064
Swap: 7624 0 7624
free -m | grep /+
will return only the second line:
-/+ buffers/cache: 947 1064
edited Oct 26 '10 at 17:52
answered Oct 26 '10 at 17:19
Isaiah
42.5k20118138
42.5k20118138
Thanks, looks great. So this947
is memory usage minus the memory used for buffers and caches?
– Jonas
Oct 26 '10 at 17:54
add a comment |
Thanks, looks great. So this947
is memory usage minus the memory used for buffers and caches?
– Jonas
Oct 26 '10 at 17:54
Thanks, looks great. So this
947
is memory usage minus the memory used for buffers and caches?– Jonas
Oct 26 '10 at 17:54
Thanks, looks great. So this
947
is memory usage minus the memory used for buffers and caches?– Jonas
Oct 26 '10 at 17:54
add a comment |
up vote
10
down vote
The watch command may be useful. Try watch -n 5 free
to monitor memory usage with updates every five seconds.
Thanks, this was great! However, I would prefer to get the memory usage on a single line, so it's easy to log to a text file.
– Jonas
Oct 26 '10 at 17:44
add a comment |
up vote
10
down vote
The watch command may be useful. Try watch -n 5 free
to monitor memory usage with updates every five seconds.
Thanks, this was great! However, I would prefer to get the memory usage on a single line, so it's easy to log to a text file.
– Jonas
Oct 26 '10 at 17:44
add a comment |
up vote
10
down vote
up vote
10
down vote
The watch command may be useful. Try watch -n 5 free
to monitor memory usage with updates every five seconds.
The watch command may be useful. Try watch -n 5 free
to monitor memory usage with updates every five seconds.
answered Oct 26 '10 at 17:27
mgunes
8,20223541
8,20223541
Thanks, this was great! However, I would prefer to get the memory usage on a single line, so it's easy to log to a text file.
– Jonas
Oct 26 '10 at 17:44
add a comment |
Thanks, this was great! However, I would prefer to get the memory usage on a single line, so it's easy to log to a text file.
– Jonas
Oct 26 '10 at 17:44
Thanks, this was great! However, I would prefer to get the memory usage on a single line, so it's easy to log to a text file.
– Jonas
Oct 26 '10 at 17:44
Thanks, this was great! However, I would prefer to get the memory usage on a single line, so it's easy to log to a text file.
– Jonas
Oct 26 '10 at 17:44
add a comment |
up vote
5
down vote
You can do it using cat /proc/meminfo
.
MemTotal: 4039160 kB
MemFree: 309796 kB
MemAvailable: 3001052 kB
Buffers: 345636 kB
Cached: 2341288 kB
SwapCached: 8 kB
Active: 1725160 kB
Inactive: 1551652 kB
Active(anon): 538404 kB
Inactive(anon): 70076 kB
Active(file): 1186756 kB
Inactive(file): 1481576 kB
Unevictable: 32 kB
Mlocked: 32 kB
SwapTotal: 4194300 kB
SwapFree: 4194044 kB
Dirty: 0 kB
Writeback: 0 kB
AnonPages: 589988 kB
Mapped: 255972 kB
Shmem: 18596 kB
Slab: 374888 kB
SReclaimable: 310496 kB
SUnreclaim: 64392 kB
KernelStack: 6976 kB
PageTables: 26452 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 6213880 kB
Committed_AS: 3589736 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
HardwareCorrupted: 0 kB
AnonHugePages: 0 kB
ShmemHugePages: 0 kB
ShmemPmdMapped: 0 kB
CmaTotal: 0 kB
CmaFree: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 147392 kB
DirectMap2M: 4046848 kB
1
adding watch to the front of this command makes it awesome! as inwatch cat /proc/meminfo
– Elder Geek
Nov 9 '16 at 3:58
Thefree
command takes its information from/proc/meminfo
and presents them in a compact way. Usefree -h
for human-readable output.
– LoMaPh
Feb 17 at 8:51
add a comment |
up vote
5
down vote
You can do it using cat /proc/meminfo
.
MemTotal: 4039160 kB
MemFree: 309796 kB
MemAvailable: 3001052 kB
Buffers: 345636 kB
Cached: 2341288 kB
SwapCached: 8 kB
Active: 1725160 kB
Inactive: 1551652 kB
Active(anon): 538404 kB
Inactive(anon): 70076 kB
Active(file): 1186756 kB
Inactive(file): 1481576 kB
Unevictable: 32 kB
Mlocked: 32 kB
SwapTotal: 4194300 kB
SwapFree: 4194044 kB
Dirty: 0 kB
Writeback: 0 kB
AnonPages: 589988 kB
Mapped: 255972 kB
Shmem: 18596 kB
Slab: 374888 kB
SReclaimable: 310496 kB
SUnreclaim: 64392 kB
KernelStack: 6976 kB
PageTables: 26452 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 6213880 kB
Committed_AS: 3589736 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
HardwareCorrupted: 0 kB
AnonHugePages: 0 kB
ShmemHugePages: 0 kB
ShmemPmdMapped: 0 kB
CmaTotal: 0 kB
CmaFree: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 147392 kB
DirectMap2M: 4046848 kB
1
adding watch to the front of this command makes it awesome! as inwatch cat /proc/meminfo
– Elder Geek
Nov 9 '16 at 3:58
Thefree
command takes its information from/proc/meminfo
and presents them in a compact way. Usefree -h
for human-readable output.
– LoMaPh
Feb 17 at 8:51
add a comment |
up vote
5
down vote
up vote
5
down vote
You can do it using cat /proc/meminfo
.
MemTotal: 4039160 kB
MemFree: 309796 kB
MemAvailable: 3001052 kB
Buffers: 345636 kB
Cached: 2341288 kB
SwapCached: 8 kB
Active: 1725160 kB
Inactive: 1551652 kB
Active(anon): 538404 kB
Inactive(anon): 70076 kB
Active(file): 1186756 kB
Inactive(file): 1481576 kB
Unevictable: 32 kB
Mlocked: 32 kB
SwapTotal: 4194300 kB
SwapFree: 4194044 kB
Dirty: 0 kB
Writeback: 0 kB
AnonPages: 589988 kB
Mapped: 255972 kB
Shmem: 18596 kB
Slab: 374888 kB
SReclaimable: 310496 kB
SUnreclaim: 64392 kB
KernelStack: 6976 kB
PageTables: 26452 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 6213880 kB
Committed_AS: 3589736 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
HardwareCorrupted: 0 kB
AnonHugePages: 0 kB
ShmemHugePages: 0 kB
ShmemPmdMapped: 0 kB
CmaTotal: 0 kB
CmaFree: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 147392 kB
DirectMap2M: 4046848 kB
You can do it using cat /proc/meminfo
.
MemTotal: 4039160 kB
MemFree: 309796 kB
MemAvailable: 3001052 kB
Buffers: 345636 kB
Cached: 2341288 kB
SwapCached: 8 kB
Active: 1725160 kB
Inactive: 1551652 kB
Active(anon): 538404 kB
Inactive(anon): 70076 kB
Active(file): 1186756 kB
Inactive(file): 1481576 kB
Unevictable: 32 kB
Mlocked: 32 kB
SwapTotal: 4194300 kB
SwapFree: 4194044 kB
Dirty: 0 kB
Writeback: 0 kB
AnonPages: 589988 kB
Mapped: 255972 kB
Shmem: 18596 kB
Slab: 374888 kB
SReclaimable: 310496 kB
SUnreclaim: 64392 kB
KernelStack: 6976 kB
PageTables: 26452 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 6213880 kB
Committed_AS: 3589736 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
HardwareCorrupted: 0 kB
AnonHugePages: 0 kB
ShmemHugePages: 0 kB
ShmemPmdMapped: 0 kB
CmaTotal: 0 kB
CmaFree: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 147392 kB
DirectMap2M: 4046848 kB
edited Nov 20 at 6:58
muru
134k19282482
134k19282482
answered Apr 16 '16 at 19:15
Amir
2421313
2421313
1
adding watch to the front of this command makes it awesome! as inwatch cat /proc/meminfo
– Elder Geek
Nov 9 '16 at 3:58
Thefree
command takes its information from/proc/meminfo
and presents them in a compact way. Usefree -h
for human-readable output.
– LoMaPh
Feb 17 at 8:51
add a comment |
1
adding watch to the front of this command makes it awesome! as inwatch cat /proc/meminfo
– Elder Geek
Nov 9 '16 at 3:58
Thefree
command takes its information from/proc/meminfo
and presents them in a compact way. Usefree -h
for human-readable output.
– LoMaPh
Feb 17 at 8:51
1
1
adding watch to the front of this command makes it awesome! as in
watch cat /proc/meminfo
– Elder Geek
Nov 9 '16 at 3:58
adding watch to the front of this command makes it awesome! as in
watch cat /proc/meminfo
– Elder Geek
Nov 9 '16 at 3:58
The
free
command takes its information from /proc/meminfo
and presents them in a compact way. Use free -h
for human-readable output.– LoMaPh
Feb 17 at 8:51
The
free
command takes its information from /proc/meminfo
and presents them in a compact way. Use free -h
for human-readable output.– LoMaPh
Feb 17 at 8:51
add a comment |
up vote
4
down vote
For visual monitoring of overall RAM usage, if you use Byobu, it will keep your memory usage in the lower right-hand corner of the terminal and will run while you are in any terminal session.
As you can see from screenshot, my virtual machine has a 1h3m uptime, 0.00 load, has 2.8GHz (virtual) processor and 994MB (21%) of the RAM available on the system.
add a comment |
up vote
4
down vote
For visual monitoring of overall RAM usage, if you use Byobu, it will keep your memory usage in the lower right-hand corner of the terminal and will run while you are in any terminal session.
As you can see from screenshot, my virtual machine has a 1h3m uptime, 0.00 load, has 2.8GHz (virtual) processor and 994MB (21%) of the RAM available on the system.
add a comment |
up vote
4
down vote
up vote
4
down vote
For visual monitoring of overall RAM usage, if you use Byobu, it will keep your memory usage in the lower right-hand corner of the terminal and will run while you are in any terminal session.
As you can see from screenshot, my virtual machine has a 1h3m uptime, 0.00 load, has 2.8GHz (virtual) processor and 994MB (21%) of the RAM available on the system.
For visual monitoring of overall RAM usage, if you use Byobu, it will keep your memory usage in the lower right-hand corner of the terminal and will run while you are in any terminal session.
As you can see from screenshot, my virtual machine has a 1h3m uptime, 0.00 load, has 2.8GHz (virtual) processor and 994MB (21%) of the RAM available on the system.
answered Jan 19 '15 at 20:09
bafromca
3361515
3361515
add a comment |
add a comment |
up vote
3
down vote
Single line solution and output:
free -m | grep "Mem:"
Here is an example of the expected output:
Mem: 3944 652 302 18 2990 2930
This will also let you see the memory-usage at the moment...
– mook765
Sep 27 '16 at 14:38
add a comment |
up vote
3
down vote
Single line solution and output:
free -m | grep "Mem:"
Here is an example of the expected output:
Mem: 3944 652 302 18 2990 2930
This will also let you see the memory-usage at the moment...
– mook765
Sep 27 '16 at 14:38
add a comment |
up vote
3
down vote
up vote
3
down vote
Single line solution and output:
free -m | grep "Mem:"
Here is an example of the expected output:
Mem: 3944 652 302 18 2990 2930
Single line solution and output:
free -m | grep "Mem:"
Here is an example of the expected output:
Mem: 3944 652 302 18 2990 2930
edited Nov 20 at 6:59
muru
134k19282482
134k19282482
answered Sep 27 '16 at 13:30
Tim
311
311
This will also let you see the memory-usage at the moment...
– mook765
Sep 27 '16 at 14:38
add a comment |
This will also let you see the memory-usage at the moment...
– mook765
Sep 27 '16 at 14:38
This will also let you see the memory-usage at the moment...
– mook765
Sep 27 '16 at 14:38
This will also let you see the memory-usage at the moment...
– mook765
Sep 27 '16 at 14:38
add a comment |
up vote
1
down vote
I would use Cacti. This will graph your memory usage etc over a period of time, and you will be able to check on usage using your web browser.
add a comment |
up vote
1
down vote
I would use Cacti. This will graph your memory usage etc over a period of time, and you will be able to check on usage using your web browser.
add a comment |
up vote
1
down vote
up vote
1
down vote
I would use Cacti. This will graph your memory usage etc over a period of time, and you will be able to check on usage using your web browser.
I would use Cacti. This will graph your memory usage etc over a period of time, and you will be able to check on usage using your web browser.
edited Jul 20 '16 at 22:05
Richard
64421125
64421125
answered Oct 26 '10 at 18:01
Matt
3831414
3831414
add a comment |
add a comment |
up vote
1
down vote
Monitoring Memory Usage
I'm more in line with one of the preceding posts that mentioned Cacti as a great way to monitor memory usage. However, since it appears cacti is no longer popular in the mainstream, there is an alternative graphing application called Graphite.
Graphite is relatively easy to install on a ubuntu server and to install it, you can check out this link for the easy to follow installation procedures.
After graphite has been installed, now, you can send memory metrics to it, at whichever interval you wish; every 5 seconds, every minute, every hour...etc.
To graph memory metrics, as already suggested in previous posts, you can write your own script using system tools to gather the necessary memory information. Or, you can use a prewritten snmp plugin that'll do all the work for you.
If you wish to write your own memory script, it'll be wise to ensure you account for buffered and cached memory when calculating used memory, otherwise, you'll end up gathering false data.
If you wish to instead utilize an snmp plugin that already does all the necessary calculations for you, here's a link to one that works pretty well: checkMemoryviaSNMP.
Pros of SNMP:
I have snmp installed on all the remote nodes I monitor. This allows me to monitor all my systems from one central server(s), without having to copy or put a plugin on the remote nodes.
Cons of SNMP:
You'd have to ensure the snmp agent is installed on each of the remote nodes you wish to monitor memory on. However, this installation will be a one time deal. If you're using automation tools such as chef or puppet or similar tools in your environment, then this isn't a problem at all.
Configuration of the SNMP agent on the remote node(s):
After the snmp agent has been installed, simply vi the /etc/snmpd/snmpd.conf file and add this line to it:
rocommunity (specify-a-community-string-aka-password-here)
Then restart the snmpd agent, with:
/etc/init.d/snmpd restart
Then, on your central server, from which you instead to monitor all your other servers, you can run the following command:
$ time ./checkMemoryviaSNMP -v2 public gearman001.phs.blah.com 30 90 graphite,10.10.10.10,2003,typical
WARNING: Used = [ 3.26154 GB ], Installed = [ 5.71509 GB ], PCT.Used = [ 57.069% ], Available.Memory = [ 2.00291 GB ]. Buffer = [ 137.594 MB ], Cached = [ 1.3849 GB ]. Thresholds: [ W=(30%) / C=(90%) ]. System Information = [ Linux gearman001.phs.blah.com 2.6.32-504.30.3.el6.x86_64 #1 SMP Thu Jul 9 15:20:47 EDT 2015 x86_64 ].
real 0m0.23s
user 0m0.03s
sys 0m0.02s
add a comment |
up vote
1
down vote
Monitoring Memory Usage
I'm more in line with one of the preceding posts that mentioned Cacti as a great way to monitor memory usage. However, since it appears cacti is no longer popular in the mainstream, there is an alternative graphing application called Graphite.
Graphite is relatively easy to install on a ubuntu server and to install it, you can check out this link for the easy to follow installation procedures.
After graphite has been installed, now, you can send memory metrics to it, at whichever interval you wish; every 5 seconds, every minute, every hour...etc.
To graph memory metrics, as already suggested in previous posts, you can write your own script using system tools to gather the necessary memory information. Or, you can use a prewritten snmp plugin that'll do all the work for you.
If you wish to write your own memory script, it'll be wise to ensure you account for buffered and cached memory when calculating used memory, otherwise, you'll end up gathering false data.
If you wish to instead utilize an snmp plugin that already does all the necessary calculations for you, here's a link to one that works pretty well: checkMemoryviaSNMP.
Pros of SNMP:
I have snmp installed on all the remote nodes I monitor. This allows me to monitor all my systems from one central server(s), without having to copy or put a plugin on the remote nodes.
Cons of SNMP:
You'd have to ensure the snmp agent is installed on each of the remote nodes you wish to monitor memory on. However, this installation will be a one time deal. If you're using automation tools such as chef or puppet or similar tools in your environment, then this isn't a problem at all.
Configuration of the SNMP agent on the remote node(s):
After the snmp agent has been installed, simply vi the /etc/snmpd/snmpd.conf file and add this line to it:
rocommunity (specify-a-community-string-aka-password-here)
Then restart the snmpd agent, with:
/etc/init.d/snmpd restart
Then, on your central server, from which you instead to monitor all your other servers, you can run the following command:
$ time ./checkMemoryviaSNMP -v2 public gearman001.phs.blah.com 30 90 graphite,10.10.10.10,2003,typical
WARNING: Used = [ 3.26154 GB ], Installed = [ 5.71509 GB ], PCT.Used = [ 57.069% ], Available.Memory = [ 2.00291 GB ]. Buffer = [ 137.594 MB ], Cached = [ 1.3849 GB ]. Thresholds: [ W=(30%) / C=(90%) ]. System Information = [ Linux gearman001.phs.blah.com 2.6.32-504.30.3.el6.x86_64 #1 SMP Thu Jul 9 15:20:47 EDT 2015 x86_64 ].
real 0m0.23s
user 0m0.03s
sys 0m0.02s
add a comment |
up vote
1
down vote
up vote
1
down vote
Monitoring Memory Usage
I'm more in line with one of the preceding posts that mentioned Cacti as a great way to monitor memory usage. However, since it appears cacti is no longer popular in the mainstream, there is an alternative graphing application called Graphite.
Graphite is relatively easy to install on a ubuntu server and to install it, you can check out this link for the easy to follow installation procedures.
After graphite has been installed, now, you can send memory metrics to it, at whichever interval you wish; every 5 seconds, every minute, every hour...etc.
To graph memory metrics, as already suggested in previous posts, you can write your own script using system tools to gather the necessary memory information. Or, you can use a prewritten snmp plugin that'll do all the work for you.
If you wish to write your own memory script, it'll be wise to ensure you account for buffered and cached memory when calculating used memory, otherwise, you'll end up gathering false data.
If you wish to instead utilize an snmp plugin that already does all the necessary calculations for you, here's a link to one that works pretty well: checkMemoryviaSNMP.
Pros of SNMP:
I have snmp installed on all the remote nodes I monitor. This allows me to monitor all my systems from one central server(s), without having to copy or put a plugin on the remote nodes.
Cons of SNMP:
You'd have to ensure the snmp agent is installed on each of the remote nodes you wish to monitor memory on. However, this installation will be a one time deal. If you're using automation tools such as chef or puppet or similar tools in your environment, then this isn't a problem at all.
Configuration of the SNMP agent on the remote node(s):
After the snmp agent has been installed, simply vi the /etc/snmpd/snmpd.conf file and add this line to it:
rocommunity (specify-a-community-string-aka-password-here)
Then restart the snmpd agent, with:
/etc/init.d/snmpd restart
Then, on your central server, from which you instead to monitor all your other servers, you can run the following command:
$ time ./checkMemoryviaSNMP -v2 public gearman001.phs.blah.com 30 90 graphite,10.10.10.10,2003,typical
WARNING: Used = [ 3.26154 GB ], Installed = [ 5.71509 GB ], PCT.Used = [ 57.069% ], Available.Memory = [ 2.00291 GB ]. Buffer = [ 137.594 MB ], Cached = [ 1.3849 GB ]. Thresholds: [ W=(30%) / C=(90%) ]. System Information = [ Linux gearman001.phs.blah.com 2.6.32-504.30.3.el6.x86_64 #1 SMP Thu Jul 9 15:20:47 EDT 2015 x86_64 ].
real 0m0.23s
user 0m0.03s
sys 0m0.02s
Monitoring Memory Usage
I'm more in line with one of the preceding posts that mentioned Cacti as a great way to monitor memory usage. However, since it appears cacti is no longer popular in the mainstream, there is an alternative graphing application called Graphite.
Graphite is relatively easy to install on a ubuntu server and to install it, you can check out this link for the easy to follow installation procedures.
After graphite has been installed, now, you can send memory metrics to it, at whichever interval you wish; every 5 seconds, every minute, every hour...etc.
To graph memory metrics, as already suggested in previous posts, you can write your own script using system tools to gather the necessary memory information. Or, you can use a prewritten snmp plugin that'll do all the work for you.
If you wish to write your own memory script, it'll be wise to ensure you account for buffered and cached memory when calculating used memory, otherwise, you'll end up gathering false data.
If you wish to instead utilize an snmp plugin that already does all the necessary calculations for you, here's a link to one that works pretty well: checkMemoryviaSNMP.
Pros of SNMP:
I have snmp installed on all the remote nodes I monitor. This allows me to monitor all my systems from one central server(s), without having to copy or put a plugin on the remote nodes.
Cons of SNMP:
You'd have to ensure the snmp agent is installed on each of the remote nodes you wish to monitor memory on. However, this installation will be a one time deal. If you're using automation tools such as chef or puppet or similar tools in your environment, then this isn't a problem at all.
Configuration of the SNMP agent on the remote node(s):
After the snmp agent has been installed, simply vi the /etc/snmpd/snmpd.conf file and add this line to it:
rocommunity (specify-a-community-string-aka-password-here)
Then restart the snmpd agent, with:
/etc/init.d/snmpd restart
Then, on your central server, from which you instead to monitor all your other servers, you can run the following command:
$ time ./checkMemoryviaSNMP -v2 public gearman001.phs.blah.com 30 90 graphite,10.10.10.10,2003,typical
WARNING: Used = [ 3.26154 GB ], Installed = [ 5.71509 GB ], PCT.Used = [ 57.069% ], Available.Memory = [ 2.00291 GB ]. Buffer = [ 137.594 MB ], Cached = [ 1.3849 GB ]. Thresholds: [ W=(30%) / C=(90%) ]. System Information = [ Linux gearman001.phs.blah.com 2.6.32-504.30.3.el6.x86_64 #1 SMP Thu Jul 9 15:20:47 EDT 2015 x86_64 ].
real 0m0.23s
user 0m0.03s
sys 0m0.02s
answered Oct 22 '16 at 15:32
SimplisticSpeed
111
111
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f9642%2fhow-can-i-monitor-the-memory-usage%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown