Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi,
recently I had a crash on one of my servers (Compaq ProLiant), which are running on Red Hat 8.0. According to the messages file, the reason was a low memory issue, but I couldn't find out which process it was, which needed so much memory.
Thus it raised the question, how I could monitor the memory and also the virtual memory. My idea is, that if the memory on the server exceeds a certain value, a script or something similar should capture the 5 processes (with name and pid) which are using the most memory and its memory usage.
Does anybody know whether there is already a solution out there? Or which solution for the problem would you suggest?
This wouldn't work, because 'top' monitors processes by the top cpu usage. But I need the processes monitored by the top most memory usage.
Any other suggestions?
you can use 'free', which will show memory information, both RAM and swap.
You could make some kind of script, which could take actions when free memory is below some value.
But isn't something alike this already build into the kernel?
Atleast on my desktop system, I used to have a program that on a specific action suddenly used HUGE amounts of memory. My computer than became very slow for a few seconds, and after that this program was killed, and memory-usage back to normal.
When looking at dmesg, the program was killed by the kernel, because of low memory.
Sounds like what you need. This was on a 2.6 kernel, by the way...
According to the messages entry, there were some processes killed, thats true.
But first I don't know which processes were killed - only the pid were given and I should also know which program.
Second I doupt that the kernel know which process is the correct one to kill. I rather think that the kernel chooses an arbitrary process to kill.
Third the server did crash anyway. This indicates that the kernel choosed the wrong process to kill.
With the command 'free' I only know the entire memory usage, but not which process is using which amount of memory.
I think this problem should have been solved already. The question is just how and where to get a solution..
Originally posted by Fredy71 According to the messages entry, there were some processes killed, thats true.
But first I don't know which processes were killed - only the pid were given and I should also know which program.
On my system I did have both the pid and the process-name in dmesg, but you might be running a 2.4 kernel instead of 2.6, which could explain this..
Quote:
Second I doupt that the kernel know which process is the correct one to kill. I rather think that the kernel chooses an arbitrary process to kill.
I did some googling around, since i got intrested by this.. It appears to be a more complex subject than can be figured out in a short brake at work
But anyways, there seems to be a lot of work in this.. I am quite sure that the kernel does a better job at this than any script you write (no offense.. )
btw. In the case i wrote about in my last post, the kernel did pick the right process..
Quote:
Third the server did crash anyway. This indicates that the kernel choosed the wrong process to kill.
What kernel version are you running exactly? from what i've read from my little bit of googling,early 2.4 kernels did indeed pick the wrong process sometimes..
Quote:
With the command 'free' I only know the entire memory usage, but not which process is using which amount of memory.
I think this problem should have been solved already. The question is just how and where to get a solution.
Really, do some googling. Lots of work have been done on it, and i found out it is a lot more complex than i thought at first..
It might suprise you, too
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.