2 include("include.php");
8 if (isset($_GET['sensor_name']))
9 $sensor_name = $_GET['sensor_name'];
12 echo "<br>Please provide a sensor_name";
16 if (isset($_GET['ip']))
20 echo "<br>Please provide an ip address";
25 if (strpos($ip, "/") === FALSE)
26 echo "$ip - ".gethostbyaddr($ip)."</h3>";
28 echo "Total - $ip</h3>";
32 if ($ip == "0.0.0.0/0")
34 $rxtable = "bd_rx_total_log";
35 $txtable = "bd_tx_total_log";
39 $rxtable = "bd_rx_log";
40 $txtable = "bd_tx_log";
43 $sql = "select rx.scale as rxscale, tx.scale as txscale, tx.total+rx.total as total, tx.total as sent,
44 rx.total as received, tx.tcp+rx.tcp as tcp, tx.udp+rx.udp as udp,
45 tx.icmp+rx.icmp as icmp, tx.http+rx.http as http,
46 tx.p2p+rx.p2p as p2p, tx.ftp+rx.ftp as ftp
49 (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,
50 sum(http) as http, sum(p2p) as p2p, sum(ftp) as ftp
51 from sensors, $txtable
52 where sensor_name = '$sensor_name'
53 and sensors.sensor_id = ".$txtable.".sensor_id
57 (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,
58 sum(http) as http, sum(p2p) as p2p, sum(ftp) as ftp
59 from sensors, $rxtable
60 where sensor_name = '$sensor_name'
61 and sensors.sensor_id = ".$rxtable.".sensor_id
65 where tx.ip = rx.ip;";
66 //echo "</center><pre>$sql</pre><center>";exit(0);
67 $result = pg_query($sql);
68 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";
69 $r = pg_fetch_array($result);
71 if (strpos($ip, "/") === FALSE)
72 echo "$ip<td>".gethostbyaddr($ip);
75 echo fmtb($r['total']).fmtb($r['sent']).fmtb($r['received']).
76 fmtb($r['tcp']).fmtb($r['udp']).fmtb($r['icmp']).fmtb($r['http']).
77 fmtb($r['p2p']).fmtb($r['ftp']);
78 echo "</table></center>";
80 echo "<center><h4>Daily</h4></center>";
81 echo "Send:<br><img src=graph.php?ip=$ip&sensor_name=".$sensor_name."&table=$txtable&yscale=".(max($r['txscale'], $r['rxscale']))."><br>";
82 echo "<img src=legend.gif><br>";
83 echo "Receive:<br><img src=graph.php?ip=$ip&sensor_name=".$sensor_name."&table=$rxtable&yscale=".(max($r['txscale'], $r['rxscale']))."><br>";
84 echo "<img src=legend.gif><br>";
86 echo "<center><h4>Weekly</h4></center>";
87 echo "Send:<br><img src=graph.php?interval=".INT_WEEKLY."&ip=$ip&sensor_name=$sensor_name&table=$txtable&yscale=".(max($r['txscale'], $r['rxscale']))."><br>";
88 echo "<img src=legend.gif><br>";
89 echo "Receive:<br><img src=graph.php?interval=".INT_WEEKLY."&ip=$ip&sensor_name=$sensor_name&table=$rxtable&yscale=".(max($r['txscale'], $r['rxscale']))."><br>";
90 echo "<img src=legend.gif><br>";
92 echo "<center><h4>Monthly</h4></center>";
93 echo "Send:<br><img src=graph.php?interval=".INT_MONTHLY."&ip=$ip&sensor_name=$sensor_name&table=$txtable&yscale=".(max($r['txscale'], $r['rxscale']))."><br>";
94 echo "<img src=legend.gif><br>";
95 echo "Receive:<br><img src=graph.php?interval=".INT_MONTHLY."&ip=$ip&sensor_name=$sensor_name&table=$rxtable&yscale=".(max($r['txscale'], $r['rxscale']))."><br>";
96 echo "<img src=legend.gif><br>";
98 echo "<center><h4>Yearly</h4></center>";
99 echo "Send:<br><img src=graph.php?interval=".INT_YEARLY."&ip=$ip&sensor_name=$sensor_name&table=$txtable&yscale=".(max($r['txscale'], $r['rxscale']))."><br>";
100 echo "<img src=legend.gif><br>";
101 echo "Receive:<br><img src=graph.php?interval=".INT_YEARLY."&ip=$ip&sensor_name=$sensor_name&table=$rxtable&yscale=".(max($r['txscale'], $r['rxscale']))."><br>";
102 echo "<img src=legend.gif><br>";