Project

General

Profile

Download (3.53 KB) Statistics
| Branch: | Tag: | Revision:
1 df01982a Colin Smith
<?php
2
/*
3 2eb4178b Colin Smith
	$Id$
4
5 df01982a Colin Smith
	diag_pkglogs.php
6
	Copyright (C) 2005 Colin Smith
7
	All rights reserved.
8
9 ce77a9c4 Phil Davis
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
10 29aef6c4 Jim Thompson
	All rights reserved.
11
12 df01982a Colin Smith
	Redistribution and use in source and binary forms, with or without
13
	modification, are permitted provided that the following conditions are met:
14
15
	1. Redistributions of source code must retain the above copyright notice,
16
	   this list of conditions and the following disclaimer.
17
18
	2. Redistributions in binary form must reproduce the above copyright
19
	   notice, this list of conditions and the following disclaimer in the
20
	   documentation and/or other materials provided with the distribution.
21
22
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
23
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
	POSSIBILITY OF SUCH DAMAGE.
32 825275fa Colin Smith
33
	<logging>
34
		<logtab>arpwatch</logtab>
35
		<grepfor>arpwatch</logtab>
36
	</logging>
37
38
		<invertgrep/>
39
		<logfile>/var/log/arpwatch.log</logfile>
40
41 df01982a Colin Smith
*/
42
43 13d193c2 Scott Ullrich
/*
44 3c2c32b3 sbeaver
	pfSense_BUILDER_BINARIES:	/usr/bin/netstat
45
	pfSense_MODULE: pkgs
46 13d193c2 Scott Ullrich
*/
47
48 6b07c15a Matthew Grooms
##|+PRIV
49
##|*IDENT=page-status-packagelogs
50
##|*NAME=Status: Package logs page
51
##|*DESCR=Allow access to the 'Status: Package logs' page.
52
##|*MATCH=diag_pkglogs.php*
53
##|-PRIV
54
55 df01982a Colin Smith
require("guiconfig.inc");
56 41fafd53 Warren Baker
require("pkg-utils.inc");
57 df01982a Colin Smith
58 af811174 Colin Smith
if(!($nentries = $config['syslog']['nentries'])) $nentries = 50;
59 df01982a Colin Smith
60 2eb4178b Colin Smith
$i = 0;
61 9fc0d646 Colin Smith
$pkgwithlogging = false;
62 41fafd53 Warren Baker
$apkg = $_GET['pkg'];
63 af811174 Colin Smith
if(!$apkg) { // If we aren't looking for a specific package, locate the first package that handles logging.
64 52da2110 Colin Smith
	if($config['installedpackages']['package'] <> "") {
65 c2eb36d9 Scott Ullrich
		foreach($config['installedpackages']['package'] as $package) {
66 0187cf2a Colin Smith
			if(is_array($package['logging'])) {
67 9fc0d646 Colin Smith
				$pkgwithlogging = true;
68 c2eb36d9 Scott Ullrich
				$apkg = $package['name'];
69
				$apkgid = $i;
70
				break;
71
			}
72
			$i++;
73 2eb4178b Colin Smith
		}
74 42e72ab3 Scott Ullrich
	}
75 af811174 Colin Smith
} elseif($apkg) {
76 2eb4178b Colin Smith
	$apkgid = get_pkg_id($apkg);
77 b67cdd05 Matt Smith
	if ($apkgid != -1) {
78
		$pkgwithlogging = true;
79
		$i = $apkgid;
80
	}
81 2eb4178b Colin Smith
}
82 df01982a Colin Smith
83 0da88d50 cadu
$pgtitle = array(gettext("Status"),gettext("Package logs"));
84 b63695db Scott Ullrich
include("head.inc");
85
86 3c2c32b3 sbeaver
if($pkgwithlogging == false) {
87
	print_info_box(gettext("No packages with logging facilities are currently installed."));
88
} else {
89 41fafd53 Warren Baker
	$tab_array = array();
90 af811174 Colin Smith
	foreach($config['installedpackages']['package'] as $package) {
91
		if(is_array($package['logging'])) {
92 3c2c32b3 sbeaver
			if(!($logtab = $package['logging']['logtab']))
93
				$logtab = $package['name'];
94
95
			if($apkg == $package['name']) {
96 af811174 Colin Smith
				$curtab = $logtab;
97 41fafd53 Warren Baker
				$tab_array[] = array(sprintf(gettext("%s"),$logtab), true, "diag_pkglogs.php?pkg=".$package['name']);
98 af811174 Colin Smith
			} else {
99 41fafd53 Warren Baker
				$tab_array[] = array(sprintf(gettext("%s"),$logtab), false, "diag_pkglogs.php?pkg=".$package['name']);
100 df01982a Colin Smith
			}
101 af811174 Colin Smith
		}
102 3c2c32b3 sbeaver
	}
103 41fafd53 Warren Baker
	display_top_tabs($tab_array);
104 3c2c32b3 sbeaver
?>
105
106
	<div class="panel panel-default">
107 f17594c7 Sjon Hortensius
		<div class="panel-heading"><h2 class="panel-title"><?=printf(gettext('Last %1$s %2$s log entries'),$nentries,$curtab)?></h2></div>
108 59efb129 sbeaver
		<div>class="panel-body">
109
			<pre>
110 3c2c32b3 sbeaver
<?php
111 59efb129 sbeaver
			$package = $config['installedpackages']['package'][$apkgid];
112
			dump_clog_no_table($g['varlog_path'] . '/' . $package['logging']['logfilename'], $nentries, true, array());
113 3c2c32b3 sbeaver
?>
114 59efb129 sbeaver
			</pre>
115
		</div>
116 3c2c32b3 sbeaver
	</div>
117
118
<?php }
119
120
include("foot.inc"); ?>