Skip to content

Instantly share code, notes, and snippets.

@simonmcc
Created October 2, 2014 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonmcc/efbb3b55bffd5bd41a42 to your computer and use it in GitHub Desktop.
Save simonmcc/efbb3b55bffd5bd41a42 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Report on the current state of unarchived records in the main nova.* tables
#
DATABASE=nova
TABLES="security_group_rules security_group_instance_association security_groups instance_info_caches instance_system_metadata instances reservations compute_node_stats "
for TABLE in ${TABLES}
do
SHADOW_TABLE="shadow_${TABLE}"
ACTIVE_RECORDS=`mysql -B -e "select count(id) from ${DATABASE}.${TABLE} where deleted=0" | tail -1`
DELETED_RECORDS=`mysql -B -e "select count(id) from ${DATABASE}.${TABLE} where deleted!=0" | tail -1`
SHADOW_RECORDS=`mysql -B -e "select count(id) from ${DATABASE}.${SHADOW_TABLE}" | tail -1`
TOTAL_RECORDS=`expr $ACTIVE_RECORDS + $DELETED_RECORDS + $SHADOW_RECORDS`
echo `date` "${DATABASE}.${TABLE} has ${ACTIVE_RECORDS}, ${DELETED_RECORDS} ready for archiving and ${SHADOW_RECORDS} already in ${SHADOW_TABLE}. Total records is ${TOTAL_RECORDS}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment