Per process memory accounting is tricky for a number of reasons I'll get into in a minute. For simple monitoring, gkrellmd, or nagios scripts is probably enough. If you want greater accuracy, you'll need to look harder.
smem introduces the concept of Proportional Set Size:
Because large portions of physical memory are typically shared among multiple applications, the standard measure of memory usage known as resident set size (RSS) will significantly overestimate memory usage. PSS instead measures each application's "fair share" of each shared area to give a realistic measure.
Example: You start up GNOME, causing a number of processes to start, one for each applet and program. They all link to libglib. Linux loads libglib into one block of memory and maps it into every process that wants libglib. Naive memory accounting counts the full libglib size against every process linking to it.
smem divides up the cost of libglib among the processes using it, to give a closer picture of reality. It also has a number of options to display memory usage (from website):
- Show basic process information smem
- Show system view smem -R 4G -K /path/to/vmlinux -w
- Show totals and percentages smem -t -p
- Show different columns smem -c "name user pss"
- Show processes filtered by mapping smem -M libxml
- Show mappings filtered by process smem -m -P [e]volution
- Read data from capture tarball smem --source capture.tar.gz
- Show a bar chart labeled by pid smem --bar pid -c "pss uss"
- Show a pie chart of RSS labeled by name smem --pie name -s rss
You will, however, need a very recent kernel (> 2.6.27).
Were you getting out of memory errors with a particular application? Or do you have a performance issue? What specifically leads you to believe that your are out of memory (aside from the 'free -m' command).
The first thing to look for is a LOT of processes using a small amount of memory. If you have 100 processes only using 128mb of memory you will be short of memory for example.
It's very normal to see almost 100% of your memory used in Linux. However I don't know enough about how this works within your particular VPS provider to know if your usage is considered normal. With my own VPS provider I have 24mb / 512m free and it's purring along nicely. If required it will dump out the almost 400mb of cached data it has.
Best Answer
There is an OOB key for both passive and active agent that does this, just create the item in your applicable hosts!
Once you create the item, you have to manually create the graph.
If you have many Linux hosts to apply this to, you may add the item and graph to a template and assign it to ask relevant hosts.
I am referencing Zabbix 2.4.4