blob: 448ea46e00f40e9b579b7a3f79066eb3428e2f70 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001<?php
2include("include.php");
3?>
4<html>
5<center>
6<img src=logo.gif>
7<?php
8if (isset($_GET['sensor_name']))
9 $sensor_name = $_GET['sensor_name'];
10else
11 {
12 echo "<br>Please provide a sensor_name";
13 exit(1);
14 }
15
16if (isset($_GET['ip']))
17 $ip = $_GET['ip'];
18else
19 {
20 echo "<br>Please provide an ip address";
21 exit(1);
22 }
23
24echo "<h3>";
25if (strpos($ip, "/") === FALSE)
26 echo "$ip - ".gethostbyaddr($ip)."</h3>";
27else
28 echo "Total - $ip</h3>";
29
30$db = ConnectDb();
31
32if ($ip == "0.0.0.0/0")
33 {
34 $rxtable = "bd_rx_total_log";
35 $txtable = "bd_tx_total_log";
36 }
37else
38 {
39 $rxtable = "bd_rx_log";
40 $txtable = "bd_tx_log";
41 }
42
43$sql = "select rx.scale as rxscale, tx.scale as txscale, tx.total+rx.total as total, tx.total as sent,
44rx.total as received, tx.tcp+rx.tcp as tcp, tx.udp+rx.udp as udp,
45tx.icmp+rx.icmp as icmp, tx.http+rx.http as http,
46tx.p2p+rx.p2p as p2p, tx.ftp+rx.ftp as ftp
47from
48
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,
50sum(http) as http, sum(p2p) as p2p, sum(ftp) as ftp
51from sensors, $txtable
52where sensor_name = '$sensor_name'
53and sensors.sensor_id = ".$txtable.".sensor_id
54$sql_subnet
55group by ip) as tx,
56
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,
58sum(http) as http, sum(p2p) as p2p, sum(ftp) as ftp
59from sensors, $rxtable
60where sensor_name = '$sensor_name'
61and sensors.sensor_id = ".$rxtable.".sensor_id
62$sql_subnet
63group by ip) as rx
64
65where tx.ip = rx.ip;";
66//error_log($sql); printf('</center><tt>%s</tt><center>', $sql);
67$db = ConnectDb();
68$result = $db->query($sql);
69echo "<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>smtp<td>ftp";
70$r = $result->fetch();
71$db = NULL;
72echo "<tr><td>";
73if (strpos($ip, "/") === FALSE)
74 echo "$ip<td>".gethostbyaddr($ip);
75else
76 echo "Total<td>$ip";
77echo fmtb($r['total']).fmtb($r['sent']).fmtb($r['received']).
78 fmtb($r['tcp']).fmtb($r['udp']).fmtb($r['icmp']).fmtb($r['http']).
79 fmtb($r['p2p']).fmtb($r['ftp']);
80echo "</table></center>";
81
82echo "<center><h4>Daily</h4></center>";
83echo "Send:<br><img src=graph.php?ip=$ip&sensor_name=".$sensor_name."&table=$txtable&yscale=".(max($r['txscale'], $r['rxscale']))."><br>";
84echo "<img src=legend.gif><br>";
85echo "Receive:<br><img src=graph.php?ip=$ip&sensor_name=".$sensor_name."&table=$rxtable&yscale=".(max($r['txscale'], $r['rxscale']))."><br>";
86echo "<img src=legend.gif><br>";
87
88echo "<center><h4>Weekly</h4></center>";
89echo "Send:<br><img src=graph.php?interval=".INT_WEEKLY."&ip=$ip&sensor_name=$sensor_name&table=$txtable&yscale=".(max($r['txscale'], $r['rxscale']))."><br>";
90echo "<img src=legend.gif><br>";
91echo "Receive:<br><img src=graph.php?interval=".INT_WEEKLY."&ip=$ip&sensor_name=$sensor_name&table=$rxtable&yscale=".(max($r['txscale'], $r['rxscale']))."><br>";
92echo "<img src=legend.gif><br>";
93
94echo "<center><h4>Monthly</h4></center>";
95echo "Send:<br><img src=graph.php?interval=".INT_MONTHLY."&ip=$ip&sensor_name=$sensor_name&table=$txtable&yscale=".(max($r['txscale'], $r['rxscale']))."><br>";
96echo "<img src=legend.gif><br>";
97echo "Receive:<br><img src=graph.php?interval=".INT_MONTHLY."&ip=$ip&sensor_name=$sensor_name&table=$rxtable&yscale=".(max($r['txscale'], $r['rxscale']))."><br>";
98echo "<img src=legend.gif><br>";
99
100echo "<center><h4>Yearly</h4></center>";
101echo "Send:<br><img src=graph.php?interval=".INT_YEARLY."&ip=$ip&sensor_name=$sensor_name&table=$txtable&yscale=".(max($r['txscale'], $r['rxscale']))."><br>";
102echo "<img src=legend.gif><br>";
103echo "Receive:<br><img src=graph.php?interval=".INT_YEARLY."&ip=$ip&sensor_name=$sensor_name&table=$rxtable&yscale=".(max($r['txscale'], $r['rxscale']))."><br>";
104echo "<img src=legend.gif><br>";