#!/bin/sh echo Content-type: text/html echo pmacct_begin="$(nvram get gw_pmacct_begin)" get_month() { echo $1 | \ awk ' { if ( $0 == 1 ) { print "Januar" } else if ( $0 == 2 ) { print "Februar" } else if ( $0 == 3 ) { print "März" } else if ( $0 == 4 ) { print "April" } else if ( $0 == 5 ) { print "Mai" } else if ( $0 == 6 ) { print "Juni" } else if ( $0 == 7 ) { print "Juli" } else if ( $0 == 8 ) { print "August" } else if ( $0 == 9 ) { print "September" } else if ( $0 == 10 ) { print "Oktober" } else if ( $0 == 11 ) { print "November" } else { print "Dezember" } } ' } cat< Freifunk.Net - Accounting
Home Kontakt
 

Inhalt

EOF if [ "$(nvram get gw_pmacct_if)" ] then if [ "`/etc/init.d/S70pmacct show | grep 'Connection refused'`" ] then echo "

Accounting eingeschaltet, aber noch nicht aktiviert (Neustart erforderlich).

" else if [ "`echo "$QUERY_STRING" | grep last_month`" ] then if [ -d "/backup" ] && [ -f "/backup/last_month.pmacct" ] then LAST_MONTH="`echo "garbage" | awk '{ print strftime("%m", systime() - 2592000 ) }'`" LAST_MONTH=$(get_month $LAST_MONTH) CURR_MONTH="`echo "garbage" | awk '{ print strftime("%m", systime() ) }'`" CURR_MONTH=$(get_month $CURR_MONTH) CURR_MONTH="

Die Erfassung des Datenvolumens erfolgt monatlich, das Accounting des aktuellen Monats ($CURR_MONTH) findet ihr hier.


" DATA_SOURCE="cat /backup/last_month.pmacct" cat<Accounting $LAST_MONTH$CURR_MONTH EOF else echo "

Keine Accounting-Informationen für den letzten Monat gefunden.

" fi else CURR_MONTH="`echo "garbage" | awk '{ print strftime("%m", systime() ) }'`" CURR_MONTH=$(get_month $CURR_MONTH) if [ -d "/backup" ] && [ -f "/backup/last_month.pmacct" ] then LAST_MONTH="`echo "garbage" | awk '{ print strftime("%m", systime() - 2592000 ) }'`" LAST_MONTH=$(get_month $LAST_MONTH) LAST_MONTH="

Die Erfassung des Datenvolumens erfolgt monatlich, das Accounting vom $LAST_MONTH findet ihr hier.


" else LAST_MONTH="
" fi DATA_SOURCE="/etc/init.d/S70pmacct cgi-bin" cat<Accounting $CURR_MONTH$LAST_MONTH
IPEmpfangenGesendetSumme
EOF fi if [ "$DATA_SOURCE" ] then $DATA_SOURCE | \ grep -Ev '(^(#[^#]|$)|total|DST)' | \ awk ' BEGIN { arr = "in" max = 0 sum_recv = 0 sum_send = 0 } { if ( $1 == "SRC" ) { arr = "out" next } else if ( $1 == "BACKUP_BEGIN" ) { arr = "in" next } else if ( $1 == "BACKUP_HALF" ) { arr = "out" next } else if ( $1 == "BACKUP_END" ) { next } else if ( $1 == "###" ) { arr = "ip2name" next } if ( arr=="in" ) { data_in[$1] += $3 sum_recv += $3 if ( length(data_in[$1]) > max ) { max = length(data_in[$1]) + 1 } } else if ( arr=="out" ) { data_out[$1] += $3 sum_send += $3 if ( length(data_out[$1]) > max ) { max = length(data_out[$1]) + 1 } } else { ip2name[$1] = $2 } } END { for ( ip in data_in ) { print_sort_field(ip) if ( ip2name[ip] ) { printf( "", ip, ip2name[ip], ip ) } else { printf( "", ip, ip ) } print "" delete(data_out[ip]) } for ( ip in data_out ) { print_sort_field(ip) if ( ip2name[ip] ) { printf( "", ip, ip2name[ip], ip ) } else { printf( "", ip, ip ) } print "" } print "" } function print_sort_field(ip) { if ( (ENVIRON["QUERY_STRING"] == "recv") || (ENVIRON["QUERY_STRING"] == "recv&last_month") ) { printf( "%0"max"d", data_in[ip] ) } else if ( (ENVIRON["QUERY_STRING"] == "send") || (ENVIRON["QUERY_STRING"] == "send&last_month") ) { printf( "%0"max"d", data_out[ip] ) } else if ( (ENVIRON["QUERY_STRING"] == "sum") || (ENVIRON["QUERY_STRING"] == "sum&last_month") ) { printf( "%0"max"d", data_in[ip]+data_out[ip] ) } else { split( ip, ip_arr, "." ) printf( "%03d.%03d.%03d.%03d", ip_arr[1], ip_arr[2], ip_arr[3], ip_arr[4] ) } } function calc_traf( bytes ) { unit = "Byte" divi = "1" if ( bytes > 5120 ) { unit = "KB" divi = "1024" if ( bytes > 5242880 ) { unit = "MB" divi = "1048576" if ( bytes > 5368709120 ) { unit = "GB" divi = "1073741824" } } } return int( bytes / divi ) " " unit }' | \ sort | \ awk -F '' '{ print $2 }' echo "
IPEmpfangenGesendetSumme
%s (%s)
%s ",calc_traf(data_in[ip]), "", calc_traf(data_out[ip]), "",calc_traf(data_in[ip]+data_out[ip]),"
%s (%s)
%s 0 Byte ", calc_traf(data_out[ip]), "",calc_traf(data_out[ip]),"
Total", calc_traf(sum_recv), "", calc_traf(sum_send), "", calc_traf(sum_send + sum_recv), "
" fi fi else echo "

Accounting deaktiviert

" fi cat<
Stand: 11.10.2005
Seitenanfang
EOF