1
0

details.php 4.2 KB

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