Skip to content

Instantly share code, notes, and snippets.

@daniel-garcia
Last active December 14, 2015 22:09
Show Gist options
  • Save daniel-garcia/5156098 to your computer and use it in GitHub Desktop.
Save daniel-garcia/5156098 to your computer and use it in GitHub Desktop.
Reindex events modified in the last n seconds
#!/usr/bin/env bash
function usage() {
echo $0 "[seconds]"
}
seconds=$1
if [ -z "$seconds" ]; then
echo "seconds were not specified"
usage
exit 1
fi
for table in summary archive
do
cmd="select (unix_timestamp()-$seconds)*1000 into @last_rsync; insert into event_${table}_index_queue (uuid, update_time) select uuid, update_time from event_${table} where update_time>@last_rsync;"
echo "executing: $cmd"
$ZENHOME/bin/python $ZENHOME/Products/ZenUtils/ZenDB.py --usedb=zep --execsql "$cmd"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment