Asterisk CDR csv handling2

'#!/bin/sh

'# asterisk_cdr_sums.sh
'# outputs sums of usage from csv based cdr records
'# suitable for monitoring own usage where complete accuracy is not required
'# use logrotate on Master.csv to limit number of days for which sums apply (I use monthly)

'# use:
'# /path/asterisk_cdr_sums.sh
'# or
'# /path/asterisk_cdr_sums.sh | mail voipmaster -s 'Asterisk cdr sums'
'# in a cron job to schedule emails to someone

'# setup:
'# use accountcodes in sip.conf, iax.conf, etc or use superdial macro (from wiki) to set cdr accounts

echo
echo "nboom"
grep nboom Master.csv | awk '{ FS = ","; s +=$14; } END { print "Sum is:", s, "(",s/60,"minutes )"}'
echo
echo "voipjet"
grep voipjet Master.csv | awk '{ FS = ","; s +=$14; } END { print "Sum is:", s, "(",s/60,"minutes )"}'
echo
echo "voipjet800"
grep voipjet800 Master.csv | awk '{ FS = ","; s +=$14; } END { print "Sum is:", s, "(",s/60,"minutes )"}'
echo
echo "aleph"
grep aleph Master.csv | awk '{ FS = ","; s +=$14; } END { print "Sum is:", s, "(",s/60,"minutes )"}'
echo
echo "aleph800"
grep aleph800 Master.csv | awk '{ FS = ","; s +=$14; } END { print "Sum is:", s, "(",s/60,"minutes )"}'
echo
echo "pstn-local"
grep pstn-local Master.csv | awk '{ FS = ","; s +=$14; } END { print "Sum is:", s, "(",s/60,"minutes )"}'
echo
echo "pstn"
grep pstn Master.csv | awk '{ FS = ","; s +=$14; } END { print "Sum is:", s, "(",s/60,"minutes )"}'
echo
echo "pstn800"
grep pstn800 Master.csv | awk '{ FS = ","; s +=$14; } END { print "Sum is:", s, "(",s/60,"minutes )"}'


'#!/bin/sh

'# asterisk_cdr_sums.sh
'# outputs sums of usage from csv based cdr records
'# suitable for monitoring own usage where complete accuracy is not required
'# use logrotate on Master.csv to limit number of days for which sums apply (I use monthly)

'# use:
'# /path/asterisk_cdr_sums.sh
'# or
'# /path/asterisk_cdr_sums.sh | mail voipmaster -s 'Asterisk cdr sums'
'# in a cron job to schedule emails to someone

'# setup:
'# use accountcodes in sip.conf, iax.conf, etc or use superdial macro (from wiki) to set cdr accounts

echo
echo "nboom"
grep nboom Master.csv | awk '{ FS = ","; s +=$14; } END { print "Sum is:", s, "(",s/60,"minutes )"}'
echo
echo "voipjet"
grep voipjet Master.csv | awk '{ FS = ","; s +=$14; } END { print "Sum is:", s, "(",s/60,"minutes )"}'
echo
echo "voipjet800"
grep voipjet800 Master.csv | awk '{ FS = ","; s +=$14; } END { print "Sum is:", s, "(",s/60,"minutes )"}'
echo
echo "aleph"
grep aleph Master.csv | awk '{ FS = ","; s +=$14; } END { print "Sum is:", s, "(",s/60,"minutes )"}'
echo
echo "aleph800"
grep aleph800 Master.csv | awk '{ FS = ","; s +=$14; } END { print "Sum is:", s, "(",s/60,"minutes )"}'
echo
echo "pstn-local"
grep pstn-local Master.csv | awk '{ FS = ","; s +=$14; } END { print "Sum is:", s, "(",s/60,"minutes )"}'
echo
echo "pstn"
grep pstn Master.csv | awk '{ FS = ","; s +=$14; } END { print "Sum is:", s, "(",s/60,"minutes )"}'
echo
echo "pstn800"
grep pstn800 Master.csv | awk '{ FS = ","; s +=$14; } END { print "Sum is:", s, "(",s/60,"minutes )"}'


Created by: bjohnson, Last modification: Sat 15 of Oct, 2005 (17:05 UTC) by JustRumours
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+