By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,304 Members | 1,253 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,304 IT Pros & Developers. It's quick & easy.

php-syslog-ng: Help needed desperately...

P: n/a
Has anybody seen this tool? It is awesome. check out
http://vw.vermeer.org/ . It's a php front end for large-scale syslog
deployments. It makes managing syslog in large networks a snap.

The idea is to fifo pipe network syslog into a MySQL database backend.
The php scripts reference the database, and print stuff to the screen.

My Info -> RH9.0 , MySQL 4.0.14, apache1.3.28

I have successfully gotten everything installed, compiled, etc. The
syslog is going to the MySQL database quite nicely. The problem, is
that retreivals are failing completely. When I try to do a search in
the database, I get the following errors...

http://localhost/results.php

Warning: Unknown(/usr/local/apache/htdocs/results.php): failed to open
stream: Permission denied in Unknown on line 0

Warning: (null)(): Failed opening
'/usr/local/apache/htdocs/results.php' for inclusion
(include_path='.:/usr/local/lib/php') in Unknown on line 0

I am happy to post my phpinfo(); if necessary. Everything is pretty
much right out of the box. I am happy to send screenshots if needed...

My pear list is
[root@localhost bin]# pear list
Installed packages:
===================
Package Version State
Archive_Tar 0.9 stable
Console_Getopt 1.0 stable
DB 1.3 stable
HTTP 1.2 stable
Mail 1.0.1 stable
Net_SMTP 1.0 stable
Net_Socket 1.0.1 stable
PEAR 1.1 stable
XML_Parser 1.0.1 stable
XML_RPC 1.0.4 stable
Lastly, I thought I would just post the results.php script... I'm no
programmer, and I can't figure out what reference is failing.

thanks for all your help. I will personally send a cookie to whoever
helps me solve this problem.

Erich Trowbridge

<?php
/*

+-------------------------------------------------------------------------+

| Copyright (C) 2002 Michael Earls
|

|
|

| This program is free software; you can redistribute it and/or
|

| modify it under the terms of the GNU General Public License
|

| as published by the Free Software Foundation; either version 2
|

| of the License, or (at your option) any later version.
|

|
|

| This program is distributed in the hope that it will be useful,
|

| but WITHOUT ANY WARRANTY; without even the implied warranty of
|

| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|

| GNU General Public License for more details.
|

+-------------------------------------------------------------------------+

| php-syslog-ng: php4 mysql syslog-ng
|

+-------------------------------------------------------------------------+

| This code is currently maintained and debugged by Michael Earls, any
|

| questions or comments regarding this code should be directed to:
|

| - mi*****@michaelearls.com
|

+-------------------------------------------------------------------------+

| - vermeer - http://www.vermeer.org/
|

+-------------------------------------------------------------------------+

*/
?>
<html>
<head>
<title>
Network Syslog Search Results
</title>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<link type="text/css" href="results.css" rel="stylesheet"/>
</head>
<!-- <img src="/images/logo"></a> -->
<br>
<h2>Network Syslog Monitor</h2>
<div align="right">
<table border="0" cellpadding="0" cellspacing="0" height="20">
<tr>
<td nowrap><small>INFO</small></td>
<td bgcolor="#C1FFC1" width="20" align="center">DEBUG</td>
<td bgcolor="#CAFF70" width="20" align="center">NOTICE</td>
<td bgcolor="#FFFFOO" width="20" align="center">WARNING</td>
<td bgcolor="#FFA500" width="20" align="center">ERR</td>
<td bgcolor="#FF4500" width="20" align="center">CRIT</td>
<td bgcolor="#FF0000" width="20" align="center">ALERT</td>
<b><font size="2">SEVERITY LEGENED</font></b>
</tr>
</table>
</div>
<a href="index.php">Search</a>
<hr>
<body>
<?php

include("dbinfo.inc.php");

MYSQL_CONNECT($hostname, $username, $password) OR DIE("Unable to
connect to the database");
@mysql_select_db( "$dbName") or die( "Unable to select database");

// begin script

if (isset ($_POST['host'])) { $host = $_POST['host'];
}
if (isset ($_POST['priority'])) { $priority =
$_POST['priority']; }
if (isset ($_POST['date'])) { $date = $_POST['date'];
}
if (isset ($_POST['limit'])) { $limit =
$_POST['limit']; }
if (isset ($_GET['host'])) { $host = $_GET['host']; }
if (isset ($_GET['priority'])) { $priority =
$_GET['priority']; }
if (isset ($_GET['date'])) { $date = $_GET['date']; }
if (isset ($_GET['limit'])) { $limit = $_GET['limit'];
}
if (isset ($_GET['offset'])) { $offset =
$_GET['offset']; }
else {
$offset = 1;
}

mysql_select_db("$dbName");
$where = "";
$query = "SELECT * FROM logs";
if($host!="*")
$where = "host='".$host."' ";
if($priority!="*")
{
if($where!="") $where = $where." AND ";
$where = $where." priority='".$priority."'
";
}
if($date!="*")
{
if($where !="") $where = $where." AND ";
$where = $where." date='".$date."' ";
}
if($where !="")
$query = $query." WHERE ".$where." ORDER BY
time AND date";
else
$query = $query." ORDER BY time AND date";

$result = mysql_query($query);
$num_results = mysql_num_rows($result);

$offsettemp=$offset-1;
$query .= " limit ".$offsettemp.", ".$limit;
$results = mysql_query($query);

echo "<i>Number of Syslog Entries</i>: <b>".$num_results." </b>";

echo "<div align=center>";
echo "<table border=1 width=100%>";
echo "<tr bgcolor=silver>";
echo "<td><b><font color=blue>Seq</b></td>";
echo "<td><b><font color=blue>Host</b></td>";
echo "<td><b><font color=blue>Priority</b></td>";
echo "<td><B><font color=blue>Date</b></td>";
echo "<td><B><font color=blue>Time</b></td>";
echo "<td><B><font color=blue>Message</b></td>";
echo "</tr>";

while ($row = mysql_fetch_array($results))
{
echo "<tr>";
echo "<td>$row[seq]</td>";
echo "<td>$row[host]</td>";
if ($row[priority] == "alert") { echo "<td
bgcolor=\"#FF0000\"><center>$row[priority]</center></td>"; }
elseif ($row[priority] == "crit") { echo "<td
bgcolor=\"#FF4500\"><center>$row[priority]</center></td>"; }
elseif ($row[priority] == "err") { echo "<td
bgcolor=\"#FFA500\"><center>$row[priority]</center></td>"; }
elseif ($row[priority] == "warning") { echo "<td
bgcolor=\"#FFFFOO\"><center>$row[priority]</center></td>"; }
elseif ($row[priority] == "notice") { echo "<td
bgcolor=\"#CAff70\"><center>$row[priority]</center></td>"; }
elseif ($row[priority] == "debug") { echo "<td
bgcolor=\"#C1FFC1\"><center>$row[priority]</center></td>"; }
// elseif ($row[priority] == "info") { echo "<td
bgcolor=\"#C1FFC1\"><center>$row[priority]</center></td>"; }
else {
echo "<td><center>$row[priority]</center></td>"; }
echo "<td>$row[date]</td>";
echo "<td>$row[time]</td>";
echo "<td>".htmlspecialchars($row[msg])."</td>";
echo "</tr>";

}
echo "</table>";
echo "<hr>";
echo "Result Page:&nbsp;&nbsp;&nbsp;&nbsp;";

if ($offset!=1) { // bypass PREV link if offset is 0
$prevoffset=$offset-$limit ;
print "<a href=\"$PHP_SELF?offset=$prevoffset&host=$host&pri ority=$priority&date=$date&limit=$limit\">PREV</a>
&nbsp; \n";
}

$pages=intval($num_results/$limit);

if ($num_results%$limit) {
$pages++;
}

for ($i=1;$i<=$pages;$i++) {
$newoffset=$limit*($i-1)+1;
if ((intval($offset/$limit)+1)==$i )
print "<font size=+1>$i</font>&nbsp; \n";
else
print "<a href=\"$PHP_SELF?offset=$newoffset&host=$host&prio rity=$priority&date=$date&limit=$limit\">$i</a>
&nbsp; \n";
}

if (!(intval($offset/$limit)+1==$pages) && $pages!=1) {
// not last page so give NEXT link
$newoffset=$offset+$limit;
print "<a href=\"$PHP_SELF?offset=$newoffset&host=$host&prio rity=$priority&date=$date&limit=$limit\">NEXT</a>
&nbsp; \n";
}
?>
<a href="index.php">Search</a>
<br>
<br>
</body>
Jul 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
<snip>

The problem was that corrcet permissions were not set on the
results.php file. For the archives, make sure that the correct
permissions exist on the php files. I had copied everything out of the
archive, so it was all owned by user root with 644 permissions, save
for results.php, which was 600. I set the permissions to 644 and
everything works great.

Now I just have to figure out how to not make the plaintext
dbinfo.inc.php globally readable and I'll be set.

Erich Trowbridge
Jul 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.