chiark / gitweb /
do ignore sigpipe; move inndcommfail
[inn-innduct.git] / backends / sendinpaths.in
1 #!/bin/sh
2 # fixscript will replace this line with code to load innshellvars
3 #
4 # Submit path statistics based on ninpaths
5 # $Id: sendinpaths.in 5854 2002-11-25 17:53:06Z rra $
6
7 # Assuming the ninpaths dump files are in ${MOST_LOGS}/path/inpaths.%d
8
9 cd ${MOST_LOGS}/path
10 ME=`${NEWSBIN}/innconfval pathhost`
11 report=30
12 keep=14
13 TMP=""
14 defaddr="pathsurvey@top1000.org top1000@anthologeek.net"
15
16 # Renice to give other processes priority, since this isn't too important.
17 renice 20 -p $$ > /dev/null
18
19 # Make report from (up to) $report days of dumps
20 LOGS=`find . -name 'inpaths.*' ! -size 0 -mtime -$report -print`
21 if [ -z "$LOGS" ] ; then
22   echo "No data has been collected this month!"
23   exit 1
24 fi
25
26 # for check dumps
27 for i in $LOGS
28 do
29  ninpaths -u $i -r $ME > /dev/null 2>&1
30  if test $? -eq 0; then :
31   TMP="$TMP -u $i"
32  fi
33 done
34
35 if [ "$1" = "-n" ] ; then
36   ninpaths $TMP -r $ME
37 else
38   ninpaths $TMP -r $ME |\
39    $MAILCMD -s "inpaths $ME" ${1:-$defaddr}
40   # remove dumps older than $keep days
41   find . -name 'inpaths.*' -mtime +$keep -exec rm '{}' \;
42 fi
43
44 exit 0