Skip to content

Commit

Permalink
Syslog stats not reporting properly
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWitness committed Mar 12, 2020
1 parent 8f8cc00 commit cb305a2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ that.

## ChangeLog

--- develop ---

* issue: Syslog stats not reporting properly

--- 2.8 ---

* issue#115: Some field where not corrected following the version change
Expand Down
12 changes: 5 additions & 7 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ function syslog_remove_items($table, $uniqueID) {
WHERE facility_id = ' . $facility_id;
}
}
}elseif ($remove['type'] == 'host') {
} elseif ($remove['type'] == 'host') {
if ($table == 'syslog_incoming') {
if ($remove['method'] != 'del') {
$sql1 = 'INSERT INTO `' . $syslogdb_default . '`.`syslog_removed`
Expand Down Expand Up @@ -444,7 +444,7 @@ function syslog_remove_items($table, $uniqueID) {
WHERE message LIKE ' . db_qstr('%' . $remove['message']);
}
}
}elseif ($remove['type'] == 'sql') {
} elseif ($remove['type'] == 'sql') {
if ($table == 'syslog_incoming') {
if ($remove['method'] != 'del') {
$sql1 = 'INSERT INTO `' . $syslogdb_default . '`.`syslog_removed`
Expand Down Expand Up @@ -508,8 +508,6 @@ function syslog_remove_items($table, $uniqueID) {
}
}

if ($removed == 0) $xferred = $total;

return array('removed' => $removed, 'xferred' => $xferred);
}

Expand Down Expand Up @@ -598,7 +596,7 @@ function sql_hosts_where($tab) {
}
}

if (sizeof($hosts_array)) {
if (cacti_sizeof($hosts_array)) {
$hostfilter_log = ' host IN(' . implode(',', $hosts_array) . ')';
}

Expand Down Expand Up @@ -717,7 +715,7 @@ function syslog_debug($message) {
global $syslog_debug;

if ($syslog_debug) {
echo 'SYSLOG: ' . trim($message) . "\n";
print 'SYSLOG: ' . trim($message) . "\n";
}
}

Expand Down Expand Up @@ -767,7 +765,7 @@ function syslog_log_alert($alert_id, $alert_name, $severity, $msg, $count = 1, $
$save['alert_name'] = $alert_name;

if (cacti_sizeof($hosts)) {
foreach($hosts as $host){
foreach($hosts as $host) {
$save['host'] = $host;
api_plugin_hook_function('syslog_update_hostsalarm', $save);
}
Expand Down
10 changes: 7 additions & 3 deletions syslog_process.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,15 @@
syslog_debug('Unique ID = ' . $uniqueID);

/* flag all records with the uniqueID prior to moving */
syslog_db_execute('UPDATE `' . $syslogdb_default . '`.`syslog_incoming` SET status=' . $uniqueID . ' WHERE status=0');
syslog_db_execute('UPDATE `' . $syslogdb_default . '`.`syslog_incoming`
SET status = ' . $uniqueID . '
WHERE status = 0');

api_plugin_hook('plugin_syslog_before_processing');

$syslog_incoming = db_affected_rows($syslog_cnn);
$syslog_incoming = db_fetch_cell('SELECT COUNT(seq)
FROM `' . $syslogdb_default . '`.`syslog_incoming`
WHERE status = ' . $uniqueID);

syslog_debug('Found ' . $syslog_incoming . ', New Message(s) to process');

Expand All @@ -191,7 +195,7 @@

foreach($domains as $domain) {
syslog_db_execute('UPDATE `' . $syslogdb_default . "`.`syslog_incoming`
SET host=SUBSTRING_INDEX(host,'.',1)
SET host = SUBSTRING_INDEX(host, '.', 1)
WHERE host LIKE '%$domain'");
}
}
Expand Down

0 comments on commit cb305a2

Please sign in to comment.