Merge pull request #433 from pi-hole/new/tail-FTLlog

Add tail pihole-FTL.log
This commit is contained in:
DL6ER
2017-03-16 23:23:03 +01:00
committed by GitHub
4 changed files with 85 additions and 1 deletions
+46
View File
@@ -0,0 +1,46 @@
/* Pi-hole: A black hole for Internet advertisements
* (c) 2017 Pi-hole, LLC (https://pi-hole.net)
* Network-wide ad blocking via your own hardware.
*
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. */
var offset, timer, pre, scrolling = true;
// Check every 200msec for fresh data
var interval = 200;
// Function that asks the API for new data
function reloadData(){
clearTimeout(timer);
$.getJSON("scripts/pi-hole/php/tailLog.php?FTL&offset="+offset, function (data)
{
offset = data["offset"];
pre.append(data["lines"]);
});
if(scrolling)
{
window.scrollTo(0,document.body.scrollHeight);
}
timer = setTimeout(reloadData, interval);
}
$(function(){
// Get offset at first loading of page
$.getJSON("scripts/pi-hole/php/tailLog.php?FTL", function (data)
{
offset = data["offset"];
});
pre = $("#output");
// Trigger function that looks for new data
reloadData();
});
$("#chk1").click(function() {
$("#chk2").prop("checked",this.checked);
scrolling = this.checked;
});
$("#chk2").click(function() {
$("#chk1").prop("checked",this.checked);
scrolling = this.checked;
});
+6
View File
@@ -469,6 +469,12 @@
<i class="fa fa-list-ul"></i> <span>Tail pihole.log</span>
</a>
</li>
<!-- Tail pihole-FTL.log -->
<li<?php if($scriptname === "taillog-FTL.php"){ ?> class="active"<?php } ?>>
<a href="taillog-FTL.php">
<i class="fa fa-list-ul"></i> <span>Tail pihole-FTL.log</span>
</a>
</li>
<!-- Generate debug log -->
<li<?php if($scriptname === "debug.php"){ ?> class="active"<?php } ?>>
<a href="debug.php">
+9 -1
View File
@@ -12,7 +12,15 @@ if(!$auth) die("Not authorized");
// Not using SplFileObject here, since direct
// usage of f-streams will be much faster for
// files as large as the pihole.log
$file = fopen("/var/log/pihole.log","r");
if(isset($_GET["FTL"]))
{
$file = fopen("/var/log/pihole-FTL.log","r");
}
else
{
$file = fopen("/var/log/pihole.log","r");
}
if(isset($_GET["offset"]))
{
$offset = intval($_GET['offset']);
+24
View File
@@ -0,0 +1,24 @@
<!-- Pi-hole: A black hole for Internet advertisements
* (c) 2017 Pi-hole, LLC (https://pi-hole.net)
* Network-wide ad blocking via your own hardware.
*
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. -->
<?php
require "scripts/pi-hole/php/header.php";
?>
<!-- Title -->
<div class="page-header">
<h1>Output the last lines of the pihole-FTL.log file (live)</h1>
</div>
<div class="checkbox"><label><input type="checkbox" name="active" checked id="chk1"> Automatic scrolling on update</label></div>
<pre id="output" style="width: 100%; height: 100%;"></pre>
<div class="checkbox"><label><input type="checkbox" name="active" checked id="chk2"> Automatic scrolling on update</label></div>
<?php
require "scripts/pi-hole/php/footer.php";
?>
<script src="scripts/pi-hole/js/taillog-FTL.js"></script>