WebFaction
Community site: login faq
0
1

This could just be a simple permissions error (I'm not familiar with SSH permissions) but I can't get the zope memory watchdog script to run.

To give you the background - I've created a new zope instance [version Zope (2.12.11) - Plone (4.0.1)] in a new shared server and I'm trying to create the zope memory watchdog for this instance.

I followed the instructions on the old forum - http://forum.webfaction.com/viewtopic.php?id=1463 -

#!/bin/bash
RAMUSAGE=$(ps -u $LOGNAME -o rss,command | grep -v peruser | awk '{sum+=$1} END {print sum}')
if [ $RAMUSAGE -gt 163840 ]; then
    echo "$( date +'%Y-%m-%d %H:%M:%S') Memory usage at $RAMUSAGE - restarting Zope" >> ~/logs/user/mem.log
    ~/webapps/zope/Zope/bin/zopectl restart
    # you can run other stuff here also
fi

changing the username, RAM value, and path to the restart script (as this seems to have changed location in this newer version of zope) which I think is now found at

~/webapps/<app name>/zinstance/bin/instance restart

I then tried to run the new script from the SSH root

~/bin/zopewatch

but this generated a permissions error.

-bash: /home/USERNAME/bin/zopewatch: Permission denied

getfacl told me that this script had no execute rights applied

user::rw- group::rw- other::r--

So I tried :

setfacl -m u:USERNAME:rwx bin/zopewatch

which getfacl told me had given my username rwx permissions

user::rw- user:urbanian:rwx group::rw- mask::rwx

However when I attempt to run the script I get the same permissions error???

-bash: /home/USERNAME/bin/zopewatch: Permission denied

Does anyone know what's going wrong here? Thanks in advance for your help... Ian.

asked 07 Jan '11, 09:49

urbanian
847
accept rate: 0%

edited 07 Jan '11, 11:02


Try chmod u+x ~/bin/zopewatch then try running the script again. Hope that helps!

permanent link

answered 07 Jan '11, 10:27

seanf
12.2k41836
accept rate: 37%

That appears to have done the trick - thanks!

(07 Jan '11, 11:00) urbanian

(Here is the original Zope Memory Watchdog post from the old forum, since it is no longer online:)


Here's a simple shell script I use to keep tabs on my Zope's memory usage:

Code:

#!/bin/bash
RAMUSAGE=$(ps -u $LOGNAME -o rss,command | grep -v peruser | awk '{sum+=$1} END {print sum}')
if [ $RAMUSAGE -gt 163840 ]; then
    echo "$( date +'%Y-%m-%d %H:%M:%S') Memory usage at $RAMUSAGE - restarting Zope" >> ~/logs/user/mem.log
    ~/webapps/zope/Zope/bin/zopectl restart
    # you can run other stuff here also
fi

It does the following:

  1. Calculates my total memory usage
  2. Compares that to a preset value of 163840 (160MB)
  3. If it is greater than 160MB, make an entry in ~/logs/user/mem.log, then restart the Zope app located in ~/webapps/zope.

I've got it saved as ~/bin/zopewatch, and scheduled to run every 5 minutes with the following cron job:

Code:

*/5 * * * * /home/my_username/bin/zopewatch > /dev/null 2>&1

I know not everyone would want their Zope restarting automatically, but mine is just a personal site, and running like this ensures that I'll never receive a high memory warning from WebFaction.

You could use this for any long running app, not just Zope - just change the line that restarts Zope to whatever you need (call another script, fire off an email, whatever).

permanent link

answered 23 Apr '13, 15:15

likebike
3366
accept rate: 28%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×87
×64
×18
×11
×3

question asked: 07 Jan '11, 09:49

question was seen: 3,828 times

last updated: 23 Apr '13, 15:15

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM