Skip to content

Commit

Permalink
narcissus: keep sleeping till the load goes down
Browse files Browse the repository at this point in the history
Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
  • Loading branch information
koenkooi committed Jan 14, 2011
1 parent cb92110 commit 8bdcf5c
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions scripts/sleep.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#!/bin/sh

LOAD="$(cat /proc/loadavg | awk -F. '{print $1}')"
iter=1

if [ $LOAD -gt 8 ] ; then
echo "load too high: $LOAD, sleeping"
sleep 20
sleep $LOAD
echo "$(date) load too high: $LOAD, sleeping" >> /tmp/foo
else
echo "load acceptable: $LOAD, continuing"
while [ $LOAD -gt 12 ] ; do
echo "load too high: $LOAD, sleeping - $iter"
echo "$(date) load too high: $LOAD, sleeping - $iter" >> /tmp/foo
sleep 5
iter=$(( $iter + 1 ))
LOAD="$(cat /proc/loadavg | awk -F. '{print $1}')"
done

if [ $iter -gt 1 ] ; then
echo "load acceptable again, continuing after $iter sleep cycles" >> /tmp/foo
fi

0 comments on commit 8bdcf5c

Please sign in to comment.