Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm using Cacti in Centos 6.3 and I would like to get the list of the top 10 memory consuming processes, with a memory graph, so that if server fails I can easily find the processes behind that.

It is possible with a plugin or template?

share|improve this question
add comment

2 Answers 2

First, This data is hard to represent in an RRD database. Because your 10 PID's/processes will change but RRD data sources are static. You could just log 1-10 but then you can't get any more information. You could get around this by mapping a name/pid to a datasource, but then you need to come up with all the required names in advance, which is not easy. Alternatively you could create 65536 data sources for each pid, but then graphing is a bit tricky.

Might be time to try something a bit more extensible like OpenTSDB

Second, monitoring actual memory usage in Linux is not easy. ps lies. Linux makes use of shared memory and doesn't provide a simple interface to query that information on a per process level. There are also kernel memory and caches that can impact memory performance on a machine.

There are 3 things you can track to help highlight memory issues.

  • Per executable shared and private memory
  • Per process private memory
  • Kernel Memory

Per executable shared and private memory

This ps_mem.py script, which is the best "off the shelf" estimate I've found.

Note "these values are per program, not per process", which is a by product of the way shared memory works and the accounting done in the kernel.

Private memory, per process

You can get the private memory per process from /proc/[0-9]*/smaps by tallying all the values of Private_Dirty and Private_Clean per file. Process names you can get from /proc/[0-9]*/status or /proc/[0-9]*/stat

Meminfo

Overall memory usage values from /proc/meminfo

MemTotal
MemFree
Buffers
Cached
SwapTotal
SwapFree
AnonPages
Mapped
Dirty
Writeback
Shmem
Slab
KernelStack
PageTables
NFS_Unstable
Bounce
WritebackTmp

There is a bunch of information you can extrapolate from the values in /proc/meminfo which are probably better things to graph than all those data points individually.

From those three you should be able to have a good idea of where most memory issues have originated from.

After all this I've still found there is still a 'hole' in what linux accounts as allocated memory. This hole appears to be the virtual->physical memory map as the hole get's bigger the more memory a machine has.

share|improve this answer
add comment

There is a template that allows you to use snmp to monitor using proc cacti is able to pipe it out as a graph..

http://forums.cacti.net/about19640.html

share|improve this answer
    
Thanks a lot ............. –  K.K Patel Dec 18 '12 at 9:44
    
This template is not working well. –  K.K Patel Dec 21 '12 at 6:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.