Пример #1
0
echo "<h3>";
if (strpos($ip, "/") === FALSE) {
    echo "{$ip} - " . gethostbyaddr($ip) . "</h3>";
} else {
    echo "Total - {$ip}</h3>";
}
$db = ConnectDb();
if ($ip == "0.0.0.0/0") {
    $rxtable = "bd_rx_total_log";
    $txtable = "bd_tx_total_log";
} else {
    $rxtable = "bd_rx_log";
    $txtable = "bd_tx_log";
}
$sql = "select rx.scale as rxscale, tx.scale as txscale, tx.total+rx.total as total, tx.total as sent,\nrx.total as received, tx.tcp+rx.tcp as tcp, tx.udp+rx.udp as udp,\ntx.icmp+rx.icmp as icmp, tx.http+rx.http as http,\ntx.p2p+rx.p2p as p2p, tx.ftp+rx.ftp as ftp\nfrom\n                                                                                                                             \n(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,\nsum(http) as http, sum(p2p) as p2p, sum(ftp) as ftp\nfrom sensors, {$txtable}\nwhere sensors.sensor_id = '{$sensor_id}'\nand sensors.sensor_id = " . $txtable . ".sensor_id\nand ip <<= '{$ip}'\ngroup by ip) as tx,\n                                                                                                                             \n(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,\nsum(http) as http, sum(p2p) as p2p, sum(ftp) as ftp\nfrom sensors, {$rxtable}\nwhere sensors.sensor_id = '{$sensor_id}'\nand sensors.sensor_id = " . $rxtable . ".sensor_id\nand ip <<= '{$ip}'\ngroup by ip) as rx\n                                                                                                                             \nwhere tx.ip = rx.ip;";
//echo "</center><pre>$sql</pre><center>";exit(0);
$result = pg_query($sql);
echo "<div class='table-responsive'><table class='table table-hover table-bordered' id='xtable' style='font-size:13px;'>\n\t\t<thead>\n\t\t\t<tr>\n\t\t\t\t<th title='click for sorting' onclick='sortTable(0);'>IP</th>\n\t\t\t\t<th title='click for sorting' onclick='sortTable(1);'>Name</th>\n\t\t\t\t<th title='click for sorting' onclick='sortTable(2);'>Total</th>\n\t\t\t\t<th title='click for sorting' onclick='sortTable(3);'>Sent</th>\n\t\t\t\t<th title='click for sorting' onclick='sortTable(4);'>Received</th>\n\t\t\t\t<th title='click for sorting' onclick='sortTable(5);'>tcp</th>\n\t\t\t\t<th title='click for sorting' onclick='sortTable(6);'>udp</th>\n\t\t\t\t<th title='click for sorting' onclick='sortTable(7);'>icmp</th>\n\t\t\t\t<th title='click for sorting' onclick='sortTable(8);'>http</th>\n\t\t\t\t<th title='click for sorting' onclick='sortTable(9);'>p2p</th>\n\t\t\t\t<th title='click for sorting' onclick='sortTable(10);'>ftp</th>\n\t\t\t</tr>\n\t\t</thead><tbody><tr><td>";
$r = pg_fetch_array($result);
if (strpos($ip, "/") === FALSE) {
    echo "{$ip}</td><td>" . gethostbyaddr($ip) . '</td>';
} else {
    echo "Total<td>{$ip}</td>";
}
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']);
echo "</tbody></table>";
echo "<div class='panel panel-default'><div class='panel-heading'><h3 class='panel-title'>Daily</h3></div>\n\t    <div class='panel-body'>\n\t    \t<div class='well'>\n\t\t    \tSend:<br><img alt='graph' src='graph.php?ip={$ip}&amp;sensor_id=" . $sensor_id . "&amp;table={$txtable}&amp;yscale=" . max($r['txscale'], $r['rxscale']) . "'><br>\n\t\t\t\t<img alt='' src=legend.gif><br>\n\t\t\t</div>\n\t\t\t<div class='well'>\n\t\t\t\tReceive:<br><img alt='graph' src='graph.php?ip={$ip}&amp;sensor_id=" . $sensor_id . "&amp;table={$rxtable}&amp;yscale=" . max($r['txscale'], $r['rxscale']) . "'>\n\t\t\t\t<img alt='' src=legend.gif><br>\n\t\t\t</div>\n\t\t</div>\n\t</div>";
echo "<div class='panel panel-default'><div class='panel-heading'><h3 class='panel-title'>Weekly</h3></div>\n\t    <div class='panel-body'>\n\t    \t<div class='well'>\n\t\t    \tSend:<br><img alt='graph' src='graph.php?interval=" . INT_WEEKLY . "&amp;ip={$ip}&amp;sensor_id={$sensor_id}&amp;table={$txtable}&amp;yscale=" . max($r['txscale'], $r['rxscale']) . "'><br>\n\t\t\t\t<img alt='' src=legend.gif><br>\n\t\t\t</div>\n\t\t\t<div class='well'>\n\t\t\t\tReceive:<br><img alt='graph' src='graph.php?interval=" . INT_WEEKLY . "&amp;ip={$ip}&amp;sensor_id={$sensor_id}&amp;table={$rxtable}&amp;yscale=" . max($r['txscale'], $r['rxscale']) . "'>\n\t\t\t\t<img alt='' src=legend.gif><br>\n\t\t\t</div>\n\t\t</div>\n\t</div>";
echo "<div class='panel panel-default'><div class='panel-heading'><h3 class='panel-title'>Monthly</h3></div>\n\t    <div class='panel-body'>\n\t    \t<div class='well'>\n\t\t    \tSend:<br><img alt='graph' src='graph.php?interval=" . INT_MONTHLY . "&amp;ip={$ip}&amp;sensor_id={$sensor_id}&amp;table={$txtable}&amp;yscale=" . max($r['txscale'], $r['rxscale']) . "'><br>\n\t\t\t\t<img alt='' src=legend.gif><br>\n\t\t\t</div>\n\t\t\t<div class='well'>\n\t\t\t\tReceive:<br><img alt='graph' src='graph.php?interval=" . INT_MONTHLY . "&amp;ip={$ip}&amp;sensor_id={$sensor_id}&amp;table={$rxtable}&amp;yscale=" . max($r['txscale'], $r['rxscale']) . "'>\n\t\t\t\t<img alt='' src=legend.gif><br>\n\t\t\t</div>\n\t\t</div>\n\t</div>";
echo "<div class='panel panel-default'><div class='panel-heading'><h3 class='panel-title'>Yearly</h3></div>\n\t    <div class='panel-body'>\n\t    \t<div class='well'>\n\t\t    \tSend:<br><img alt='graph' src='graph.php?interval=" . INT_YEARLY . "&amp;ip={$ip}&amp;sensor_id={$sensor_id}&amp;table={$txtable}&amp;yscale=" . max($r['txscale'], $r['rxscale']) . "'><br>\n\t\t\t\t<img alt='' src=legend.gif><br>\n\t\t\t</div>\n\t\t\t<div class='well'>\n\t\t\t\tReceive:<br><img alt='graph' src='graph.php?interval=" . INT_YEARLY . "&amp;ip={$ip}&amp;sensor_id={$sensor_id}&amp;table={$rxtable}&amp;yscale=" . max($r['txscale'], $r['rxscale']) . "'>\n\t\t\t\t<img alt='' src=legend.gif><br>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n\n</div>";
include 'footer.php';
Пример #2
0
and ip <<= '$ip'
group by ip) as rx
                                                                                                                             
