From 982de35051bed16cb57739c7b4acabe4c7f251ac Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Sat, 25 Aug 2012 01:24:57 +0200 Subject: [PATCH] reduce limits on high loads and order results correctly --- utils/cron_banip.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/utils/cron_banip.sh b/utils/cron_banip.sh index c73db560..2e0c8dfb 100755 --- a/utils/cron_banip.sh +++ b/utils/cron_banip.sh @@ -23,6 +23,11 @@ SRCHSHORT_LIMIT='10 min' PSQLCMD='psql -qtA -d nominatim' +curload=`cat /proc/loadavg | sed 's:[. ].*::'` +if [ "$curload" -gt "15" ]; then + REVSHORT_LIMIT=$((REVSHORT_LIMIT/2)) +fi + # Blocking candidates $PSQLCMD > $BLOCKEDFILE.newblocks << ENDOFQUERY SELECT ipaddress FROM @@ -70,10 +75,12 @@ if [ "x$blocked" == "x" ]; then mv $BLOCKEDFILE.newblocks $BLOCKEDFILE else $PSQLCMD > $BLOCKEDFILE.newlifted << ENDOFQUERY + SELECT column1 FROM ( VALUES ('$blocked') EXCEPT (SELECT DISTINCT ipaddress FROM new_query_log WHERE starttime > now() - interval '$COOLOFF_PERIOD') + ) as q ORDER BY column1; ENDOFQUERY no_lifted=`cat $BLOCKEDFILE.newlifted | wc -w` -- 2.39.5