Commit b2af67a9 authored by Franco Fichtner's avatar Franco Fichtner

logs: improve all things logging for #397

parent a3e5de62
...@@ -768,20 +768,14 @@ function system_syslogd_start() ...@@ -768,20 +768,14 @@ function system_syslogd_start()
$syslogcfg = $config['syslog']; $syslogcfg = $config['syslog'];
if (file_exists("/var/run/booting")) if (file_exists('/var/run/booting')) {
echo gettext("Starting syslog..."); echo gettext('Starting syslog...');
// Which logging type are we using this week??
if (isset($config['system']['disablesyslogclog'])) {
$log_directive = "";
$log_create_directive = "/usr/bin/touch ";
$log_size = "";
} else { // Defaults to CLOG
$log_directive = "%";
$log_size = isset($config['syslog']['logfilesize']) ? $config['syslog']['logfilesize'] : "10240";
$log_create_directive = "/usr/local/sbin/clog -i -s ";
} }
$log_directive = '%';
$log_size = isset($config['syslog']['logfilesize']) ? $config['syslog']['logfilesize'] : '511488';
$log_create_directive = '/usr/local/sbin/clog -i -s ';
$syslogd_extra = ""; $syslogd_extra = "";
if (isset($syslogcfg)) { if (isset($syslogcfg)) {
$separatelogfacilities = array('ntp','ntpd','ntpdate','charon','openvpn','pptps','poes','l2tps','relayd','hostapd','dnsmasq','filterdns','unbound','dhcpd','dhcrelay','dhclient','dhcp6c','apinger','radvd','routed','olsrd','zebra','ospfd','bgpd','miniupnpd','filterlog'); $separatelogfacilities = array('ntp','ntpd','ntpdate','charon','openvpn','pptps','poes','l2tps','relayd','hostapd','dnsmasq','filterdns','unbound','dhcpd','dhcrelay','dhclient','dhcp6c','apinger','radvd','routed','olsrd','zebra','ospfd','bgpd','miniupnpd','filterlog');
......
...@@ -165,7 +165,6 @@ rm -rf /tmp/* ...@@ -165,7 +165,6 @@ rm -rf /tmp/*
chmod 1777 /tmp chmod 1777 /tmp
echo -n "." echo -n "."
DISABLESYSLOGCLOG=`/usr/bin/grep -c disablesyslogclog /conf/config.xml`
LOG_FILES="system filter dhcpd vpn pptps poes l2tps openvpn portalauth ipsec ppps relayd wireless lighttpd ntpd gateways resolver routing" LOG_FILES="system filter dhcpd vpn pptps poes l2tps openvpn portalauth ipsec ppps relayd wireless lighttpd ntpd gateways resolver routing"
DEFAULT_LOG_FILE_SIZE=`/usr/local/bin/xmllint --xpath 'string(//opnsense/syslog/logfilesize)' /conf/config.xml` DEFAULT_LOG_FILE_SIZE=`/usr/local/bin/xmllint --xpath 'string(//opnsense/syslog/logfilesize)' /conf/config.xml`
...@@ -174,13 +173,9 @@ if [ ! ${DEFAULT_LOG_FILE_SIZE} ]; then ...@@ -174,13 +173,9 @@ if [ ! ${DEFAULT_LOG_FILE_SIZE} ]; then
fi fi
for logfile in $LOG_FILES; do for logfile in $LOG_FILES; do
if [ "$DISABLESYSLOGCLOG" -gt "0" ]; then
touch /var/log/$logfile.log
else
if [ ! -f /var/log/$logfile.log ]; then if [ ! -f /var/log/$logfile.log ]; then
clog -i -s ${DEFAULT_LOG_FILE_SIZE} /var/log/$logfile.log clog -i -s ${DEFAULT_LOG_FILE_SIZE} /var/log/$logfile.log
fi fi
fi
chmod 0600 /var/log/$logfile.log chmod 0600 /var/log/$logfile.log
done done
......
...@@ -41,7 +41,7 @@ if (empty($config['syslog']['nentries'])) { ...@@ -41,7 +41,7 @@ if (empty($config['syslog']['nentries'])) {
} }
if (isset($_POST['clear'])) { if (isset($_POST['clear'])) {
clear_log_file($system_logfile); clear_clog($system_logfile);
} }
if ($_GET['filtertext']) { if ($_GET['filtertext']) {
......
...@@ -41,7 +41,7 @@ if (empty($config['syslog']['nentries'])) { ...@@ -41,7 +41,7 @@ if (empty($config['syslog']['nentries'])) {
} }
if ($_POST['clear']) { if ($_POST['clear']) {
clear_log_file($portal_logfile); clear_clog($portal_logfile);
} }
$pgtitle = array(gettext("Status"),gettext("System logs"),gettext("Portal Auth")); $pgtitle = array(gettext("Status"),gettext("System logs"),gettext("Portal Auth"));
......
...@@ -42,7 +42,7 @@ if (empty($config['syslog']['nentries'])) { ...@@ -42,7 +42,7 @@ if (empty($config['syslog']['nentries'])) {
} }
if ($_POST['clear']) { if ($_POST['clear']) {
clear_log_file($dhcpd_logfile); clear_clog($dhcpd_logfile);
killbyname("dhcpd"); killbyname("dhcpd");
services_dhcpd_configure(); services_dhcpd_configure();
} }
......
...@@ -586,9 +586,8 @@ if (isset($filterlogentries_qty) && $filterlogentries_qty != null) { ...@@ -586,9 +586,8 @@ if (isset($filterlogentries_qty) && $filterlogentries_qty != null) {
$nentries = $filterlogentries_qty; $nentries = $filterlogentries_qty;
} }
if (isset($_POST['clear'])) { if (isset($_POST['clear'])) {
clear_log_file($filter_logfile); clear_clog($filter_logfile);
} }
$pgtitle = array(gettext("Status"),gettext("System logs"),gettext("Firewall")); $pgtitle = array(gettext("Status"),gettext("System logs"),gettext("Firewall"));
...@@ -599,7 +598,6 @@ include("head.inc"); ...@@ -599,7 +598,6 @@ include("head.inc");
<script src="/javascript/filter_log.js" type="text/javascript"></script> <script src="/javascript/filter_log.js" type="text/javascript"></script>
<body> <body>
<?php include("fbegin.inc"); ?> <?php include("fbegin.inc"); ?>
......
...@@ -42,7 +42,7 @@ $nentries = 50; ...@@ -42,7 +42,7 @@ $nentries = 50;
handle_ajax($nentries, $nentries + 20); handle_ajax($nentries, $nentries + 20);
if (isset($_POST['clear'])) { if (isset($_POST['clear'])) {
clear_log_file($filter_logfile); clear_clog($filter_logfile);
} }
$filterlog = conv_log_filter($filter_logfile, $nentries, $nentries + 100); $filterlog = conv_log_filter($filter_logfile, $nentries, $nentries + 100);
......
<?php <?php
/* /*
Copyright (C) 2014-2015 Deciso B.V. - J. Schellevis Copyright (C) 2014-2015 Deciso B.V. - J. Schellevis
Copyright (C) 2009 Jim Pingle (jpingle@gmail.com) Copyright (C) 2009 Jim Pingle (jpingle@gmail.com)
......
...@@ -43,7 +43,7 @@ if (empty($config['syslog']['nentries'])) { ...@@ -43,7 +43,7 @@ if (empty($config['syslog']['nentries'])) {
} }
if ($_POST['clear']) { if ($_POST['clear']) {
clear_log_file($system_logfile); clear_clog($system_logfile);
} }
if ($_GET['filtertext']) { if ($_GET['filtertext']) {
......
...@@ -34,25 +34,6 @@ require_once("services.inc"); ...@@ -34,25 +34,6 @@ require_once("services.inc");
require_once("system.inc"); require_once("system.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
function return_clog($logfile, $tail, $withorig = true, $grepfor = "", $grepinvert = "", $grepreverse = false) {
global $g, $config;
$sor = (isset($config['syslog']['reverse']) || $grepreverse) ? "-r" : "";
$logarr = "";
$grepline = " ";
if(is_array($grepfor))
$grepline .= " | /usr/bin/egrep " . escapeshellarg(implode("|", $grepfor));
if(is_array($grepinvert))
$grepline .= " | /usr/bin/egrep -v " . escapeshellarg(implode("|", $grepinvert));
if($config['system']['disablesyslogclog']) {
exec("cat " . escapeshellarg($logfile) . "{$grepline} | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
} else {
exec("/usr/local/sbin/clog " . escapeshellarg($logfile) . "{$grepline}| grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
}
return($logarr);
}
$ipsec_logfile = '/var/log/ipsec.log'; $ipsec_logfile = '/var/log/ipsec.log';
if (empty($config['syslog']['nentries'])) { if (empty($config['syslog']['nentries'])) {
...@@ -62,18 +43,15 @@ if (empty($config['syslog']['nentries'])) { ...@@ -62,18 +43,15 @@ if (empty($config['syslog']['nentries'])) {
} }
if ($_POST['clear']) { if ($_POST['clear']) {
clear_log_file($ipsec_logfile); clear_clog($ipsec_logfile);
} }
$ipsec_logarr = return_clog($ipsec_logfile, $nentries);
$pgtitle = array(gettext("Status"),gettext("System logs"),gettext("IPsec VPN")); $pgtitle = array(gettext("Status"),gettext("System logs"),gettext("IPsec VPN"));
$shortcut_section = "ipsec"; $shortcut_section = "ipsec";
include("head.inc"); include("head.inc");
?> ?>
<body> <body>
<?php include("fbegin.inc"); ?> <?php include("fbegin.inc"); ?>
...@@ -96,17 +74,7 @@ include("head.inc"); ...@@ -96,17 +74,7 @@ include("head.inc");
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-striped table-sort"> <table class="table table-striped table-sort">
<?php <?php dump_clog($ipsec_logfile, $nentries); ?>
foreach($ipsec_logarr as $logent){
$logent = htmlspecialchars($logent);
$logent = preg_split("/\s+/", $logent, 6);
echo "<tr valign=\"top\">\n";
$entry_date_time = htmlspecialchars(join(" ", array_slice($logent, 0, 3)));
echo "<td class=\"listlr nowrap\">" . $entry_date_time . "</td>\n";
echo "<td class=\"listr\">" . $logent[4] . " " . $logent[5] . "</td>\n";
echo "</tr>\n";
}
?>
</table> </table>
</div> </div>
......
...@@ -43,7 +43,7 @@ if (empty($config['syslog']['nentries'])) { ...@@ -43,7 +43,7 @@ if (empty($config['syslog']['nentries'])) {
} }
if ($_POST['clear']) { if ($_POST['clear']) {
clear_log_file($ntpd_logfile); clear_clog($ntpd_logfile);
} }
$pgtitle = array(gettext("Status"),gettext("System logs"),gettext("NTP")); $pgtitle = array(gettext("Status"),gettext("System logs"),gettext("NTP"));
......
...@@ -46,7 +46,7 @@ if (empty($config['syslog']['nentries'])) { ...@@ -46,7 +46,7 @@ if (empty($config['syslog']['nentries'])) {
} }
if ($_POST['clear']) { if ($_POST['clear']) {
clear_log_file($openvpn_logfile); clear_clog($openvpn_logfile);
} }
include("head.inc"); include("head.inc");
......
<?php <?php
/* /*
Copyright (C) 2014 Deciso B.V. Copyright (C) 2014 Deciso B.V.
All rights reserved. All rights reserved.
......
...@@ -41,7 +41,7 @@ if (empty($config['syslog']['nentries'])) { ...@@ -41,7 +41,7 @@ if (empty($config['syslog']['nentries'])) {
} }
if ($_POST['clear']) { if ($_POST['clear']) {
clear_log_file($ppps_logfile); clear_clog($ppps_logfile);
} }
$pgtitle = array(gettext("Status"),gettext("System logs"),gettext("PPP")); $pgtitle = array(gettext("Status"),gettext("System logs"),gettext("PPP"));
......
<?php <?php
/* /*
Copyright (C) 2015 Deciso B.V. Copyright (C) 2015 Deciso B.V.
All rights reserved. All rights reserved.
...@@ -26,6 +27,7 @@ ...@@ -26,6 +27,7 @@
*/ */
require_once("guiconfig.inc"); require_once("guiconfig.inc");
require_once("system.inc");
$logfile = '/var/log/squid/cache.log'; $logfile = '/var/log/squid/cache.log';
...@@ -36,10 +38,7 @@ if (empty($config['syslog']['nentries'])) { ...@@ -36,10 +38,7 @@ if (empty($config['syslog']['nentries'])) {
} }
if ($_POST['clear']) { if ($_POST['clear']) {
// trash log file clear_log($logfile);
$handle = fopen($logfile, 'r+');
ftruncate($handle, 0);
fclose($handle);
} }
$pgtitle = array(gettext("Status"),gettext("System logs"),gettext("Proxy")); $pgtitle = array(gettext("Status"),gettext("System logs"),gettext("Proxy"));
...@@ -57,12 +56,12 @@ include("head.inc"); ...@@ -57,12 +56,12 @@ include("head.inc");
<? include('diag_logs_tabs.inc'); ?> <? include('diag_logs_tabs.inc'); ?>
<div class="tab-content content-box col-xs-12"> <div class="tab-content content-box col-xs-12">
<div class="container-fluid"> <div class="container-fluid">
<p> <?php printf(gettext("Last %s log entries"), $max_logentries);?></p> <p><?php printf(gettext("Last %s Proxy log entries"), $nentries);?></p>
<pre><?php <div class="table-responsive">
if (file_exists($logfile)) { <table class="table table-striped table-sort">
echo trim(implode("", array_slice(file($logfile), -$max_logentries))); <?php dump_log($logfile, $nentries); ?>
} </table>
?></pre> </div>
<form method="post"> <form method="post">
<input name="clear" type="submit" class="btn" value="<?= gettext("Clear log");?>" /> <input name="clear" type="submit" class="btn" value="<?= gettext("Clear log");?>" />
</form> </form>
......
...@@ -42,7 +42,7 @@ if (empty($config['syslog']['nentries'])) { ...@@ -42,7 +42,7 @@ if (empty($config['syslog']['nentries'])) {
} }
if ($_POST['clear']) { if ($_POST['clear']) {
clear_log_file($relayd_logfile); clear_clog($relayd_logfile);
} }
$pgtitle = array(gettext("Status"),gettext("System logs"),gettext("Load Balancer")); $pgtitle = array(gettext("Status"),gettext("System logs"),gettext("Load Balancer"));
......
...@@ -43,7 +43,7 @@ if (empty($config['syslog']['nentries'])) { ...@@ -43,7 +43,7 @@ if (empty($config['syslog']['nentries'])) {
} }
if ($_POST['clear']) { if ($_POST['clear']) {
clear_log_file($system_logfile); clear_clog($system_logfile);
} }
if ($_GET['filtertext']) { if ($_GET['filtertext']) {
......
...@@ -40,7 +40,7 @@ if (empty($config['syslog']['nentries'])) { ...@@ -40,7 +40,7 @@ if (empty($config['syslog']['nentries'])) {
} }
if ($_POST['clear']) { if ($_POST['clear']) {
clear_log_file($routing_logfile); clear_clog($routing_logfile);
} }
$pgtitle = array(gettext("Status"),gettext("System logs"),gettext("Routing")); $pgtitle = array(gettext("Status"),gettext("System logs"),gettext("Routing"));
......
<?php <?php
/* /*
Copyright (C) 2014 Deciso B.V. Copyright (C) 2014 Deciso B.V.
Copyright (C) 2004-2009 Scott Ullrich Copyright (C) 2004-2009 Scott Ullrich
...@@ -38,22 +39,45 @@ function clear_all_log_files() ...@@ -38,22 +39,45 @@ function clear_all_log_files()
{ {
killbyname('syslogd'); killbyname('syslogd');
$clog_files = array(
'dhcpd',
'filter',
'gateways',
'ipsec',
'l2tps',
'lighttpd',
'ntpd',
'openvpn',
'poes',
'portalauth',
'ppps',
'pptps',
'relayd',
'resolver',
'routing',
'system',
'vpn',
'wireless',
);
foreach ($clog_files as $lfile) {
clear_clog("/var/log/{$lfile}.log", false);
}
$log_files = array( $log_files = array(
"system", "filter", "dhcpd", "vpn", "pptps", "poes", "l2tps", "openvpn", "portalauth", 'squid/access',
"ipsec", "ppps", "relayd", "wireless", "lighttpd", "ntpd", "gateways", "resolver", "routing" 'squid/cache',
); );
foreach ($log_files as $lfile) { foreach ($clog_files as $lfile) {
clear_log_file("/var/log/{$lfile}.log", false); clear_log("/var/log/{$lfile}.log", false);
} }
system_syslogd_start(); system_syslogd_start();
killbyname("dhcpd"); killbyname('dhcpd');
services_dhcpd_configure(); services_dhcpd_configure();
} }
$pconfig['reverse'] = isset($config['syslog']['reverse']); $pconfig['reverse'] = isset($config['syslog']['reverse']);
$pconfig['nentries'] = $config['syslog']['nentries']; $pconfig['nentries'] = $config['syslog']['nentries'];
$pconfig['remoteserver'] = $config['syslog']['remoteserver']; $pconfig['remoteserver'] = $config['syslog']['remoteserver'];
......
<?php <?php
/* /*
Copyright (C) 2014 Deciso B.V. Copyright (C) 2014 Deciso B.V.
All rights reserved. All rights reserved.
...@@ -24,19 +25,19 @@ ...@@ -24,19 +25,19 @@
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
*/ */
$active_tab = isset($active_tab) ? $active_tab : $_SERVER['PHP_SELF'];
$tab_array = array(); $active_tab = isset($active_tab) ? $active_tab : $_SERVER['PHP_SELF'];
$tab_array[] = array(gettext("System"), $active_tab == "/diag_logs.php", "diag_logs.php"); $tab_array = array();
$tab_array[] = array(gettext("Firewall"), $active_tab == "/diag_logs_filter.php", "diag_logs_filter.php"); $tab_array[] = array(gettext("System"), $active_tab == "/diag_logs.php", "diag_logs.php");
$tab_array[] = array(gettext("DHCP"), $active_tab == "/diag_logs_dhcp.php", "diag_logs_dhcp.php"); $tab_array[] = array(gettext("Firewall"), $active_tab == "/diag_logs_filter.php", "diag_logs_filter.php");
$tab_array[] = array(gettext("Portal Auth"), $active_tab == "/diag_logs_auth.php", "diag_logs_auth.php"); $tab_array[] = array(gettext("DHCP"), $active_tab == "/diag_logs_dhcp.php", "diag_logs_dhcp.php");
$tab_array[] = array(gettext("IPsec"), $active_tab == "/diag_logs_ipsec.php", "diag_logs_ipsec.php"); $tab_array[] = array(gettext("Portal Auth"), $active_tab == "/diag_logs_auth.php", "diag_logs_auth.php");
$tab_array[] = array(gettext("PPP"), $active_tab == "/diag_logs_ppp.php", "diag_logs_ppp.php"); $tab_array[] = array(gettext("IPsec"), $active_tab == "/diag_logs_ipsec.php", "diag_logs_ipsec.php");
$tab_array[] = array(gettext("VPN"), $active_tab == "/diag_logs_vpn.php", "diag_logs_vpn.php"); $tab_array[] = array(gettext("PPP"), $active_tab == "/diag_logs_ppp.php", "diag_logs_ppp.php");
$tab_array[] = array(gettext("Load Balancer"), $active_tab == "/diag_logs_relayd.php", "diag_logs_relayd.php"); $tab_array[] = array(gettext("VPN"), $active_tab == "/diag_logs_vpn.php", "diag_logs_vpn.php");
$tab_array[] = array(gettext("OpenVPN"), $active_tab == "/diag_logs_openvpn.php", "diag_logs_openvpn.php"); $tab_array[] = array(gettext("Load Balancer"), $active_tab == "/diag_logs_relayd.php", "diag_logs_relayd.php");
$tab_array[] = array(gettext("NTP"), $active_tab == "/diag_logs_ntpd.php", "diag_logs_ntpd.php"); $tab_array[] = array(gettext("OpenVPN"), $active_tab == "/diag_logs_openvpn.php", "diag_logs_openvpn.php");
$tab_array[] = array(gettext("Proxy"), $active_tab == "/diag_logs_proxy.php", "diag_logs_proxy.php"); $tab_array[] = array(gettext("NTP"), $active_tab == "/diag_logs_ntpd.php", "diag_logs_ntpd.php");
$tab_array[] = array(gettext("Settings"), $active_tab == "/diag_logs_settings.php", "diag_logs_settings.php"); $tab_array[] = array(gettext("Proxy"), $active_tab == "/diag_logs_proxy.php", "diag_logs_proxy.php");
display_top_tabs($tab_array); $tab_array[] = array(gettext("Settings"), $active_tab == "/diag_logs_settings.php", "diag_logs_settings.php");
?> display_top_tabs($tab_array);
...@@ -66,10 +66,11 @@ switch ($vpntype) { ...@@ -66,10 +66,11 @@ switch ($vpntype) {
} }
if ($_POST['clear']) { if ($_POST['clear']) {
if ($mode != "raw") if ($mode != "raw") {
clear_log_file("/var/log/vpn.log"); clear_clog("/var/log/vpn.log");
else } else {
clear_log_file("/var/log/{$logname}.log"); clear_clog("/var/log/{$logname}.log");
}
} }
function dump_clog_vpn($logfile, $tail) { function dump_clog_vpn($logfile, $tail) {
......
...@@ -42,7 +42,7 @@ if (empty($config['syslog']['nentries'])) { ...@@ -42,7 +42,7 @@ if (empty($config['syslog']['nentries'])) {
} }
if ($_POST['clear']) { if ($_POST['clear']) {
clear_log_file($wireless_logfile); clear_clog($wireless_logfile);
} }
$pgtitle = array(gettext("Status"),gettext("System logs"),gettext("Wireless")); $pgtitle = array(gettext("Status"),gettext("System logs"),gettext("Wireless"));
......
...@@ -347,43 +347,48 @@ function update_changedesc($update) { ...@@ -347,43 +347,48 @@ function update_changedesc($update) {
$changecount++; $changecount++;
} }
function clear_log_file($logfile = '/var/log/system.log', $restart_syslogd = true) function clear_log($logfile, $restart_syslogd = true)
{ {
global $config, $g; if ($restart_syslogd) {
if ($restart_syslogd) killbyname('syslogd');
exec("/usr/bin/killall syslogd");
if(isset($config['system']['disablesyslogclog'])) {
unlink($logfile);
touch($logfile);
} else {
$log_size = isset($config['syslog']['logfilesize']) ? $config['syslog']['logfilesize'] : "511488";
exec("/usr/local/sbin/clog -i -s {$log_size} " . escapeshellarg($logfile));
} }
foreach (glob($logfile . '.*') as $rotated) {
@unlink($rotated);
}
/* preserve file ownership and permissions */
$handle = fopen($logfile, 'r+');
if ($handle) {
ftruncate($handle, 0);
fclose($handle);
}
if ($restart_syslogd) { if ($restart_syslogd) {
system_syslogd_start(); system_syslogd_start();
} }
} }
function dump_clog($logfile, $tail, $withorig = true, $grepfor = "", $grepinvert = "") { function clear_clog($logfile, $restart_syslogd = true)
global $g, $config; {
$sor = isset($config['syslog']['reverse']) ? "-r" : ""; global $config;
$logarr = "";
$grepline = " "; if ($restart_syslogd) {
if(is_array($grepfor)) killbyname('syslogd');
$grepline .= " | /usr/bin/egrep " . escapeshellarg(implode("|", $grepfor));
if(is_array($grepinvert))
$grepline .= " | /usr/bin/egrep -v " . escapeshellarg(implode("|", $grepinvert));
if (is_dir($logfile)) {
$logarr = array("File $logfile is a directory.");
} elseif (file_exists($logfile) && filesize($logfile) == 0) {
$logarr = array("Log file started.");
} else {
if($config['system']['disablesyslogclog']) {
exec("cat " . escapeshellarg($logfile) . "{$grepline} | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
} else {
exec("/usr/local/sbin/clog " . escapeshellarg($logfile) . "{$grepline}| grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
} }
$log_size = isset($config['syslog']['logfilesize']) ? $config['syslog']['logfilesize'] : '511488';
mwexecf('/usr/local/sbin/clog -i -s %s %s', array($log_size, $logfile));
if ($restart_syslogd) {
system_syslogd_start();
} }
}
function print_dump($logarr, $withorig)
{
global $config;
foreach ($logarr as $logent) { foreach ($logarr as $logent) {
$logent = preg_split("/\s+/", $logent, 6); $logent = preg_split("/\s+/", $logent, 6);
echo "<tr valign=\"top\">\n"; echo "<tr valign=\"top\">\n";
...@@ -400,6 +405,63 @@ function dump_clog($logfile, $tail, $withorig = true, $grepfor = "", $grepinvert ...@@ -400,6 +405,63 @@ function dump_clog($logfile, $tail, $withorig = true, $grepfor = "", $grepinvert
} }
} }
function dump_clog($logfile, $tail, $withorig = true, $grepfor = '', $grepinvert = '')
{
global $config;
$sor = isset($config['syslog']['reverse']) ? '-r' : '';
$grepline = ' ';
$logarr = '';
if (is_array($grepfor)) {
$grepline .= " | /usr/bin/egrep " . escapeshellarg(implode("|", $grepfor));
}
if (is_array($grepinvert)) {
$grepline .= " | /usr/bin/egrep -v " . escapeshellarg(implode("|", $grepinvert));
}
if (is_dir($logfile)) {
$logarr = array("File $logfile is a directory.");
} elseif (!file_exists($logfile)) {
$logarr = array("File $logfile doesn't exist.");
} elseif (filesize($logfile) == 0) {
$logarr = array("Log file started.");
} else {
exec("/usr/local/sbin/clog " . escapeshellarg($logfile) . "{$grepline}| grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
}
print_dump($logarr, $withorig);
}
function dump_log($logfile, $tail, $withorig = true, $grepfor = '', $grepinvert = '')
{
global $config;
$sor = isset($config['syslog']['reverse']) ? '-r' : '';
$grepline = ' ';
$logarr = '';
if (is_array($grepfor)) {
$grepline .= " | /usr/bin/egrep " . escapeshellarg(implode("|", $grepfor));
}
if (is_array($grepinvert)) {
$grepline .= " | /usr/bin/egrep -v " . escapeshellarg(implode("|", $grepinvert));
}
if (is_dir($logfile)) {
$logarr = array("File $logfile is a directory.");
} elseif (!file_exists($logfile)) {
$logarr = array("File $logfile doesn't exist.");
} elseif (filesize($logfile) == 0) {
$logarr = array("Log file started.");
} else {
exec("cat " . escapeshellarg($logfile) . "{$grepline} | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
}
print_dump($logarr, $withorig);
}
/* Check if variable has changed, update and log if it has /* Check if variable has changed, update and log if it has
* returns true if var changed * returns true if var changed
...@@ -523,9 +585,10 @@ function is_specialnet($net) { ...@@ -523,9 +585,10 @@ function is_specialnet($net) {
* RESULT * RESULT
* null * null
******/ ******/
function display_top_tabs(& $tab_array, $no_drop_down = false) { function display_top_tabs(& $tab_array, $no_drop_down = false)
{
global $config; global $config;
global $g;
$tab_array_char_limit = 92; $tab_array_char_limit = 92;
/* does the user have access to this tab? /* does the user have access to this tab?
...@@ -583,9 +646,6 @@ function display_top_tabs(& $tab_array, $no_drop_down = false) { ...@@ -583,9 +646,6 @@ function display_top_tabs(& $tab_array, $no_drop_down = false) {
} }
} }
$timezone = $config['system']['timezone']; $timezone = $config['system']['timezone'];
if (!$timezone) { if (!$timezone) {
$timezone = 'Etc/UTC'; $timezone = 'Etc/UTC';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment