>
Subnet Filter:">
Top $limit - $sensor_name"; else echo "

All Records - $sensor_name

"; // Sqlize the incomming variables if (isset($subnet)) $sql_subnet = "and ip <<= '$subnet'"; // Sql Statement $sql = "select tx.ip, rx.scale as rxscale, tx.scale as txscale, tx.total+rx.total as total, tx.total as sent, rx.total as received, tx.tcp+rx.tcp as tcp, tx.udp+rx.udp as udp, tx.icmp+rx.icmp as icmp, tx.http+rx.http as http, tx.p2p+rx.p2p as p2p, tx.ftp+rx.ftp as ftp from (SELECT ip, max(total/sample_duration)*8 as scale, sum(total) as total, sum(tcp) as tcp, sum(udp) as udp, sum(icmp) as icmp, sum(http) as http, sum(p2p) as p2p, sum(ftp) as ftp from sensors, bd_tx_log where sensor_name = '$sensor_name' and sensors.sensor_id = bd_tx_log.sensor_id $sql_subnet and timestamp > $timestamp::abstime and timestamp < ".($timestamp+$interval)."::abstime group by ip) as tx, (SELECT ip, max(total/sample_duration)*8 as scale, sum(total) as total, sum(tcp) as tcp, sum(udp) as udp, sum(icmp) as icmp, sum(http) as http, sum(p2p) as p2p, sum(ftp) as ftp from sensors, bd_rx_log where sensor_name = '$sensor_name' and sensors.sensor_id = bd_rx_log.sensor_id $sql_subnet and timestamp > $timestamp::abstime and timestamp < ".($timestamp+$interval)."::abstime group by ip) as rx where tx.ip = rx.ip order by total desc;"; //echo "
$sql
"; exit(0); pg_query("SET sort_mem TO 30000;"); $result = pg_query($sql); pg_query("set sort_mem to default;"); if ($limit == "all") $limit = pg_num_rows($result); echo "
IpNameTotalSentReceivedtcpudpicmphttpp2pftp"; if (!isset($subnet)) // Set this now for total graphs $subnet = "0.0.0.0/0"; // Output Total Line echo "
Total$subnet"; foreach (array("total", "sent", "received", "tcp", "udp", "icmp", "http", "p2p", "ftp") as $key) { for($Counter=0, $Total = 0; $Counter < pg_num_rows($result); $Counter++) { $r = pg_fetch_array($result, $Counter); $Total += $r[$key]; } echo fmtb($Total); } echo "\n"; // Output Other Lines for($Counter=0; $Counter < pg_num_rows($result) && $Counter < $limit; $Counter++) { $r = pg_fetch_array($result, $Counter); echo "
"; echo $r['ip']."".gethostbyaddr($r['ip']); echo ""; echo fmtb($r['total']).fmtb($r['sent']).fmtb($r['received']). fmtb($r['tcp']).fmtb($r['udp']).fmtb($r['icmp']).fmtb($r['http']). fmtb($r['p2p']).fmtb($r['ftp'])."\n"; } echo "
"; // Output Total Graph for($Counter=0, $Total = 0; $Counter < pg_num_rows($result); $Counter++) { $r = pg_fetch_array($result, $Counter); $scale = max($r['txscale'], $scale); $scale = max($r['rxscale'], $scale); } if ($subnet == "0.0.0.0/0") $total_table = "bd_tx_total_log"; else $total_table = "bd_tx_log"; echo "

"; echo "Total - Total of $subnet

"; echo ""; echo "Send:

"; echo "
\n"; if ($subnet == "0.0.0.0/0") $total_table = "bd_rx_total_log"; else $total_table = "bd_rx_log"; echo "Receive:

"; echo "
\n"; // Output Other Graphs for($Counter=0; $Counter < pg_num_rows($result) && $Counter < $limit; $Counter++) { $r = pg_fetch_array($result, $Counter); echo "

"; if ($r['ip'] == "0.0.0.0") echo "Total - Total of all subnets

"; else echo $r['ip']." - ".gethostbyaddr($r['ip']).""; echo ""; echo "Send:

"; echo "
\n"; echo "Receive:

"; echo "
\n"; } include('footer.php');