diff --git a/api.php b/api.php index 87246f43..d9f22550 100644 --- a/api.php +++ b/api.php @@ -39,6 +39,10 @@ $data = array_merge($data, getForwardDestinations()); } + if (isset($_GET['getQuerySources'])) { + $data = array_merge($data, getQuerySources()); + } + echo json_encode($data); ?> diff --git a/data.php b/data.php index 2a7a128c..06ec811b 100644 --- a/data.php +++ b/data.php @@ -100,6 +100,23 @@ } + function getQuerySources() { + $log = readInLog(); + $dns_queries = getDnsQueries($log); + $sources = array(); + foreach($dns_queries as $query) { + $exploded = explode(" ", $query); + $ip = trim($exploded[count($exploded)-1]); + if (isset($sources[$ip])) { + $sources[$ip]++; + } + else { + $sources[$ip] = 1; + } + } + return $sources; + } + /******** Private Members ********/ function readInBlockList() { global $domains; diff --git a/index.php b/index.php index 7757531e..dbd66c17 100644 --- a/index.php +++ b/index.php @@ -95,6 +95,22 @@
+
+
+

Top Clients

+
+
+
+ +
+
+
+ +
+ +
+
+

Forward Destinations

@@ -202,6 +218,8 @@ updateQueryTypes(); + updateTopClientsChart(); + updateForwardDestinations(); updateTopLists(); @@ -235,6 +253,20 @@ ctx = document.getElementById("forwardDestinationChart").getContext("2d"); forwardDestinationChart = new Chart(ctx).Doughnut([],{ legendTemplate : "
    -legend\"><% for (var i=0; i
  • \"><%if(segments[i].label){%><%=segments[i].label%><%}%>
  • <%}%>
" }); + + var radarChartData = { + labels: [], + datasets: [ + { + label: "Top Clients", + fillColor: "rgba(220,220,220,0.5)", + strokeColor: "rgba(0, 166, 90,.8)", + data: [] + } + ] + }; + ctx = document.getElementById("topClientsChart").getContext("2d"); + topClientsChart = new Chart(ctx).Radar(radarChartData, {}); }); function updateSummaryData(runOnce) { @@ -278,6 +310,18 @@ }); } + function updateTopClientsChart() { + $.getJSON("api.php?getQuerySources", function(data) { + console.log(data); + $.each(data, function(key, value) { + topClientsChart.addData([value], key); + }); + + $('#top-clients .overlay').remove(); + //$('#queries-over-time').append(timeLineChart.generateLegend()); + }); + } + function updateQueryTypes() { $.getJSON("api.php?getQueryTypes", function(data) { var colors = [];