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
88b047c1
Commit
88b047c1
authored
Jun 13, 2016
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
logs: move log specifics away from guiconfig.inc
parent
12febf02
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
123 additions
and
85 deletions
+123
-85
diag_logs_common.inc
src/www/diag_logs_common.inc
+111
-0
diag_logs_template.inc
src/www/diag_logs_template.inc
+7
-2
guiconfig.inc
src/www/guiconfig.inc
+0
-81
system_log.widget.php
src/www/widgets/widgets/system_log.widget.php
+5
-2
No files found.
src/www/diag_logs_common.inc
0 → 100644
View file @
88b047c1
<?php
/*
Copyright (C) 2015-2016 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>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
function
print_dump
(
$logarr
)
{
global
$config
;
if
(
!
is_array
(
$logarr
))
{
echo
"<tr>
\n
"
;
echo
"<td colspan=
\"
2
\"
>"
.
htmlspecialchars
(
$logarr
)
.
"</td>
\n
"
;
echo
"</tr>
\n
"
;
return
;
}
foreach
(
$logarr
as
$logent
)
{
$logent
=
preg_split
(
"/\s+/"
,
$logent
,
6
);
echo
"<tr>
\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>
{
$entry_date_time
}
</td>
\n
"
;
echo
"<td>
{
$entry_text
}
</td>
\n
"
;
echo
"</tr>
\n
"
;
}
}
function
dump_clog
(
$logfile
,
$tail
,
$grepfor
=
''
)
{
global
$config
;
$sor
=
isset
(
$config
[
'syslog'
][
'reverse'
])
?
'-r'
:
''
;
$logarr
=
array
();
$grepline
=
''
;
$grepfor
=
preg_split
(
'/\s+/'
,
trim
(
$grepfor
));
foreach
(
$grepfor
as
$pattern
)
{
$grepline
.=
' | /usr/bin/egrep -i '
.
escapeshellarg
(
$pattern
);
}
if
(
is_dir
(
$logfile
))
{
$logarr
=
sprintf
(
gettext
(
'File %s is a directory.'
),
$logfile
);
}
elseif
(
!
file_exists
(
$logfile
))
{
$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
);
}
if
(
is_array
(
$logarr
)
&&
!
count
(
$logarr
))
{
$logarr
=
sprintf
(
gettext
(
'File %s yielded no results.'
),
$logfile
);
}
print_dump
(
$logarr
);
}
function
dump_log
(
$logfile
,
$tail
,
$grepfor
=
''
)
{
global
$config
;
$sor
=
isset
(
$config
[
'syslog'
][
'reverse'
])
?
'-r'
:
''
;
$logarr
=
array
();
$grepline
=
''
;
$grepfor
=
preg_split
(
'/\s+/'
,
trim
(
$grepfor
));
foreach
(
$grepfor
as
$pattern
)
{
$grepline
.=
' | /usr/bin/egrep -i '
.
escapeshellarg
(
$pattern
);
}
if
(
is_dir
(
$logfile
))
{
$logarr
=
sprintf
(
gettext
(
'File %s is a directory.'
),
$logfile
);
}
elseif
(
!
file_exists
(
$logfile
))
{
$logarr
=
sprintf
(
gettext
(
'File %s doesn\'t exist.'
),
$logfile
);
}
else
{
exec
(
"cat "
.
escapeshellarg
(
$logfile
)
.
"
{
$grepline
}
| /usr/bin/tail
{
$sor
}
-n "
.
escapeshellarg
(
$tail
),
$logarr
);
}
if
(
is_array
(
$logarr
)
&&
!
count
(
$logarr
))
{
$logarr
=
sprintf
(
gettext
(
'File %s yielded no results.'
),
$logfile
);
}
print_dump
(
$logarr
);
}
src/www/diag_logs_template.inc
View file @
88b047c1
...
...
@@ -37,6 +37,8 @@ require_once("plugins.inc");
/* expects $logfile to point to the system path */
/* expects $logclog to be true or false */
require_once
'diag_logs_common.inc'
;
$filtertext
=
''
;
$nentries
=
50
;
...
...
@@ -101,8 +103,11 @@ include("head.inc");
?>
<tr>
<td
colspan=
"2"
>
<form
action=
"
<?
$_SERVER
[
'REQUEST_URI'
]
?>
"
method=
"post"
>
<input
name=
"clear"
type=
"submit"
class=
"btn btn-primary"
value=
"
<?=
gettext
(
"Clear log"
);
?>
"
/>
<form
action=
"
<?
html_safe
(
$_SERVER
[
'REQUEST_URI'
])
?>
"
method=
"post"
>
<?php
if
(
isset
(
$mode
))
:
?>
<input
type=
"hidden"
name=
"mode"
id=
"mode"
value=
"
<?=
html_safe
(
$mode
)
?>
"
/>
<?php
endif
?>
<input
name=
"clear"
type=
"submit"
class=
"btn btn-primary"
value=
"
<?=
html_safe
(
gettext
(
'Clear log'
))
?>
"
/>
</form>
</td>
</tr>
...
...
src/www/guiconfig.inc
View file @
88b047c1
...
...
@@ -359,87 +359,6 @@ function gentitle($breadcrumbs, $navlevelsep = ': ')
return
join
(
$navlevelsep
,
$output
);
}
function
print_dump
(
$logarr
)
{
global
$config
;
if
(
!
is_array
(
$logarr
))
{
echo
"<tr>
\n
"
;
echo
"<td colspan=
\"
2
\"
>"
.
htmlspecialchars
(
$logarr
)
.
"</td>
\n
"
;
echo
"</tr>
\n
"
;
return
;
}
foreach
(
$logarr
as
$logent
)
{
$logent
=
preg_split
(
"/\s+/"
,
$logent
,
6
);
echo
"<tr>
\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>
{
$entry_date_time
}
</td>
\n
"
;
echo
"<td>
{
$entry_text
}
</td>
\n
"
;
echo
"</tr>
\n
"
;
}
}
function
dump_clog
(
$logfile
,
$tail
,
$grepfor
=
''
)
{
global
$config
;
$sor
=
isset
(
$config
[
'syslog'
][
'reverse'
])
?
'-r'
:
''
;
$logarr
=
array
();
$grepline
=
''
;
$grepfor
=
preg_split
(
'/\s+/'
,
trim
(
$grepfor
));
foreach
(
$grepfor
as
$pattern
)
{
$grepline
.=
' | /usr/bin/egrep -i '
.
escapeshellarg
(
$pattern
);
}
if
(
is_dir
(
$logfile
))
{
$logarr
=
sprintf
(
gettext
(
'File %s is a directory.'
),
$logfile
);
}
elseif
(
!
file_exists
(
$logfile
))
{
$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
);
}
if
(
is_array
(
$logarr
)
&&
!
count
(
$logarr
))
{
$logarr
=
sprintf
(
gettext
(
'File %s yielded no results.'
),
$logfile
);
}
print_dump
(
$logarr
);
}
function
dump_log
(
$logfile
,
$tail
,
$grepfor
=
''
)
{
global
$config
;
$sor
=
isset
(
$config
[
'syslog'
][
'reverse'
])
?
'-r'
:
''
;
$logarr
=
array
();
$grepline
=
''
;
$grepfor
=
preg_split
(
'/\s+/'
,
trim
(
$grepfor
));
foreach
(
$grepfor
as
$pattern
)
{
$grepline
.=
' | /usr/bin/egrep -i '
.
escapeshellarg
(
$pattern
);
}
if
(
is_dir
(
$logfile
))
{
$logarr
=
sprintf
(
gettext
(
'File %s is a directory.'
),
$logfile
);
}
elseif
(
!
file_exists
(
$logfile
))
{
$logarr
=
sprintf
(
gettext
(
'File %s doesn\'t exist.'
),
$logfile
);
}
else
{
exec
(
"cat "
.
escapeshellarg
(
$logfile
)
.
"
{
$grepline
}
| /usr/bin/tail
{
$sor
}
-n "
.
escapeshellarg
(
$tail
),
$logarr
);
}
if
(
is_array
(
$logarr
)
&&
!
count
(
$logarr
))
{
$logarr
=
sprintf
(
gettext
(
'File %s yielded no results.'
),
$logfile
);
}
print_dump
(
$logarr
);
}
function
address_to_pconfig
(
$adr
,
&
$padr
,
&
$pmask
,
&
$pnot
,
&
$pbeginport
,
&
$pendport
)
{
if
(
isset
(
$adr
[
'any'
]))
{
...
...
src/www/widgets/widgets/system_log.widget.php
View file @
88b047c1
...
...
@@ -37,13 +37,16 @@ if (!$config['widgets']['systemlogfiltercount']){
$syslogEntriesToFetch
=
$config
[
'widgets'
][
'systemlogfiltercount'
];
}
if
(
is_numeric
(
$_POST
[
'logfiltercount'
]))
{
if
(
is_numeric
(
$_POST
[
'logfiltercount'
]))
{
$countReceived
=
$_POST
[
'logfiltercount'
];
$config
[
'widgets'
][
'systemlogfiltercount'
]
=
$countReceived
;
write_config
(
"Saved Widget System Log Filter Setting"
);
Header
(
"Location: /index.php"
);
exit
(
0
)
;
exit
;
}
require_once
(
'diag_logs_common.inc'
);
?>
<div
id=
"system_log-settings"
class=
"widgetconfigdiv"
style=
"display:none;"
>
...
...
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