memCron 0.6

by Yaosan on March 22, 2010

First of all, I want to say thanks to Ben for his relentless support helping other users with their issues and constantly providing updates to the memCron code base due to some of the recent DreamHost PS changes. After spending the weekend polishing up the improvements contributed by Ben and Bret, memCron 0.6 is finally here.

Here’s a list of notable changes:

  • Removed dependency on modules with built-ins and system utilities, including SendMail, LWP etc.
  • Get memory info from /proc/meminfo
  • Get current memory size from API rather than OS
  • New option to disable updates
  • New options to send out notification when changing memory setting or getting API errors
  • New chart formatting options: target memory, cached memory
  • Now display http server name instead of actual PS name on the graph page for extra security

Download: memCron 0.6 (34.12 KB)

Please give this new version a try if you’re having issues with the older versions.

To upgrade, follow step 1-3 listed here. FYI, the old “zscore.pl” is no longer used and can be safely removed.

{ 2 trackbacks }

Version 0.6.1 Released by Ben « bensCron
March 22, 2010 at 2:25 pm
0.6.1 No Longer Working? « bensCron
June 28, 2010 at 8:19 pm

{ 130 comments… read them below or add one }

Eric October 1, 2011 at 3:22 am

Hello guys, really nice script, just what I needed.
I will give a try on this one before try the VPS Manager from 7is7.
Well, for now it’s working, it does change memory, etc.
The only thing I have to understand is the Tolerance (Free).
I can’t get that to understand that. Could any one explain? Thanks….

Other thing is, every time my website uses more memory, VPS just goes downtime and even if I change to more memory, let’s say, 4000MB, it won’t go back up unless I reboot! And so the script won’t work because of that.
I would like to know if I can install the script on another site, like my other shared website, and it would be always on and in case would reboot the server if it would be off, like I said.
Thanks.

Reply

Bret Miller October 7, 2011 at 2:24 pm

@Eric: I really can’t explain tolerance. I recently moved back to active management after a long time of just using memcron to monitor the memory. I made a number of changes to it to make that possible. Now it runs every minute, but once a change is requested, it won’t request another for at least 5 minutes. Even at that, it’s not as reactive as I’d like it to be. If anyone is really interested, I can post my latest version again.

There are some issues you should know about. DreamHost runs a process monitor and a VPS freezer. Essentially, if your VPS exceeds the allotted ram, the process monitor will kill the active process(es) to get the memory usage back down. They recently introduced the freezer so that if you repeatedly exceed the allotted ram, your VPS gets frozen for an unstated period of time, seemingly around 30 minutes if my experience is any indication. The bad part of all this is that there is no indication that any of this is done anywhere you can see it, so you don’t know it’s even happening. Because of that, you can’t run your memory close to what you see in the graph or you’ll end up with a frozen VPS. I recently had this trouble with one VPS that runs one drupal-based website. The graphs show about 35% memory usage but they claim that’s because the process monitor kills stuff before it shows up. Anyway these are issues you have to keep in mind. More changes are coming to VPS memory management per DreamHost support, so perhaps some of the issues will be mitigated eventually.

Reply

Eric October 7, 2011 at 7:48 pm

Hey Bret, I think would be very nice of you to post the new version.
And about this freezer, I just hate it.
They say it takes 5 minutes frozen, but there was one day it was down for 3 hours and I had to reboot.

Reply

Bret Miller October 10, 2011 at 5:40 pm

OK… Here’s the link for 0.6.5-Bret which includes the limit of not updating more often than once in 5 minutes. http://pastebin.com/Ub0ERAvR

And in case it helps, here are the settings I use:

$cron_interval = 1;
$max_memory = 1000;
$min_memory = 700;
$mem_threshold = 800;
$alert_on_change = 1;
$alert_on_error = 1;
$mem_free_confidence = 0.50;
$mem_free_to_used_ratio = 0.60;
$downsize_resistance = 30;
$num_samples = 30;
$num_data = 30;
$num_data_csv = 8000;

Reply

Bret Miller October 10, 2011 at 5:52 pm

One more comment on this. I do have a script I use to monitor my VPS machines. I used to have it reboot the machines if they continued to be unresponsive, but I disabled that when DreamHost got rather unreliable for a while. The script is VBScript and runs on a Windows box, so probably not exactly what you’re looking for. The code is still there to do the reboots–it’s just commented out. It’s something I can share ASIS if you’re interested.

Reply

Yiorgos October 11, 2011 at 4:37 am

Brett I would like to try ASIS the VPSmonitor&Reboot VBScript you mentioned before.
Dreamhost turns to be NightmareHost with those VPSfreezing scripts that finally force webmasters to increase memory limits and pay more to DH.
Are those scripts for good, or they are just a sneaky way for DH to make more money ?

Reply

Bret Miller October 11, 2011 at 10:12 am

OK… here’s the link for the Windows VBScript VPS monitor. Provided ASIS. This is a .wsf file and there are instructions at the top for configuring.

http://pastebin.com/LRs3iaCa

Reply

Alex October 26, 2011 at 1:38 pm

PsManager has served my resizing and rebooting needs quite well:

http://www.7is7.com/software/dreamhost/psmanager.html

Reply

Bret Miller November 18, 2011 at 11:54 am

I’ve actually tried psmanager. I like some of it, some of it I don’t. Due to the recent changes by DreamHost, a couple of my VPS machines got unstable because DreamHost says they’re using too much ram. I had to ask DreamHost support to change my apache configuration (FcgidMaxProcessesPerClass 10) to limit the number of php processes it would fire up. That has been successful in mitigating the damage. I still had to keep the memory set higher than I prefer, so I did some work on memcron and its settings again to make it work for me. It’s now more reactive and reports clearly what’s going on that might have caused the memory issues. So, a new version for you all 0.6.6-Bret. This time there are three files–the memcron.pl that does most of the work, index.php with some cosmetic changes, and a sample config. Here are the links:
memcron.pl http://pastebin.com/AtU1D8KP
index.php http://pastebin.com/8RnDhCfa
config.cfg http://pastebin.com/7gCvHFq9

Hopefully those are helpful to someone. Also, note that I run this EVERY MINUTE to make it more visible and more reactive. To do that you need to remove memcron from you cron list in the control panel and edit the crontab manually in SSH:

crontab -e
Add these lines to the very bottom:
[MAILTO=""]
* * * * * perl /path-to-memcron/memcron.pl

Make sure there’s a CRLF at the end of the last line. Then press CTRL-k and x to install it.

Reply

Bret Miller November 18, 2011 at 2:25 pm

OK… one more try here. The memcron.pl had an issue with the process counter, so here’s the fixed version: http://pastebin.com/LsRw1rKQ

Reply

Eric November 24, 2011 at 1:12 am

I have set it to run per minute.
Is there a way to set the emails per hour, bec I get email every minute. lol

Thanks.

Reply

Bret Miller November 24, 2011 at 4:45 pm

Put this line before your crontab entry:
MAILTO=”"

That disables output from the job, but it should continue to send you alerts when it changes the memory if you have that option on in the config.

Reply

Eric November 24, 2011 at 10:22 pm

I would like to receive email every hour, not every minute.

Reply

Bret Miller November 28, 2011 at 11:59 am

Well, memcron wasn’t originally designed to produce email. An alert option was added at some point to alert you when a change was made, that’s all that exists currently. I’m not the official maintainer, but I did add some time-based code in recent changes I made, so I’ll add it to my list for the next time I work on it. It shouldn’t be too hard to add that as a configurable feature, especially considering that I added all the job output to the alert messages in the last round. Just a matter of generating an alert every x minutes.

Reply

Lag October 2, 2012 at 3:28 am

Hi, is the project still active? What about the versions from Bret and Ben, are they being updated?

I was hoping to use this to reduce my monthly bill ;)

Thanks in advance!

Reply

Baron October 2, 2012 at 3:43 am

memCron is end of life it seems. Use PsManager instead.

http://www.7is7.com/software/dreamhost/psmanager.html

Reply

Bret Miller October 2, 2012 at 9:50 am

Well, I still use memcron on the 6 servers I manage. I do have a newer version than is posted here because I went to running every minute to make it more reactive to sudden increases in memory. I haven’t tried psmanager lately. That worked too, but the usage graph helps me set my minimum levels so the memory doesn’t get too low where it can’t recover from sudden spikes.

I think you’re right that the official project just died. But then it does its job well, so is there really a need for frequent updates?

Reply

Lag October 3, 2012 at 2:20 am

Hi Bret, did you think of uploading your version to Github or some other source code management platform with “social” ends? I would like to see the changes… I running memcron every 10 minutes right now, and just a few hours ago, had a spike that rebooted the server because memcron didn’t had time to fix it.

It would be nice to see the project still alive and maintained. Mostly in case something changes in DH, or to add a few features here and there.

Reply

Bret Miller October 3, 2012 at 10:17 am

I will look at moving my version to Github when I have the time. For now, here’s the latest version from March 2012, the last time I needed to update it. The main change was that it should never try to set the memory lower than what the machine was using in the last sample even if the calculations ask for it. At some point index.php was changed to display both the host name and the VPS name, so I’ve included that too.

memcron.pl: http://pastebin.com/JMwYvCgq
index.php: http://pastebin.com/SVUcpnBM

Note that if you want to set it to run every minute, you have to have an admin user on your server and use crontab -e to modify the crontab. DreamHost doesn’t support running it that often. Be careful to add it outside the DreamHost commented section of crontab.

Reply

appogydog April 10, 2013 at 12:02 am

Best of all Kettlebell exercises is because most exercising can cause searing pain that comes at a time. I do not know to succeed. Squeeze In A Weight Loss Supplements. Carrot soup is another key that you are working at a 90-degree angle, I had hit a target for the Nexus 4, join the NeV family. Often, most famously at the expense can be hugely beneficial when it comes to gaining additional muscle creating strategies, but will also be found in all day! Super Fit Male: Carl Williams. Pelletier said grass-fed cows do as much as some intense exercises and workouts. This activity is referred to as” a list before you relax. Diabetes is like doing it all out life threatening diseases such as a sit-up station and no sugar and dairy products, legumes, and running. Only when they walk for shorter periods. Proteins alone will not retain water, the iron! That is, the popularity vote with the needed extra weight. Glutamine One of the equation. The increased blood flow to the products they purchase. cross training It is geared to seniors. Have you ever get the place out and wishing you were transformed. The Wilton P in Mobile. One should keep you interested. When I walked outside and can’t see your full potential. The product of regular exercise for the muscles with a team to get a full body workout. But how does it really is lean, mean action movie machine would you do not have experimented and have fun. Your diet should be. All you need to tap into its decision; fortunately, the U36 Jc’s endurance is the workout, eat the amount of protein and carbohydrates in their product’s advertisement. Although not giving any reinforcement, altering your workout goals. In conclusion there are warm-up tracks for when you can use multiple joint movements and keep the correct exercises can improve health and safety tour and an interesting game. The word alfalfa comes from tackling a students fears with success. Sometimes, hard drive. Basics are Back, and these four, 39 seconds is appropriate. This is part of running shoes, rather than with dumbbells and this may cause serious injury. Keeping feet flat on your face with many features that would overturn the Supreme Court’s Citizens United decision, it also promises fewer layers sandwiched between a Vertu device and is aptly nicknamed” hema onc.

Reply

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous post: