Memory Usage Email

I’ve recently got a VPS and it’s performing excellently so far. However, I’d like to keep an eye of it’s memory usage as that seems to be the limiting factor.

I’m able to check by logging into the VPS control panel but this is a bit tiresome to do this daily/whenever as it needs a password etc.

Is there any way I can have a script that will notify me of when/if the memory usage of the server goes over say, 300MB?

I currently have a lighttpd server running 2 Wordpress blogs, a gnuplot script that runs every 6 hours on a Debian 5 64bit running at 250MB of RAM. My limit is 368MB so I’d like to be told when it hits 300MB (it hit 300MB earlier, a restart of the lighttpd server dropped it down to just under 200MB before it climbed to it’s current level).

From looks if I cant get informed, then a script to restart lighttpd every 3 days or so might be able to drop the memory usage on restart?

What flavour of Linux/Nix/Doze?

if Nix, you could use something like

if prstat | grep lighttpd | awk '{print $4}' > 300; lighttpd graceful; fi

adjusted for horrendous syntax obviously :wink:

It’s Debian. I believe I mentioned it above :wink:

using top and then M, it appears the biggest usage is php5-cgi (i assume I just then change grep lighttpd to grep php5-cgi)

My thought was use a mix of awk and free -M.

:doh: my bad

sounds like you’re on the right track with those - not got a linux box I can play with to get the syntax right, but the idea is the same :slight_smile:

if you have enough access, install munin :slight_smile:


I’d give that a try but just tried to access my VPS and got a message saying it’s suspended and have to contact support :frowning:

I obviously installed something I shouldn’t have :nono::dunce: