I reloaded the syslog plugin last night and I am still not seeing anything in the alerts, removals, or reports pages. But there is information in the database tables for each of the related tables.
Last night I also recieved an email from the syslog plugin so that is working also.
I have been looking at the code in the syslog_alert.php file and the error is generated from this section:
Code: Select all
$text = '';
if ($id > 0) {
$text = db_fetch_cell("SELECT " . $syslog_config["textField"] . " FROM " . $syslog_config["syslogTable"] . " where " . $syslog_config["id"] . "=" . $id);
$x = strpos($text, ':');
$y = strpos($text, ' ', $x + 2);
$text = substr($text, 0, $y);
}
disyplay_edit($text);
The line with
is where it is failing with the following error:
Warning: strpos() [function.strpos]: Offset not contained in string. in C:\Inetpub\wwwroot\cacti\plugins\syslog\syslog_alert.php on line 89
A typical message in my syslog table looks like this:
Code: Select all
EvntSLog:342107: [ERR] Wed Oct 17 09:38:22 2007: MYDOMAIN/MYSERVER/DCOM (10010) - "The server {2C5DFFB3-472F-11CE-A030-00AA00339A98} did not register with DCOM within the required timeout."
I am not very good at php, but it looks like the code checks to make sure that url query string contains a value of "id" and make sure it is grater than zero. then fetch the message field from he syslog table where the id fields match. Then set
to the numerical posistion of where ":" is found int he message field from the recordset. Then it sets
to the numerical posistion of where it finds ' ' (a space) with an offset of
. So set
to a posistion of where it finds a space in the message field and start at the location where it finds ":" in the message plus 2 characters. T
Then the script sets
. I am assuming this substitutes a "0" for the spot the
is set to.
Not sure why all this manipulation, but with the error of "Offset not contained in string." I am assumeing that a space cannot be found in the posistion that the script is trying to set
to.
If you remove the "offset' part of the code, the error goes away, but I am not sure what concequences this may have down the road.
---- now for the other problem ----
I have not figured out why the alert page does not show any alerts from the table, even though there are alerts present.
Here is the code and maybe someone more knowledgable in php can see something I dont.
Code: Select all
function display_alertss () {
global $colors, $sql_where, $hostfilter, $config, $types;
include("./include/config_arrays.php");
include('plugins/syslog/config.php');
$syslog_config["rows_per_page"] = read_config_option("num_rows_syslog");
$url_curr_page = get_browser_query_string();
$syslog_alerts = db_fetch_assoc("SELECT * FROM " . $syslog_config["alertTable"] . ' LIMIT ' . $syslog_config["rows_per_page"]*($_REQUEST["page"]-1) . ', ' . $syslog_config["rows_per_page"]);
?>
<center><h1>Syslog Alerts</h1>All items in this table will be alerted on.<br><table width="50%" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#ffffff" height="8" style="background-image: url(images/shadow.gif); background-repeat: repeat-x;">
</td>
</tr>
<tr>
<td width="100%" valign="top" style="padding: 5px;">
<?php
$total_rows = db_fetch_cell("SELECT count(*) from " . $syslog_config["alertTable"]);
html_start_box("", "98%", $colors["header"], "3", "center", "");
$nav = "<tr bgcolor='#" . $colors["header"] . "'>
<td colspan='8'>
<table width='100%' cellspacing='0' cellpadding='0' border='0'>
<tr>
<td align='left' class='textHeaderDark'>
<strong><< "; if (isset($_REQUEST["page"]) && $_REQUEST["page"] > 1) { $nav .= "<a class='linkOverDark' href='" . get_query_edited_url($url_curr_page, 'page', ($_REQUEST["page"]-1)) . "'>"; } $nav .= "Previous"; if (isset($_REQUEST["page"]) && $_REQUEST["page"] > 1) { $nav .= "</a>"; } $nav .= "</strong>
</td>\n
<td align='center' class='textHeaderDark'>
Showing Rows " . (($syslog_config["rows_per_page"]*($_REQUEST["page"]-1))+1) . " to " . ((($total_rows < $syslog_config["rows_per_page"]) || ($total_rows < ($syslog_config["rows_per_page"]*$_REQUEST["page"]))) ? $total_rows : ($syslog_config["rows_per_page"]*$_REQUEST["page"])) . " of $total_rows [" . syslog_page_select($total_rows) . "]
</td>\n
<td align='right' class='textHeaderDark'>
<strong>"; if (isset($_REQUEST["page"]) && ($_REQUEST["page"] * $syslog_config["rows_per_page"]) < $total_rows) { $nav .= "<a class='linkOverDark' href='" . get_query_edited_url($url_curr_page, 'page', ($_REQUEST["page"]+1)) . "'>"; } $nav .= "Next"; if (($_REQUEST["page"] * $syslog_config["rows_per_page"]) < $total_rows) { $nav .= "</a>"; } $nav .= " >></strong>
</td>\n
</tr>
</table>
</td>
</tr>\n";
print " $nav
<tr bgcolor='#" . $colors["header_panel"] . "'>
<td class='textSubHeaderDark'>Name</td>
<td class='textSubHeaderDark'>Type</td>
<td class='textSubHeaderDark'>Text</td>
<td class='textSubHeaderDark'>Email</td>
<td class='textSubHeaderDark'> </td>
<td class='textSubHeaderDark'>User</td>
<td class='textSubHeaderDark'>Date</td>
<td class='textSubHeaderDark'>Options</td>
</tr>\n";
$i = 0;
if (sizeof($syslog_alerts) > 0) {
foreach ($syslog_alerts as $syslog_message) {
syslog_row_color($colors["alternate"],$colors["light"],$i,$colors["alternate"]); $i++;
?>
<td nowrap valign=top>
<?php print $syslog_message['name']; ?>
</td>
<td nowrap valign=top>
<?php print $types[$syslog_message['type']]; ?>
</td>
<td nowrap valign=top>
<?php print $syslog_message['message']; ?>
</td>
<td nowrap valign=top>
<?php print $syslog_message['email']; ?>
</td>
<td nowrap>
<?php print " ";?>
</td>
<td valign=top>
<?php print $syslog_message['user']; ?>
</td>
<td nowrap valign=top>
<?php print date("F j, Y, g:i a", $syslog_message['date']); ?>
</td>
<td nowrap valign=top>
<center><a href='syslog_alert.php?remove=<?php print $syslog_message['id']; ?>'><img src='images/red.gif' border=0></a></center>
</td>
</tr>
<?php
}
}else{
print "<tr><td><em>No Messages</em></td></tr>";
}
/* put the nav bar on the bottom as well */
print $nav;
html_end_box(false);
?>
</td>
</tr>
</table></center>
<?php
}
?>
any help or suggestions would be much appreciated!
Also, i noticed that I dont see any color coding with syslog messages... not a critical thing, but i will have to work on that in the future.