i've simple question . how i can customize the display of free or vmstat or top commands to display memory usage only because i want the result to draw it via MRTG .
i've simple question . how i can customize the display of free or vmstat or top commands to display memory usage only because i want the result to draw it via MRTG .
/proc/meminfo
contains all the various memory statistics, and you can grab the values from there and manipulate to your heart's content.You could pass the contents of
/proc/meminfo
through grep to get the lines you want. For instance:(the ^ in the command looking for "cached" tells
grep
to only match at the start of a line, so it won't find the line for the SwapCached value too)Or if you want more than one line at once, use the extended matching option so the "or" operator can be used:
You can use
tr
to return just the numeric values for a single item:There are a small pile of other standard text manipulation programs (
cut
,paste
,sed
,awk
,xargs
...) that you can pipe the results through to get the output into different formats. If you give the format you require in your question, if you are not looking for just a single numeric value in which case the above will do what you want, we can tell you which filters to pass the info through to get the desired result. I don't use MRTG myself so I can only guess the input format it requires.This isn't strictly speaking an answer to your question, but if you have a /proc filesystem, you might be able to grep out the information you're interested in from /proc/meminfo.