From 72e95b9c506c61d8d60eb8949d129bc496277e4a Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 2 Mar 2017 14:26:21 +0100 Subject: [systemstatus] Add lighttpd error log --- modules-available/systemstatus/page.inc.php | 32 ++++++++++++++++++++++ .../systemstatus/templates/_page.html | 9 ++++++ 2 files changed, 41 insertions(+) diff --git a/modules-available/systemstatus/page.inc.php b/modules-available/systemstatus/page.inc.php index 59a69267..b9fef0fd 100644 --- a/modules-available/systemstatus/page.inc.php +++ b/modules-available/systemstatus/page.inc.php @@ -269,6 +269,38 @@ class Page_SystemStatus extends Page echo '
', htmlspecialchars(substr($data, $start), ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'), '
'; } + protected function ajaxLighttpdLog() + { + $fh = @fopen('/var/log/lighttpd/error.log', 'r'); + if ($fh === false) { + echo 'Error opening log file'; + return; + } + fseek($fh, -6000, SEEK_END); + $data = fread($fh, 6000); + @fclose($fh); + if ($data === false) { + echo 'Error reading from log file'; + return; + } + // If we could read less, try the .1 file too + $amount = 6000 - strlen($data); + if ($amount > 100) { + $fh = @fopen('/var/log/lighttpd/error.log.1', 'r'); + if ($fh !== false) { + fseek($fh, -$amount, SEEK_END); + $data = fread($fh, $amount) . $data; + @fclose($fh); + } + } + if (strlen($data) < 5990) { + $start = 0; + } else { + $start = strpos($data, "\n") + 1; + } + echo '
', htmlspecialchars(substr($data, $start), ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'), '
'; + } + protected function ajaxLdadpLog() { $haveSysconfig = Module::isAvailable('sysconfig'); diff --git a/modules-available/systemstatus/templates/_page.html b/modules-available/systemstatus/templates/_page.html index 51aa5b55..0573a20c 100644 --- a/modules-available/systemstatus/templates/_page.html +++ b/modules-available/systemstatus/templates/_page.html @@ -95,6 +95,14 @@ +
+
+ {{lang_lighttpdLog}} +
+
+ +
+
netstat -tulpn @@ -124,6 +132,7 @@ $('#netstat').load('?do=SystemStatus&action=Netstat'); $('#pslist').load('?do=SystemStatus&action=PsList'); $('#ldadp-log').load('?do=SystemStatus&action=LdadpLog'); + $('#lighttpd-log').load('?do=SystemStatus&action=LighttpdLog'); }, 300); }, false); -- cgit v1.2.3-55-g7522