Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

narcissus: keep sleeping till the load goes down

Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
  • Loading branch information...
commit 8bdcf5cc055492558fb71d48e08d8497973d1b0b 1 parent cb92110
@koenkooi koenkooi authored
Showing with 11 additions and 7 deletions.
  1. +11 −7 scripts/sleep.sh
View
18 scripts/sleep.sh
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.