2010-07-31 21:08:35 +00:00
< ? php
2018-02-20 14:57:56 +00:00
$datefrom = date ( 'YmdHis' , $vars [ 'from' ]);
$dateto = date ( 'YmdHis' , $vars [ 'to' ]);
2019-05-28 21:39:31 -07:00
$rates = getRates ( $vars [ 'id' ], $datefrom , $dateto , $vars [ 'dir' ]);
2018-02-20 14:57:56 +00:00
$ports = dbFetchRows ( 'SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D WHERE B.bill_id = ? AND P.port_id = B.port_id AND D.device_id = P.device_id' , array ( $vars [ 'id' ]));
2012-05-25 12:24:34 +00:00
// Generate a list of ports and then call the multi_bits grapher to generate from the list
2011-03-17 13:35:25 +00:00
$i = 0 ;
2015-07-10 13:36:21 +02:00
foreach ( $ports as $port ) {
2016-08-18 20:28:22 -05:00
$rrd_file = get_port_rrdfile_path ( $port [ 'hostname' ], $port [ 'port_id' ]);
2016-07-08 15:09:11 -05:00
if ( rrdtool_check_rrd_exists ( $rrd_file )) {
2016-01-21 22:04:33 +01:00
$rrd_list [ $i ][ 'filename' ] = $rrd_file ;
2015-07-10 13:36:21 +02:00
$rrd_list [ $i ][ 'descr' ] = $port [ 'ifDescr' ];
$i ++ ;
}
2010-07-31 21:08:35 +00:00
}
2015-07-10 13:36:21 +02:00
$units = 'bps' ;
$total_units = 'B' ;
$colours_in = 'greens' ;
$multiplier = '8' ;
2010-07-31 21:08:35 +00:00
$colours_out = 'blues' ;
$nototal = 1 ;
2015-07-10 13:36:21 +02:00
$ds_in = 'INOCTETS' ;
$ds_out = 'OUTOCTETS' ;
// print_r($rates);
if ( $bill [ 'bill_type' ] == 'cdr' ) {
$custom_graph = " COMMENT:' \\ r' " ;
$custom_graph .= ' HRULE:' . $rates [ 'rate_95th' ] . " #cc0000:'95th %ile \ : " . formatRates ( $rates [ 'rate_95th' ]) . ' (' . $rates [ 'dir_95th' ] . ') (CDR\: ' . formatRates ( $bill [ 'bill_cdr' ]) . " )' " ;
$custom_graph .= ' HRULE:' . ( $rates [ 'rate_95th' ] * - 1 ) . '#cc0000' ;
2016-08-18 20:28:22 -05:00
} elseif ( $bill [ 'bill_type' ] == 'quota' ) {
2015-07-10 13:36:21 +02:00
$custom_graph = " COMMENT:' \\ r' " ;
$custom_graph .= ' HRULE:' . $rates [ 'rate_average' ] . " #cc0000:'Usage \ : " . format_bytes_billing ( $rates [ 'total_data' ]) . ' (' . formatRates ( $rates [ 'rate_average' ]) . " )' " ;
$custom_graph .= ' HRULE:' . ( $rates [ 'rate_average' ] * - 1 ) . '#cc0000' ;
2011-03-23 10:25:42 +00:00
}
2019-04-11 23:26:42 -05:00
require 'includes/html/graphs/generic_multi_bits_separated.inc.php' ;