improved indexing

This commit is contained in:
SJ 2013-07-09 10:12:42 +02:00
parent bc16df8778
commit 7e65be8ca7
7 changed files with 77 additions and 6 deletions

View File

@ -110,7 +110,7 @@ key:
dd if=/dev/urandom bs=56 count=1 of=piler.key
postinstall:
@sh util/postinstall.sh $(RUNNING_USER) $(RUNNING_GROUP) $(sysconfdir) $(localstatedir)
@sh util/postinstall.sh $(RUNNING_USER) $(RUNNING_GROUP) $(sysconfdir) $(localstatedir) $(libexecdir)

View File

@ -17,8 +17,8 @@ piler's crontab:
### mandatory
*/5 * * * * LC_ALL=C mpstat | tail -1 | awk '{print $11}' > /var/piler/stat/cpu.stat
5,35 2-23 * * * /usr/local/bin/indexer --quiet delta1 --rotate && sleep 2 && /usr/local/bin/indexer --quiet --merge dailydelta1 delta1 --merge-dst-range deleted 0 0 --rotate
15 0 * * * /usr/local/bin/indexer --quiet --merge main1 dailydelta1 --merge-dst-range deleted 0 0 --rotate && sleep 2 && /usr/local/bin/indexer --quiet dailydelta1 --rotate
5,35 * * * * LIBEXECDIR/piler/indexer.delta.sh
15 2 * * * LIBEXECDIR/piler/indexer.main.sh
*/15 * * * * /usr/local/bin/indexer --quiet tag1 --rotate
*/15 * * * * /usr/local/bin/indexer --quiet note1 --rotate

View File

@ -31,6 +31,8 @@ install:
$(INSTALL) -m 0755 $(srcdir)/daily-report.php $(DESTDIR)$(libexecdir)/piler
$(INSTALL) -m 0755 $(srcdir)/gmail-imap-import.php $(DESTDIR)$(libexecdir)/piler
$(INSTALL) -m 0755 $(srcdir)/generate_stats.php $(DESTDIR)$(libexecdir)/piler
$(INSTALL) -m 0755 $(srcdir)/indexer.delta.sh $(DESTDIR)$(libexecdir)/piler
$(INSTALL) -m 0755 $(srcdir)/indexer.main.sh $(DESTDIR)$(libexecdir)/piler
clean:

35
util/indexer.delta.sh Executable file
View File

@ -0,0 +1,35 @@
#!/bin/bash
MAINTMPFILE=/var/run/piler/main.indexer.tmp
DELTATMPFILE=/var/run/piler/delta.indexer.tmp
INDEXER=`which indexer`
PRIORITY=mail.error
if [ -f $MAINTMPFILE ]; then echo "INDEXER ERROR: indexer merging to main index is already running. It started at "`cat $MAINTMPFILE` | logger -p $PRIORITY ; exit 1; fi
if [ -f $DELTATMPFILE ]; then echo "INDEXER ERROR: delta indexing and merging is already running. It started at "`cat $DELTATMPFILE` | logger -p $PRIORITY ; exit 1; fi
date > $DELTATMPFILE
function finish {
rm -f $DELTATMPFILE
}
trap finish EXIT
echo "INDEXER INFO: indexing delta1 started" | logger -p $PRIORITY
5,35 2-23 * * * /usr/local/bin/indexer --quiet delta1 --rotate && sleep 2 && /usr/local/bin/indexer --quiet --merge dailydelta1 delta1 --merge-dst-range deleted 0 0 --rotate
$INDEXER --quiet delta1 --rotate
echo "INDEXER INFO: indexing delta1 finished" | logger -p $PRIORITY
sleep 5
echo "INDEXER INFO: merging delta to dailydelta started" | logger -p $PRIORITY
$INDEXER --quiet --merge dailydelta1 delta1 --merge-dst-range deleted 0 0 --rotate
echo "INDEXER INFO: merging delta to dailydelta finished" | logger -p $PRIORITY

31
util/indexer.main.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/bash
MAINTMPFILE=/var/run/piler/main.indexer.tmp
#MAINTMPFILE=/tmp/main.indexer.tmp
INDEXER=`which indexer`
PRIORITY=mail.error
if [ -f $MAINTMPFILE ]; then echo "ERROR: indexer merging to main index is already running. It started at "`cat $MAINTMPFILE` | logger -p $PRIORITY ; exit 1; fi
date > $MAINTMPFILE
function finish {
rm -f $MAINTMPFILE
}
trap finish EXIT
echo "INFO: merging to main started" | logger -p $PRIORITY
$INDEXER --quiet --merge main1 dailydelta1 --merge-dst-range deleted 0 0 --rotate
echo "INFO: merging to main finished" | logger -p $PRIORITY
sleep 5
echo "INFO: resetting daily delta started" | logger -p $PRIORITY
$INDEXER --quiet dailydelta1 --rotate
echo "INFO: resetting daily delta finished" | logger -p $PRIORITY

View File

@ -75,7 +75,7 @@ gather_smtp_relay_data() {
ask "Please enter smtp relay" "$SMARTHOST"
SMARTHOST=$response
askNonBlankNoEcho "Please enter smtp relay port" "$SMARTHOST_PORT"
ask "Please enter smtp relay port" "$SMARTHOST_PORT"
SMARTHOST_PORT=$response
}
@ -100,7 +100,9 @@ make_cron_entries() {
echo ""
echo "### PILERSTART" >> $CRON_TMP
echo "*/5 * * * * LC_ALL=C mpstat | tail -1 | awk '{print \$11}' > $LOCALSTATEDIR/piler/stat/cpu.stat" >> $CRON_TMP
echo "5,35 * * * * $INDEXER --quiet delta1 --rotate && sleep 2 && $INDEXER --quiet --merge main1 delta1 --merge-dst-range deleted 0 0 --rotate" >> $CRON_TMP
echo "5,35 * * * * $LIBEXECDIR/piler/indexer.delta.sh" >> $CRON_TMP
echo "15 2 * * * $LIBEXECDIR/piler/indexer.main.sh" >> $CRON_TMP
echo "*/15 * * * * $INDEXER --quiet tag1 --rotate" >> $CRON_TMP
echo "*/15 * * * * $INDEXER --quiet note1 --rotate" >> $CRON_TMP
echo "### PILEREND" >> $CRON_TMP
@ -255,7 +257,7 @@ PILERUSER=$1
PILERGROUP=$2
SYSCONFDIR=$3
LOCALSTATEDIR=$4
LIBEXECDIR=$5
#LOGFILE="/tmp/piler-install.log.$$"
#touch $LOGFILE

View File

@ -11,6 +11,7 @@ load_default_values() {
PILERUSER="piler"
SYSCONFDIR="/usr/local/etc"
LOCALSTATEDIR="/var"
LIBEXECDIR="/usr/local/libexec"
KEYTMPFILE="piler.key"
KEYFILE="$SYSCONFDIR/piler.key"