#!/bin/sh
# Copyright (c) 2010-2013 Index Data, http://www.indexdata.com
#
# pazpar2-error-statistic - generate daily reliablity statistics

# who will get the statistics. Set the environment variable mailto to
# change the list of recipients
: ${mailto='wosch'} #test


# die on error
set -e
umask 002
tmp=$(mktemp)

# LANG=en_US.UTF-8 make egrep 10 times slower
export LANG=C

# use development installation if exists
if [ -d /home/indexdata/pazpar2-statistic/bin ]; then
   cd /home/indexdata/pazpar2-statistic/bin
else
   cd /usr/share/pazpar2-statistic/bin
fi

# overview of failed z39.50 connections
make -s today-total | ./ppstat2csv.pl > $tmp && cp -f $tmp /var/lib/cf-repo/.statistic/.reliability-pazpar2-today-full.csv

rm -rf $tmp

