summaryrefslogtreecommitdiffstats
path: root/usr
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2006-09-27 23:02:41 +0000
committerScott Ullrich <sullrich@pfsense.org>2006-09-27 23:02:41 +0000
commit0fcfdd3d0bac7b2c8b7ba4d98d82d1deac1cd606 (patch)
treea7ccf73e5f96da23a2b1395ca22965c73584a59c /usr
parent13c24013c56f4aa2269d0aacd2e2a75251340cb0 (diff)
downloadpfsense-0fcfdd3d0bac7b2c8b7ba4d98d82d1deac1cd606.zip
pfsense-0fcfdd3d0bac7b2c8b7ba4d98d82d1deac1cd606.tar.gz
We cannot tail the initial clog file in dump_clog because we are not guaranteed to have that amount of "matching" lines. Instead, build up a grepline that contains all of the grep and grep -v statement. This now allows the tail to chop off the last X lines correctly.
Diffstat (limited to 'usr')
-rwxr-xr-xusr/local/www/guiconfig.inc49
1 files changed, 24 insertions, 25 deletions
diff --git a/usr/local/www/guiconfig.inc b/usr/local/www/guiconfig.inc
index 9ce52f1..d3ed496 100755
--- a/usr/local/www/guiconfig.inc
+++ b/usr/local/www/guiconfig.inc
@@ -562,32 +562,31 @@ function dump_clog($logfile, $tail, $withorig = true, $grepfor = "", $grepinvert
global $g, $config;
$sor = isset($config['syslog']['reverse']) ? "-r" : "";
$logarr = "";
- exec("/usr/sbin/clog {$logfile} | grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n {$tail}", $logarr);
-
+ $grepline = " ";
if(is_array($grepfor)) {
- $i = 0;
- foreach($grepfor as $agrep) {
- $regexp = "/" . $agrep . "/i";
- if($grepinvert[$i]) {
- $logarr = preg_grep($regexp, $logarr, PREG_GREP_INVERT);
- } else {
- $logarr = preg_grep($regexp, $logarr);
- }
- $i++;
- }
- }
- foreach ($logarr as $logent) {
- $logent = preg_split("/\s+/", $logent, 6);
- echo "<tr valign=\"top\">\n";
- if ($withorig) {
- $entry_date_time = htmlspecialchars(join(" ", array_slice($logent, 0, 3)));
- echo "<td class=\"listlr\" nowrap>" . $entry_date_time . "</td>\n";
- echo "<td class=\"listr\">" . htmlspecialchars($logent[4] . " " . $logent[5]) . "</td>\n";
- } else {
- echo "<td class=\"listlr\" colspan=\"2\">" . htmlspecialchars($logent[5]) . "</td>\n";
- }
- echo "</tr>\n";
- }
+ foreach($grepfor as $agrep) {
+ $regexp = $agrep;
+ if($grepinvert[$i]) {
+ $grepline .= " | grep \"$regexp\"";
+ } else {
+ $grepline .= " | grep -v \"$regexp\"";
+ }
+ }
+ }
+ exec("/usr/sbin/clog {$logfile}{$grepline}| grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n {$tail}", $logarr);
+ echo "<!-- /usr/sbin/clog {$logfile}{$grepline}| grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n {$tail} -->";
+ foreach ($logarr as $logent) {
+ $logent = preg_split("/\s+/", $logent, 6);
+ echo "<tr valign=\"top\">\n";
+ if ($withorig) {
+ $entry_date_time = htmlspecialchars(join(" ", array_slice($logent, 0, 3)));
+ echo "<td class=\"listlr\" nowrap>" . $entry_date_time . "</td>\n";
+ echo "<td class=\"listr\">" . htmlspecialchars($logent[4] . " " . $logent[5]) . "</td>\n";
+ } else {
+ echo "<td class=\"listlr\" colspan=\"2\">" . htmlspecialchars($logent[5]) . "</td>\n";
+ }
+ echo "</tr>\n";
+ }
}
function return_clog($logfile, $tail, $grepfor = "", $grepinvert = "", $grepreverse = false) {
OpenPOWER on IntegriCloud