mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
revert something that broke syslog 2 months ago...
git-svn-id: http://www.observium.org/svn/observer/trunk@2293 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -1,59 +1,36 @@
|
||||
<?php
|
||||
|
||||
function process_syslog ($entry, $update)
|
||||
{
|
||||
function process_syslog ($entry, $update) {
|
||||
|
||||
global $config;
|
||||
|
||||
foreach ($config['syslog_filter'] as $bi)
|
||||
{
|
||||
if (strstr($entry['msg'], $bi) !== FALSE)
|
||||
{
|
||||
foreach($config['syslog_filter'] as $bi) {
|
||||
if (strstr($entry['msg'], $bi)) {
|
||||
$delete = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (strstr($entry['msg'], "diskio.c: don't know how to handle") !== FALSE)
|
||||
{
|
||||
$delete = 1;
|
||||
}
|
||||
$device_id_host = @mysql_result(mysql_query("SELECT device_id FROM devices WHERE `hostname` = '".$entry['host']."' OR `sysName` = '".$entry['host']."'"),0);
|
||||
|
||||
$device_id_host = @dbFetchCell("SELECT device_id FROM devices WHERE `hostname` = '".mres($entry['host'])."' OR `sysName` = '".mres($entry['host'])."'");
|
||||
|
||||
if ($device_id_host)
|
||||
{
|
||||
if($device_id_host) {
|
||||
$entry['device_id'] = $device_id_host;
|
||||
}
|
||||
else
|
||||
{
|
||||
$device_id_ip = @dbFetchCell("SELECT device_id FROM ipv4_addresses AS A, ports AS I WHERE A.ipv4_address = '" . $entry['host']."' AND I.interface_id = A.interface_id");
|
||||
if ($device_id_ip)
|
||||
{
|
||||
} else {
|
||||
$device_id_ip = @mysql_result(mysql_query("SELECT device_id FROM ipv4_addresses AS A, ports AS I WHERE
|
||||
A.ipv4_address = '" . $entry['host']."' AND I.interface_id = A.interface_id"),0);
|
||||
if($device_id_ip) {
|
||||
$entry['device_id'] = $device_id_ip;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($entry['device_id'] && !$delete)
|
||||
{
|
||||
$os = dbFetchCell("SELECT `os` FROM `devices` WHERE `device_id` = '".mres($entry['device_id'])."'");
|
||||
if ($os == 'catos')
|
||||
{
|
||||
$matches = array();
|
||||
preg_match('#%(?P<program>[A-Z0-9\-_]*):(?P<msg>(.*))#', $entry['msg'], $matches);
|
||||
$entry['msg'] = $matches['msg'];
|
||||
$entry['program'] = $matches['program'];
|
||||
unset($matches);
|
||||
}
|
||||
elseif ($os == "ios" || $os == "iosxe")
|
||||
{
|
||||
if (strstr($entry[msg], "%"))
|
||||
{
|
||||
if($entry['device_id'] && !$delete) {
|
||||
$os = mysql_result(mysql_query("SELECT `os` FROM `devices` WHERE `device_id` = '".$entry['device_id']."'"),0);
|
||||
if($os == "ios" || $os == "iosxe") {
|
||||
if(strstr($entry[msg], "%")) {
|
||||
$entry['msg'] = preg_replace("/^%(.+?):\ /", "\\1||", $entry['msg']);
|
||||
list(,$entry[msg]) = explode(": %", $entry['msg']);
|
||||
list(,$entry[msg]) = split(": %", $entry['msg']);
|
||||
$entry['msg'] = "%" . $entry['msg'];
|
||||
$entry['msg'] = preg_replace("/^%(.+?):\ /", "\\1||", $entry['msg']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$entry['msg'] = preg_replace("/^%(.+?):\ /", "\\1||", $entry['msg']);
|
||||
} else {
|
||||
$entry['msg'] = preg_replace("/^.*[0-9]:/", "", $entry['msg']);
|
||||
$entry['msg'] = preg_replace("/^[0-9][0-9]\ [A-Z]{3}:/", "", $entry['msg']);
|
||||
$entry['msg'] = preg_replace("/^(.+?):\ /", "\\1||", $entry['msg']);
|
||||
@@ -65,37 +42,34 @@ function process_syslog ($entry, $update)
|
||||
list($entry['program'], $entry['msg']) = explode("||", $entry['msg']);
|
||||
$entry['msg'] = preg_replace("/^[0-9]+:/", "", $entry['msg']);
|
||||
|
||||
if (!$entry['program'])
|
||||
{
|
||||
if(!$entry['program']) {
|
||||
$entry['msg'] = preg_replace("/^([0-9A-Z\-]+?):\ /", "\\1||", $entry['msg']);
|
||||
list($entry['program'], $entry['msg']) = explode("||", $entry['msg']);
|
||||
}
|
||||
|
||||
if (!$entry['msg']) { $entry['msg'] = $entry['program']; unset ($entry['program']); }
|
||||
if(!$entry['msg']) { $entry['msg'] = $entry['program']; unset ($entry['program']); }
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$program = preg_quote($entry['program'],'/');
|
||||
$entry['msg'] = preg_replace("/^$program:\ /", "", $entry['msg']);
|
||||
# if (preg_match("/^[a-zA-Z\/]+\[[0-9]+\]:/", $entry['msg'])) {
|
||||
# if(preg_match("/^[a-zA-Z\/]+\[[0-9]+\]:/", $entry['msg'])) {
|
||||
$entry['msg'] = preg_replace("/^(.+?)\[[0-9]+\]:\ /", "\\1||", $entry['msg']);
|
||||
if (!strstr($entry['msg'], "||")) { $entry['msg'] = preg_replace("/^(.+?):\ /", "\\1||", $entry['msg']); }
|
||||
if(!strstr($entry['msg'], "||")) { $entry['msg'] = preg_replace("/^(.+?):\ /", "\\1||", $entry['msg']);}
|
||||
list($entry['program'], $entry['msg']) = explode("||", $entry['msg']);
|
||||
$entry['program'] = preg_replace("@\-[0-9]+@", "", $entry['program']);
|
||||
# }
|
||||
}
|
||||
$entry['program'] = strtoupper($entry['program']);
|
||||
#$x = "UPDATE `syslog` set `device_id` = '".$entry['device_id']."', `program` = '".$entry['program']."', `msg` = '" . mres($entry['msg']) . "', processed = '1' WHERE `seq` = '" . $entry['seq'] . "'";
|
||||
|
||||
$insert_array = array('device_id' => $entry['device_id'], 'program' => $entry['program'], 'facility' => $entry['facility'], 'priority' => $entry['priority'],
|
||||
'level' => $entry['level'], 'tag' => $entry['tag'], 'msg' => $entry['msg'], 'timestamp' => $entry['timestamp']);
|
||||
|
||||
if ($update && $entry['device_id']) { dbInsert($insert_array, 'syslog'); }
|
||||
$x = "UPDATE `syslog` set `device_id` = '".$entry['device_id']."', `program` = '".$entry['program']."', `msg` = '" . mres($entry['msg']) . "', processed = '1' WHERE `seq` = '" . $entry['seq'] . "'";
|
||||
$x = "INSERT INTO `syslog` (`device_id`,`program`,`facility`,`priority`, `level`, `tag`, `msg`, `timestamp`) ";
|
||||
$x .= "VALUES ('".$entry['device_id']."','".$entry['program']."','".$entry['facility']."','".$entry['priority']."', '".$entry['level']."', '".$entry['tag']."', '".$entry['msg']."','".$entry['timestamp']."')";
|
||||
if($update && $entry['device_id']) { mysql_query($x); }
|
||||
unset ($fix);
|
||||
} else { print_r($entry); echo("D-$delete"); }
|
||||
} else { print_r($entry); echo("D-$delete");}
|
||||
|
||||
return $entry;
|
||||
|
||||
return $entry;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
Reference in New Issue
Block a user