Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
fba56a9a
Commit
fba56a9a
authored
Nov 11, 2015
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
logs: lots of love for logs, filtering is more useful than ever :)
parent
dd878efc
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
65 additions
and
95 deletions
+65
-95
diag_logs.php
src/www/diag_logs.php
+4
-10
diag_logs_auth.php
src/www/diag_logs_auth.php
+3
-4
diag_logs_dhcp.php
src/www/diag_logs_dhcp.php
+3
-4
diag_logs_gateways.php
src/www/diag_logs_gateways.php
+4
-9
diag_logs_resolver.php
src/www/diag_logs_resolver.php
+4
-9
diag_logs_routing.php
src/www/diag_logs_routing.php
+4
-9
diag_logs_wireless.php
src/www/diag_logs_wireless.php
+4
-9
guiconfig.inc
src/www/guiconfig.inc
+38
-40
system_log.widget.php
src/www/widgets/widgets/system_log.widget.php
+1
-1
No files found.
src/www/diag_logs.php
View file @
fba56a9a
...
...
@@ -33,10 +33,10 @@ require_once("system.inc");
require_once
(
"interfaces.inc"
);
$system_logfile
=
'/var/log/system.log'
;
$filtertext
=
''
;
$nentries
=
50
;
if
(
empty
(
$config
[
'syslog'
][
'nentries'
]))
{
$nentries
=
50
;
}
else
{
if
(
isset
(
$config
[
'syslog'
][
'nentries'
]))
{
$nentries
=
$config
[
'syslog'
][
'nentries'
];
}
...
...
@@ -76,13 +76,7 @@ include("head.inc");
<input
id=
"filtersubmit"
name=
"filtersubmit"
type=
"submit"
class=
"btn btn-primary"
value=
"
<?=
gettext
(
"Filter"
);
?>
"
/>
</form>
</td></tr>
<?php
if
(
isset
(
$filtertext
))
{
dump_clog
(
$system_logfile
,
$nentries
,
true
,
array
(
"
$filtertext
"
),
array
(
"ppp"
));
}
else
{
dump_clog
(
$system_logfile
,
$nentries
,
true
,
array
(),
array
(
"ppp"
));
}
?>
<?php
dump_clog
(
$system_logfile
,
$nentries
,
$filtertext
);
?>
<tr><td
colspan=
"2"
>
<form
action=
"diag_logs.php"
method=
"post"
>
<input
name=
"clear"
type=
"submit"
class=
"btn btn-default"
value=
"
<?=
gettext
(
"Clear log"
);
?>
"
/>
...
...
src/www/diag_logs_auth.php
View file @
fba56a9a
...
...
@@ -33,10 +33,9 @@ require_once("system.inc");
require_once
(
"interfaces.inc"
);
$portal_logfile
=
'/var/log/portalauth.log'
;
$nentries
=
50
;
if
(
empty
(
$config
[
'syslog'
][
'nentries'
]))
{
$nentries
=
50
;
}
else
{
if
(
isset
(
$config
[
'syslog'
][
'nentries'
]))
{
$nentries
=
$config
[
'syslog'
][
'nentries'
];
}
...
...
@@ -65,7 +64,7 @@ include("head.inc");
<div
class=
"table-responsive"
>
<table
class=
"table table-striped table-sort"
>
<tr><td
colspan=
"2"
><strong>
<?=
sprintf
(
gettext
(
'Last %s Portal Auth log entries'
),
$nentries
);
?>
</strong></td></tr>
<?php
dump_clog
(
$portal_logfile
,
$nentries
,
true
);
?>
<?php
dump_clog
(
$portal_logfile
,
$nentries
);
?>
<tr><td
colspan=
"2"
>
<form
action=
"diag_logs_auth.php"
method=
"post"
>
<input
name=
"clear"
type=
"submit"
class=
"btn"
value=
"
<?=
gettext
(
"Clear log"
);
?>
"
/>
...
...
src/www/diag_logs_dhcp.php
View file @
fba56a9a
...
...
@@ -34,10 +34,9 @@ require_once("system.inc");
require_once
(
"interfaces.inc"
);
$dhcpd_logfile
=
'/var/log/dhcpd.log'
;
$nentries
=
50
;
if
(
empty
(
$config
[
'syslog'
][
'nentries'
]))
{
$nentries
=
50
;
}
else
{
if
(
isset
(
$config
[
'syslog'
][
'nentries'
]))
{
$nentries
=
$config
[
'syslog'
][
'nentries'
];
}
...
...
@@ -68,7 +67,7 @@ include("head.inc");
<div
class=
"table-responsive"
>
<table
class=
"table table-striped table-sort"
>
<tr><td
colspan=
"2"
>
<?=
sprintf
(
gettext
(
'Last %s DHCP service log entries'
),
$nentries
);
?>
</strong></td><tr>
<?php
dump_clog
(
$dhcpd_logfile
,
$nentries
,
true
);
?>
<?php
dump_clog
(
$dhcpd_logfile
,
$nentries
);
?>
<tr><td
colspan=
"2"
>
<form
action=
"diag_logs_dhcp.php"
method=
"post"
>
<input
name=
"clear"
type=
"submit"
class=
"btn"
value=
"
<?=
gettext
(
"Clear log"
);
?>
"
/>
...
...
src/www/diag_logs_gateways.php
View file @
fba56a9a
...
...
@@ -35,10 +35,10 @@ require_once("system.inc");
require_once
(
"interfaces.inc"
);
$system_logfile
=
'/var/log/gateways.log'
;
$filtertext
=
''
;
$nentries
=
50
;
if
(
empty
(
$config
[
'syslog'
][
'nentries'
]))
{
$nentries
=
50
;
}
else
{
if
(
isset
(
$config
[
'syslog'
][
'nentries'
]))
{
$nentries
=
$config
[
'syslog'
][
'nentries'
];
}
...
...
@@ -77,12 +77,7 @@ include("head.inc");
<input
id=
"filtersubmit"
name=
"filtersubmit"
type=
"submit"
class=
"btn btn-primary"
value=
"
<?=
gettext
(
"Filter"
);
?>
"
/>
</form>
</td></tr>
<?php
if
(
isset
(
$filtertext
))
dump_clog
(
$system_logfile
,
$nentries
,
true
,
array
(
"
$filtertext
"
));
else
dump_clog
(
$system_logfile
,
$nentries
,
true
,
array
());
?>
<?php
dump_clog
(
$system_logfile
,
$nentries
,
$filtertext
);
?>
<tr><td
colspan=
"2"
>
<form
action=
"diag_logs_gateways.php"
method=
"post"
>
<input
name=
"clear"
type=
"submit"
class=
"btn"
value=
"
<?=
gettext
(
"Clear log"
);
?>
"
/>
...
...
src/www/diag_logs_resolver.php
View file @
fba56a9a
...
...
@@ -35,10 +35,10 @@ require_once("system.inc");
require_once
(
"interfaces.inc"
);
$system_logfile
=
'/var/log/resolver.log'
;
$filtertext
=
''
;
$nentries
=
50
;
if
(
empty
(
$config
[
'syslog'
][
'nentries'
]))
{
$nentries
=
50
;
}
else
{
if
(
isset
(
$config
[
'syslog'
][
'nentries'
]))
{
$nentries
=
$config
[
'syslog'
][
'nentries'
];
}
...
...
@@ -77,12 +77,7 @@ include("head.inc");
<input
id=
"filtersubmit"
name=
"filtersubmit"
type=
"submit"
class=
"btn btn-primary"
value=
"
<?=
gettext
(
"Filter"
);
?>
"
/>
</form>
</td></tr>
<?php
if
(
isset
(
$filtertext
))
dump_clog
(
$system_logfile
,
$nentries
,
true
,
array
(
"
$filtertext
"
),
array
(
"ppp"
));
else
dump_clog
(
$system_logfile
,
$nentries
,
true
,
array
(),
array
(
"ppp"
));
?>
<?php
dump_clog
(
$system_logfile
,
$nentries
,
$filtertext
);
?>
<tr><td
colspan=
"2"
>
<form
action=
"diag_logs_resolver.php"
method=
"post"
>
<input
name=
"clear"
type=
"submit"
class=
"btn"
value=
"
<?=
gettext
(
"Clear log"
);
?>
"
/>
...
...
src/www/diag_logs_routing.php
View file @
fba56a9a
...
...
@@ -32,10 +32,10 @@ require_once("system.inc");
require_once
(
"interfaces.inc"
);
$routing_logfile
=
'/var/log/routing.log'
;
$filtertext
=
''
;
$nentries
=
50
;
if
(
empty
(
$config
[
'syslog'
][
'nentries'
]))
{
$nentries
=
50
;
}
else
{
if
(
isset
(
$config
[
'syslog'
][
'nentries'
]))
{
$nentries
=
$config
[
'syslog'
][
'nentries'
];
}
...
...
@@ -76,12 +76,7 @@ include("head.inc");
<input
id=
"filtersubmit"
name=
"filtersubmit"
type=
"submit"
class=
"btn btn-primary"
value=
"
<?=
gettext
(
"Filter"
);
?>
"
/>
</form>
</td></tr>
<?php
if
(
isset
(
$filtertext
))
dump_clog
(
$routing_logfile
,
$nentries
,
true
,
array
(
"
$filtertext
"
));
else
dump_clog
(
$routing_logfile
,
$nentries
,
true
,
array
());
?>
<?php
dump_clog
(
$routing_logfile
,
$nentries
,
$filtertext
);
?>
<tr><td
colspan=
"2"
>
<form
action=
"diag_logs_routing.php"
method=
"post"
>
<input
name=
"clear"
type=
"submit"
class=
"btn"
value=
"
<?=
gettext
(
"Clear log"
);
?>
"
/>
...
...
src/www/diag_logs_wireless.php
View file @
fba56a9a
...
...
@@ -34,10 +34,10 @@ require_once("system.inc");
require_once
(
"interfaces.inc"
);
$wireless_logfile
=
'/var/log/wireless.log'
;
$filtertext
=
''
;
$nentries
=
50
;
if
(
empty
(
$config
[
'syslog'
][
'nentries'
]))
{
$nentries
=
50
;
}
else
{
if
(
isset
(
$config
[
'syslog'
][
'nentries'
]))
{
$nentries
=
$config
[
'syslog'
][
'nentries'
];
}
...
...
@@ -77,12 +77,7 @@ include("head.inc");
<input
id=
"filtersubmit"
name=
"filtersubmit"
type=
"submit"
class=
"btn btn-primary"
value=
"
<?=
gettext
(
"Filter"
);
?>
"
/>
</form>
</td></tr>
<?php
if
(
isset
(
$filtertext
))
dump_clog
(
$wireless_logfile
,
$nentries
,
true
,
array
(
"
$filtertext
"
));
else
dump_clog
(
$wireless_logfile
,
$nentries
,
true
,
array
());
?>
<?php
dump_clog
(
$wireless_logfile
,
$nentries
,
$filtertext
);
?>
<tr><td
colspan=
"2"
>
<form
action=
"diag_logs_wireless.php"
method=
"post"
>
<input
name=
"clear"
type=
"submit"
class=
"btn"
value=
"
<?=
gettext
(
"Clear log"
);
?>
"
/>
...
...
src/www/guiconfig.inc
View file @
fba56a9a
<?php
/*
Copyright (C) 2015 Franco Fichtner <franco@opnsense.org>
Copyright (C) 2014 Deciso B.V.
Copyright (C) 2004 Scott Ullrich
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
...
...
@@ -339,88 +340,85 @@ function clear_clog($logfile, $restart_syslogd = true)
}
}
function
print_dump
(
$logarr
,
$withorig
)
function
print_dump
(
$logarr
)
{
global
$config
;
if
(
!
is_array
(
$logarr
))
{
echo
"<tr valign=
\"
top
\"
>
\n
"
;
echo
"<td class=
\"
listlr
\"
colspan=
\"
2
\"
>"
.
htmlspecialchars
(
$logarr
)
.
"</td>
\n
"
;
echo
"</tr>
\n
"
;
return
;
}
foreach
(
$logarr
as
$logent
)
{
$logent
=
preg_split
(
"/\s+/"
,
$logent
,
6
);
echo
"<tr valign=
\"
top
\"
>
\n
"
;
if
(
$logent
[
0
]
===
'File'
)
{
echo
"<td class=
\"
listlr
\"
colspan=
\"
2
\"
>"
.
htmlspecialchars
(
join
(
' '
,
$logent
))
.
"</td>
\n
"
;
}
elseif
(
$withorig
)
{
$entry_date_time
=
htmlspecialchars
(
join
(
" "
,
array_slice
(
$logent
,
0
,
3
)));
$entry_text
=
(
$logent
[
3
]
==
$config
[
'system'
][
'hostname'
])
?
""
:
$logent
[
3
]
.
" "
;
$entry_text
.=
htmlspecialchars
(
$logent
[
4
]
.
" "
.
$logent
[
5
]);
echo
"<td class=
\"
listlr nowrap
\"
>
{
$entry_date_time
}
</td>
\n
"
;
echo
"<td class=
\"
listr
\"
>
{
$entry_text
}
</td>
\n
"
;
}
else
{
echo
"<td class=
\"
listlr
\"
colspan=
\"
2
\"
>"
.
htmlspecialchars
(
$logent
[
5
])
.
"</td>
\n
"
;
}
$entry_date_time
=
htmlspecialchars
(
join
(
" "
,
array_slice
(
$logent
,
0
,
3
)));
$entry_text
=
(
$logent
[
3
]
==
$config
[
'system'
][
'hostname'
])
?
""
:
$logent
[
3
]
.
" "
;
$entry_text
.=
htmlspecialchars
(
$logent
[
4
]
.
" "
.
$logent
[
5
]);
echo
"<td class=
\"
listlr nowrap
\"
>
{
$entry_date_time
}
</td>
\n
"
;
echo
"<td class=
\"
listr
\"
>
{
$entry_text
}
</td>
\n
"
;
echo
"</tr>
\n
"
;
}
}
function
dump_clog
(
$logfile
,
$tail
,
$
withorig
=
true
,
$grepfor
=
''
,
$grepinvert
=
''
)
function
dump_clog
(
$logfile
,
$tail
,
$
grepfor
=
''
)
{
global
$config
;
$sor
=
isset
(
$config
[
'syslog'
][
'reverse'
])
?
'-r'
:
''
;
$
grepline
=
' '
;
$
logarr
=
''
;
$
logarr
=
array
()
;
$
grepline
=
''
;
if
(
is_array
(
$grepfor
))
{
$grepline
.=
" | /usr/bin/egrep -i "
.
escapeshellarg
(
implode
(
"|"
,
$grepfor
));
}
$grepfor
=
preg_split
(
'/\s+/'
,
trim
(
$grepfor
));
if
(
is_array
(
$grepinvert
)
)
{
$grepline
.=
" | /usr/bin/egrep -iv "
.
escapeshellarg
(
implode
(
"|"
,
$grepinvert
)
);
foreach
(
$grepfor
as
$pattern
)
{
$grepline
.=
' | /usr/bin/egrep -i '
.
escapeshellarg
(
$pattern
);
}
if
(
is_dir
(
$logfile
))
{
$logarr
=
array
(
"File
$logfile
is a directory."
);
$logarr
=
sprintf
(
gettext
(
'File %s is a directory.'
),
$logfile
);
}
elseif
(
!
file_exists
(
$logfile
))
{
$logarr
=
array
(
"File
$logfile
doesn't exist."
);
$logarr
=
sprintf
(
gettext
(
'File %s doesn\'t exist.'
),
$logfile
);
}
else
{
exec
(
"/usr/local/sbin/clog "
.
escapeshellarg
(
$logfile
)
.
"
{
$grepline
}
| grep -v
\"
CLOG
\"
| grep -v
\"\033\"
| /usr/bin/tail
{
$sor
}
-n "
.
escapeshellarg
(
$tail
),
$logarr
);
exec
(
"/usr/local/sbin/clog "
.
escapeshellarg
(
$logfile
)
.
"
{
$grepline
}
| grep -v
\"
CLOG
\"
| grep -v
\"\033\"
| /usr/bin/tail
{
$sor
}
-n "
.
escapeshellarg
(
$tail
),
$logarr
);
}
if
(
!
count
(
$logarr
))
{
$logarr
[]
=
sprintf
(
gettext
(
'File %s yielded no results.'
),
$logfile
);
if
(
is_array
(
$logarr
)
&&
!
count
(
$logarr
))
{
$logarr
=
sprintf
(
gettext
(
'File %s yielded no results.'
),
$logfile
);
}
print_dump
(
$logarr
,
$withorig
);
print_dump
(
$logarr
);
}
function
dump_log
(
$logfile
,
$tail
,
$
withorig
=
true
,
$grepfor
=
''
,
$grepinvert
=
''
)
function
dump_log
(
$logfile
,
$tail
,
$
grepfor
=
''
)
{
global
$config
;
$sor
=
isset
(
$config
[
'syslog'
][
'reverse'
])
?
'-r'
:
''
;
$
grepline
=
' '
;
$
logarr
=
''
;
$
logarr
=
array
()
;
$
grepline
=
''
;
if
(
is_array
(
$grepfor
))
{
$grepline
.=
" | /usr/bin/egrep -i "
.
escapeshellarg
(
implode
(
"|"
,
$grepfor
));
}
$grepfor
=
preg_split
(
'/\s+/'
,
trim
(
$grepfor
));
if
(
is_array
(
$grepinvert
)
)
{
$grepline
.=
" | /usr/bin/egrep -iv "
.
escapeshellarg
(
implode
(
"|"
,
$grepinvert
)
);
foreach
(
$grepfor
as
$pattern
)
{
$grepline
.=
' | /usr/bin/egrep -i '
.
escapeshellarg
(
$pattern
);
}
if
(
is_dir
(
$logfile
))
{
$logarr
=
array
(
sprintf
(
gettext
(
'File %s is a directory.'
),
$logfile
)
);
$logarr
=
sprintf
(
gettext
(
'File %s is a directory.'
),
$logfile
);
}
elseif
(
!
file_exists
(
$logfile
))
{
$logarr
=
array
(
sprintf
(
gettext
(
'File %s doesn\'t exist.'
),
$logfile
)
);
$logarr
=
sprintf
(
gettext
(
'File %s doesn\'t exist.'
),
$logfile
);
}
else
{
exec
(
"cat "
.
escapeshellarg
(
$logfile
)
.
"
{
$grepline
}
| /usr/bin/tail
{
$sor
}
-n "
.
escapeshellarg
(
$tail
),
$logarr
);
exec
(
"cat "
.
escapeshellarg
(
$logfile
)
.
"
{
$grepline
}
| /usr/bin/tail
{
$sor
}
-n "
.
escapeshellarg
(
$tail
),
$logarr
);
}
if
(
!
count
(
$logarr
))
{
$logarr
[]
=
sprintf
(
gettext
(
'File %s yielded no results.'
),
$logfile
);
if
(
is_array
(
$logarr
)
&&
!
count
(
$logarr
))
{
$logarr
=
sprintf
(
gettext
(
'File %s yielded no results.'
),
$logfile
);
}
print_dump
(
$logarr
,
$withorig
);
print_dump
(
$logarr
);
}
/* Check if variable has changed, update and log if it has
...
...
src/www/widgets/widgets/system_log.widget.php
View file @
fba56a9a
...
...
@@ -72,7 +72,7 @@ if(is_numeric($_POST['logfiltercount'])) {
<div
id=
"system_log-widgets"
class=
"content-box"
style=
"overflow:scroll;"
>
<table
class=
"table table-striped"
cellspacing=
"0"
cellpadding=
"0"
>
<?php
dump_clog
(
$system_logfile
,
$syslogEntriesToFetch
,
true
,
array
(),
array
(
"ppp"
)
);
?>
<?php
dump_clog
(
$system_logfile
,
$syslogEntriesToFetch
);
?>
</table>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment