memCron 0.6

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 id=”6″]

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 “” is no longer used and can be safely removed.

137 thoughts on “memCron 0.6”

  1. sigh…suddenly memcron has broken.

    any ideas on this?

    main::normsinv() called too early to check prototype at /home/user/hinternet/memcron/ line 94.
    main::normsinv() called too early to check prototype at /home/user/hinternet/memcron/ line 95.

    1. OK, memcron is actually working, as others have said it is a warning only.

      You can stop getting emailed by adding ,code>> /dev/null to the end of the cron line

      e.g. perl $HOME/hinternet/memcron/ > /dev/null

  2. 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.

    1. @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.

      1. 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.

        1. OK… Here’s the link for 0.6.5-Bret which includes the limit of not updating more often than once in 5 minutes.

          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;

    2. 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.

  3. 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 ?

  4. 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 that does most of the work, index.php with some cosmetic changes, and a sample config. Here are the links:

    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:
    * * * * * perl /path-to-memcron/

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

    1. Put this line before your crontab entry:

      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.

    1. 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.

  5. 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!

    1. 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?

      1. 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.

  6. 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.

    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.

  7. Yea, I’m guessing this hasn’t been sleovd . makes the whole idea kind of a close but no cigar thing for me. That and the code to make the tags dynamic (which works) doesn’t seem to leave a way to show ALL in addition to the sorted by tags without adding the ALL link between each tag link.

  8. Hi, logo.png’, admin’ => false) , true);?> />The above given is my code. Is there any issue? If it is please let me know. Because the above given is not working for me. In my tweet, only title and links are displayed, I want to display the description in that tweet. Please help me.Thanks in advance,Usha.S

  9. I wished to thank you so much once again. I am not sure the thigns I could possibly have carried out in the absence of the type of creative concepts provided by you regarding this situation. It truly was a intimidating concern for me personally, nevertheless spending time with a new professional tactic you solved it made me to weep over gladness. Extremely happier for this work and hope you know what a great job that you’re putting in teaching many others all through your webblog. I know that you have never met any of us.

  10. Thank you for each of your efforts on this site. Debby rllaey loves participating in research and it’s rllaey easy to understand why. My partner and i hear all concerning the powerful means you deliver worthwhile information on the web site and therefore improve participation from other ones on that idea and our favorite daughter is always being taught a great deal. Enjoy the rest of the new year. You are always doing a useful job.

  11. What i do not understood is how you are not much more well-liked than you may be right now. You’re so inlgetielnt. You realize thus significantly relating to this subject, made me personally consider it from a lot of varied angles. Its like men and women aren’t fascinated unless it?s one thing to accomplish with Lady gaga! Your own stuffs outstanding. Always maintain it up!

  12. . Your justification arpeaped to be on the net the simplest thing to be aware of. I say to you, I certainly get annoyed while people consider worries that they just don’t know about. You managed to hit the nail upon the top and defined out the whole thing without having side-effects , people can take a signal. Will probably be back to get more. Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.