This should prevent us from executing the same awstats analysis at the same time, thereby eliminating the nagios alerts for crond on log1. Since I'm not in sysadmin-web, I don't feel real comfortable deploying this without someone telling me it's OK and that it looks sane :)
diff --git a/modules/awstats/templates/awstats.cron.erb b/modules/awstats/templates/awstats.cron.erb index 7e41be0..7ea507b 100755 --- a/modules/awstats/templates/awstats.cron.erb +++ b/modules/awstats/templates/awstats.cron.erb @@ -1,6 +1,12 @@ #!/bin/bash
# <%= name %> + +if [ -e /var/run/<%=name>.awstats.lock ] ; do + exit 1 +fi + +touch /var/run/<%= name%>.awstats.lock mkdir -p /srv/web/awstats/<%= name %>
/usr/share/awstats/tools/awstats_buildstaticpages.pl \
On 2008-11-08 09:43:28 PM, Jon Stanley wrote:
This should prevent us from executing the same awstats analysis at the same time, thereby eliminating the nagios alerts for crond on log1. Since I'm not in sysadmin-web, I don't feel real comfortable deploying this without someone telling me it's OK and that it looks sane :)
I think you forgot to rm the lock file when it finishes :-) Otherwise, it looks good. If you want to take it a step further and account for stale lockfiles, take a look at what Mike did in configs/system/syncStatic.sh.
Thanks, Ricky
2008/11/8 Ricky Zhou ricky@fedoraproject.org:
I think you forgot to rm the lock file when it finishes :-) Otherwise, it looks good. If you want to take it a step further and account for stale lockfiles, take a look at what Mike did in configs/system/syncStatic.sh.
Grr, here's another try:
diff --git a/modules/awstats/templates/awstats.cron.erb b/modules/awstats/templates/awstats.cron.erb index 7e41be0..825d4e9 100755 --- a/modules/awstats/templates/awstats.cron.erb +++ b/modules/awstats/templates/awstats.cron.erb @@ -1,6 +1,14 @@ #!/bin/bash
# <%= name %> + +if [ -e /var/lock/subsys/<%= name %>.awstats.lock ] ; then + if `ps $(cat /var/lock/subsys/<%= name %>.awstats.lock) > /dev/null` ; then + exit 1 + fi +fi + +echo $$ > /var/lock/subsys/<%= name %>.awstats.lock mkdir -p /srv/web/awstats/<%= name %>
/usr/share/awstats/tools/awstats_buildstaticpages.pl \ @@ -10,3 +18,5 @@ mkdir -p /srv/web/awstats/<%= name %> ln -sf \ /srv/web/awstats/<%= name %>/awstats.<%= name %>.html \ /srv/web/awstats/<%= name %>/index.html + +rm /var/lock/subsys/<%= name %>.awstats.lock
infrastructure@lists.fedoraproject.org