1 |
df01982a
|
Colin Smith
|
#!/usr/local/bin/php
|
2 |
|
|
<?php
|
3 |
|
|
/*
|
4 |
2eb4178b
|
Colin Smith
|
$Id$
|
5 |
|
|
|
6 |
df01982a
|
Colin Smith
|
diag_pkglogs.php
|
7 |
|
|
Copyright (C) 2005 Colin Smith
|
8 |
|
|
All rights reserved.
|
9 |
|
|
|
10 |
|
|
Redistribution and use in source and binary forms, with or without
|
11 |
|
|
modification, are permitted provided that the following conditions are met:
|
12 |
|
|
|
13 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
14 |
|
|
this list of conditions and the following disclaimer.
|
15 |
|
|
|
16 |
|
|
2. Redistributions in binary form must reproduce the above copyright
|
17 |
|
|
notice, this list of conditions and the following disclaimer in the
|
18 |
|
|
documentation and/or other materials provided with the distribution.
|
19 |
|
|
|
20 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
21 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
22 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
23 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
30 |
825275fa
|
Colin Smith
|
|
31 |
|
|
<logging>
|
32 |
|
|
<logtab>arpwatch</logtab>
|
33 |
|
|
<grepfor>arpwatch</logtab>
|
34 |
|
|
</logging>
|
35 |
|
|
|
36 |
|
|
<invertgrep/>
|
37 |
|
|
<logfile>/var/log/arpwatch.log</logfile>
|
38 |
|
|
|
39 |
df01982a
|
Colin Smith
|
*/
|
40 |
|
|
|
41 |
|
|
require("guiconfig.inc");
|
42 |
af811174
|
Colin Smith
|
//require_once("pkg-utils.inc");
|
43 |
df01982a
|
Colin Smith
|
|
44 |
af811174
|
Colin Smith
|
if(!($nentries = $config['syslog']['nentries'])) $nentries = 50;
|
45 |
df01982a
|
Colin Smith
|
|
46 |
|
|
if ($_POST['clear']) {
|
47 |
0187cf2a
|
Colin Smith
|
exec("/usr/sbin/clog -i -s 262144 {$logfile}");
|
48 |
df01982a
|
Colin Smith
|
}
|
49 |
2eb4178b
|
Colin Smith
|
$i = 0;
|
50 |
9fc0d646
|
Colin Smith
|
$pkgwithlogging = false;
|
51 |
2eb4178b
|
Colin Smith
|
$apkg = $_POST['pkg'];
|
52 |
af811174
|
Colin Smith
|
if(!$apkg) { // If we aren't looking for a specific package, locate the first package that handles logging.
|
53 |
52da2110
|
Colin Smith
|
if($config['installedpackages']['package'] <> "") {
|
54 |
c2eb36d9
|
Scott Ullrich
|
foreach($config['installedpackages']['package'] as $package) {
|
55 |
0187cf2a
|
Colin Smith
|
if(is_array($package['logging'])) {
|
56 |
9fc0d646
|
Colin Smith
|
$pkgwithlogging = true;
|
57 |
c2eb36d9
|
Scott Ullrich
|
$apkg = $package['name'];
|
58 |
|
|
$apkgid = $i;
|
59 |
|
|
break;
|
60 |
|
|
}
|
61 |
|
|
$i++;
|
62 |
2eb4178b
|
Colin Smith
|
}
|
63 |
42e72ab3
|
Scott Ullrich
|
}
|
64 |
af811174
|
Colin Smith
|
} elseif($apkg) {
|
65 |
9fc0d646
|
Colin Smith
|
$pkgwithlogging = true;
|
66 |
2eb4178b
|
Colin Smith
|
$apkgid = get_pkg_id($apkg);
|
67 |
52da2110
|
Colin Smith
|
$i = $apkgid;
|
68 |
2eb4178b
|
Colin Smith
|
}
|
69 |
df01982a
|
Colin Smith
|
|
70 |
b63695db
|
Scott Ullrich
|
$pgtitle = "Diagnostics: Package logs";
|
71 |
|
|
include("head.inc");
|
72 |
|
|
|
73 |
|
|
?>
|
74 |
df01982a
|
Colin Smith
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
75 |
|
|
<?php include("fbegin.inc"); ?>
|
76 |
310b2c06
|
Bill Marquette
|
<p class="pgtitle"><?=$pgtitle?></p>
|
77 |
df01982a
|
Colin Smith
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
78 |
|
|
<tr><td>
|
79 |
|
|
<ul id="tabnav">
|
80 |
|
|
<?php
|
81 |
af811174
|
Colin Smith
|
if($pkgwithlogging == false) {
|
82 |
64d08e72
|
Colin Smith
|
print_info_box("No packages with logging facilities are currently installed.");
|
83 |
af811174
|
Colin Smith
|
echo '</ul></td></tr></table>';
|
84 |
42e72ab3
|
Scott Ullrich
|
include("fend.inc");
|
85 |
52da2110
|
Colin Smith
|
exit;
|
86 |
42e72ab3
|
Scott Ullrich
|
}
|
87 |
af811174
|
Colin Smith
|
foreach($config['installedpackages']['package'] as $package) {
|
88 |
|
|
if(is_array($package['logging'])) {
|
89 |
|
|
if(!($logtab = $package['logging']['logtab'])) $logtab = $package['name'];
|
90 |
|
|
if($apkg == $package['name']) {
|
91 |
|
|
$curtab = $logtab;
|
92 |
|
|
echo '<li class="tabact">' . $logtab . '</li>';
|
93 |
|
|
} else {
|
94 |
|
|
Echo '<li class="tabinact"><a href="diag_pkglogs.php?pkg=' . htmlspecialchars($package['name']) . '">' . $logtab . '</a></li>';
|
95 |
df01982a
|
Colin Smith
|
}
|
96 |
af811174
|
Colin Smith
|
}
|
97 |
|
|
}
|
98 |
df01982a
|
Colin Smith
|
?>
|
99 |
|
|
</ul>
|
100 |
|
|
</td></tr>
|
101 |
|
|
<tr>
|
102 |
|
|
<td class="tabcont">
|
103 |
|
|
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
104 |
|
|
<tr>
|
105 |
|
|
<td colspan="2" class="listtopic">
|
106 |
af811174
|
Colin Smith
|
Last <?= $nentries ?> <?= $curtab ?> log entries</td>
|
107 |
df01982a
|
Colin Smith
|
</tr>
|
108 |
|
|
<?php
|
109 |
af811174
|
Colin Smith
|
$package =& $config['installedpackages']['package'][$apkgid];
|
110 |
|
|
dump_clog($g['varlog_path'] . '/' . $package['logging']['logfilename'], $nentries);
|
111 |
df01982a
|
Colin Smith
|
?>
|
112 |
|
|
</table>
|
113 |
52da2110
|
Colin Smith
|
<br>
|
114 |
|
|
<!--
|
115 |
|
|
<form action="diag_pkglogs.php" method="post">
|
116 |
df01982a
|
Colin Smith
|
<input name="clear" type="submit" class="formbtn" value="Clear log">
|
117 |
|
|
</form>
|
118 |
52da2110
|
Colin Smith
|
-->
|
119 |
df01982a
|
Colin Smith
|
</td>
|
120 |
|
|
</tr>
|
121 |
|
|
</table>
|
122 |
|
|
<?php include("fend.inc"); ?>
|
123 |
|
|
</body>
|
124 |
|
|
</html>
|