From 29054afff2f41e9f861ba465a0bfff14234a1970 Mon Sep 17 00:00:00 2001 From: Raghu Rao Date: Wed, 11 Sep 2013 11:09:25 -0500 Subject: [PATCH] Added an example script to prune the rawdata table --- etc/sample_stacktach_prune.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 etc/sample_stacktach_prune.sh diff --git a/etc/sample_stacktach_prune.sh b/etc/sample_stacktach_prune.sh new file mode 100644 index 0000000..2afe282 --- /dev/null +++ b/etc/sample_stacktach_prune.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# Example script to prune the Stacktach RawData table + +# The following is one way you could keep your RawData table from growing +# very large -- keep only the last N days worth of data, N being a number +# convenient to your installation. + +# Full path to where you have deployed the Stacktach app +PATH_TO_ST='/path/to/stacktach' + +# Let us say we want to keep only 90 days' worth of RawData. +# 90 days = 90 * (24*60*60) seconds = 7776000 seconds. +KEEP_RAWDATA_DAYS=90 +KEEP_RAWDATA_SECS=$((KEEP_RAWDATA_DAYS*24*60*60)) + +# Source the stacktach_config.sh script to populate the +# STACKTACH_DB_* variables among other things, and do the deed. +cd ${PATH_TO_ST} && \ +. ${PATH_TO_ST}/etc/stacktach_config.sh && \ +python manage.py dbshell < /tmp/stacktach_prune.stdout \ + 2> /tmp/stacktach_prune.stderr + +DELETE FROM stacktach_rawdata +WHERE stacktach_rawdata.when < (UNIX_TIMESTAMP(NOW())-${KEEP_RAWDATA_SECS}); + +EOF