#!/bin/bash

DEFAULT_PACE=1000
DEFAULT_PIPE=/tmp/cca
CCAD_CONF=/etc/ccad.conf
MYSQL='/usr/bin/mysql'
TR=/usr/bin/tr
SLEEP=/bin/sleep



function get_value_from_config {
   CONF_VALUE=`grep -oE "$1[[:space:]]*=[[:space:]]*[^[:space:]]+" $CCAD_CONF |cut -d"=" -f 2|tr -d " "`
}

get_value_from_config "pace"
PACE=${CONF_VALUE:-$DEFAULT_PACE}
PACE=$(( $PACE / 1000 ))

get_value_from_config "pipe"
PIPE=${CONF_VALUE:-$DEFAULT_PIPE}
test -p $PIPE || exit 3

while true; do
   $MYSQL -e 'show global status'|$TR '[[:blank:]]' '=' > $PIPE
   $SLEEP $PACE || exit 4
   echo "." > $PIPE
done

