Bug#505996: bcfg2: Include random Sleep before running on cronjob

2008-12-20 Thread Sol Jerome
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

There are already a couple ways to do this using either TCheetah or
TGenshi templating systems. Both are on the wiki:

http://trac.mcs.anl.gov/projects/bcfg2/wiki/TCheetahPlugin
http://trac.mcs.anl.gov/projects/bcfg2/wiki/TGenshi/examples/bcfg2_cron

This will allow you to use python's random implementation while giving
reproducable results (seeded by hostname).

HTH,
Sol
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: http://getfiregpg.org

iD8DBQFJTUCKgLhJL6iP/0sRAm3zAKCuFXnG3aT5G3E0iO4aU/hmXqiyHACgrnWS
X1nQJ/HRaluIjQlN1od0TMA=
=4Hds
-END PGP SIGNATURE-



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#505996: bcfg2: Include random Sleep before running on cronjob

2008-11-17 Thread Marc Fargas
Package: bcfg2
Version: 0.9.5.7-1.1
Severity: wishlist

Hi there,
Right now all bcfg2 clients will run at the very same time in a common
scenario (i.e. from the cronjob provided) that can, in my case does,
kill the server. Maybe the cron job could do some random sleeping
before running the agent, just like /etc/cron.daily/apt does, i.e:

  sleep `$(($(dd if=/dev/urandom count=1 2 /dev/null | cksum | cut -c1-5) % 
1800))`

Or, from /etc/cron.daily/apt:

# sleep for a random interval of time (default 30min)
# (some code taken from cron-apt, thanks)
random_sleep()
{
RandomSleep=1800
eval $(apt-config shell RandomSleep APT::Periodic::RandomSleep)
if [ $RandomSleep -eq 0 ]; then
return
fi
if [ -z $RANDOM ] ; then
# A fix for shells that do not have this bash feature.
RANDOM=$(dd if=/dev/urandom count=1 2 /dev/null | cksum | cut -c1-5)
fi
TIME=$(($RANDOM % $RandomSleep))
sleep $TIME
}

That would distribute the hourly load spike a bit ;)

Thanks,
Marc

-- System Information:
Debian Release: lenny/sid
  APT prefers testing
  APT policy: (900, 'testing'), (300, 'unstable'), (150, 'experimental'), (100, 
'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.26-1-686 (SMP w/2 CPU cores)
Locale: LANG=es_ES.UTF-8, LC_CTYPE=es_ES.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#505996: bcfg2: Include random Sleep before running on cronjob

2008-11-17 Thread Sami Haahtinen
Hi,

On Mon, 2008-11-17 at 17:26 +0100, Marc Fargas wrote:
 Right now all bcfg2 clients will run at the very same time in a common
 scenario (i.e. from the cronjob provided) that can, in my case does,
 kill the server. Maybe the cron job could do some random sleeping
 before running the agent...

That's actually a really good idea. The only problem is that sleeping
while doing cron.daily run will cause the rest of the jobs to be delayed
within that cron.daily run.

It might be better to detach the process and run the job after waiting a
random time. Also, it might be a good idea to allow the user to
configure the offset since in some cases it is critical for the client
to run the job as close as possible to the given time.

I'll see what i can come up with =)

- S

-- 
Sami Haahtinen [EMAIL PROTECTED]


signature.asc
Description: This is a digitally signed message part