where tx.ip = rx.ip;";
//echo "</center><pre>$sql</pre><center>";exit(0);
$result = pg_query($sql);
echo "<table width=100% border=1 cellspacing=0><tr><td>Ip<td>Name<td>Total<td>Sent<td>Received<td>tcp<td>udp<td>icmp<td>http<td>p2p<td>ftp";
$r = pg_fetch_array($result);
echo "<tr><td>";
if (strpos($ip, "/") === FALSE)
	echo "$ip<td>".gethostbyaddr($ip);
else
	echo "Total<td>$ip";
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']);
echo "</table></center>";

echo "<center><h4>Daily</h4></center>";
echo "Send:<br><img src=graph.php?ip=$ip&sensor_id=".$sensor_id."&table=$txtable&yscale=".(max($r['txscale'], $r['rxscale']))."><br>";
echo "<img src=legend.gif><br>";
echo "Receive:<br><img src=graph.php?ip=$ip&sensor_id=".$sensor_id."&table=$rxtable&yscale=".(max($r['txscale'], $r['rxscale']))."><br>";
echo "<img src=legend.gif><br>";

echo "<center><h4>Weekly</h4></center>";
echo "Send:<br><img src=graph.php?interval=".INT_WEEKLY."&ip=$ip&sensor_id=$sensor_id&table=$txtable&yscale=".(max($r['txscale'], $r['rxscale']))."><br>";
echo "<img src=legend.gif><br>";
echo "Receive:<br><img src=graph.php?interval=".INT_WEEKLY."&ip=$ip&sensor_id=$sensor_id&table=$rxtable&yscale=".(max($r['txscale'], $r['rxscale']))."><br>";
echo "<img src=legend.gif><br>";

echo "<center><h4>Monthly</h4></center>";
Пример #3
0
echo "\n";

// Output Other Lines
for($Counter=0; $Counter < pg_num_rows($result) && $Counter < $limit; $Counter++)
	{
	$r = pg_fetch_array($result, $Counter);
	if ($graphs == "")
		$url = "<a href=# onclick=\"window.open('details.php?sensor_id=$sensor_id&ip=".$r['ip']."','_blank', 'scrollbars=yes,width=930,height=768,resizable=yes,left=20,top=20')\">";
	else
		$url = "<a href=#".$r['ip'].">";
	echo "<tr><td>".$url;
	echo $r['ip']."<td>".gethostbyaddr($r['ip']);
	echo "</a>";
	echo fmtb($r['total']).fmtb($r['sent']).fmtb($r['received']).
		fmtb($r['tcp']).fmtb($r['udp']).fmtb($r['icmp']).fmtb($r['http']).fmtb($r['mail']).
		fmtb($r['p2p']).fmtb($r['ftp'])."\n";
	}
echo "</table></center>";

// Stop here
if ($graphs == "")
	exit();

// 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);
	}