[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#303412: radiuscontext: monthly statistics



Package: radiuscontext
Version: 1.76-3
Severity: wishlist
Tags: patch


The package, out of a box, unable to produce even simple monthly 
statistics.

Here is useful script:

--- /usr/local/sbin/radius-report

#!/bin/sh -e

###########################################################################
#
# Monthly reporting tool for radiuscontext
#
# Usage: radius-report [this|daily|...]
#
# While started without any arguments, generates report for the last 
# calendar month. Else (think "_this_ month" or "_daily_ report") generates 
# "cumulative" report for the current month.
#
# In /etc/cron.d/radiuscontext:
#
# @daily root /usr/local/sbin/radius-report daily
# @monthly root /usr/local/sbin/radius-report
#
# You have to provide the radius accounting "detail" logs rotated with 
# enough rate (with logrotate, for instance), since this tool time filter 
# is based on log file modification time. Logs may be gzipped and spreaded
# under several subdirectories of the find start point.
#
###########################################################################
#
# Copyright (c) Al Nikolov <alnikolov@narod.ru>, 2005
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
###########################################################################

# Where you want temporary database to be created
TMPDIR=/tmp

# Where you store radius accounting logs
LOGDIR=/var/log/radacct

# Where you want reports to be created
REPDIR=/var/www/radius-reports

# Options for reporting
OPTS='-g html -s 0'

###########################################################################


offset () { 
  OFFSET=$((($(/bin/date +%s) - $(/bin/date -d $1 +%s)) / 60))
  /bin/echo $(($OFFSET > 0 ? $OFFSET : 0))
}

ym () { 
  /bin/echo $(/usr/bin/expr substr $1 1 7)
}

TODAY=$(/bin/date +%F)
if [ "$1" == "" ]; then
  START=$(/bin/date -d "$(ym $TODAY)-15 -1 month" +%Y-%m)-01
  END=$(ym $TODAY)-01
else
  START=$(ym $TODAY)-01
  END=$(/bin/date -d "$TODAY tomorrow" +%F)
fi
TEMP=$(/bin/mktemp)
/usr/bin/find $LOGDIR -name detail* \
  -mmin +$(offset $END) -mmin -$(offset $START) \
  -exec /bin/zcat -f {} \;|/usr/bin/raddetail -d $TEMP
REPDIR=$REPDIR/$(ym $START)
/bin/mkdir -p $REPDIR
/usr/bin/radreport -d $TEMP -D $REPDIR $OPTS
/bin/rm $TEMP




-- System Information
Debian Release: 3.0
Architecture: i386
Kernel: Linux alligator 2.4.18 #1 SMP Thu Jun 17 16:44:46 MSD 2004 i686
Locale: LANG=ru_RU.KOI8-R, LC_CTYPE=ru_RU.KOI8-R

Versions of packages radiuscontext depends on:
ii  python                        2.1.3-3.2  An interactive object-oriented scr
ii  python1.5                     1.5.2-23.3 An interactive object-oriented scr
ii  python1.5-gdbm                1.5.2-23.3 GNU dbm database support for Pytho




Reply to: