Skip to content

Commit cb305a2

Browse files
committed
Syslog stats not reporting properly
1 parent 8f8cc00 commit cb305a2

3 files changed

Lines changed: 16 additions & 10 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ that.
155155

156156
## ChangeLog
157157

158+
--- develop ---
159+
160+
* issue: Syslog stats not reporting properly
161+
158162
--- 2.8 ---
159163

160164
* issue#115: Some field where not corrected following the version change

functions.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ function syslog_remove_items($table, $uniqueID) {
284284
WHERE facility_id = ' . $facility_id;
285285
}
286286
}
287-
}elseif ($remove['type'] == 'host') {
287+
} elseif ($remove['type'] == 'host') {
288288
if ($table == 'syslog_incoming') {
289289
if ($remove['method'] != 'del') {
290290
$sql1 = 'INSERT INTO `' . $syslogdb_default . '`.`syslog_removed`
@@ -444,7 +444,7 @@ function syslog_remove_items($table, $uniqueID) {
444444
WHERE message LIKE ' . db_qstr('%' . $remove['message']);
445445
}
446446
}
447-
}elseif ($remove['type'] == 'sql') {
447+
} elseif ($remove['type'] == 'sql') {
448448
if ($table == 'syslog_incoming') {
449449
if ($remove['method'] != 'del') {
450450
$sql1 = 'INSERT INTO `' . $syslogdb_default . '`.`syslog_removed`
@@ -508,8 +508,6 @@ function syslog_remove_items($table, $uniqueID) {
508508
}
509509
}
510510

511-
if ($removed == 0) $xferred = $total;
512-
513511
return array('removed' => $removed, 'xferred' => $xferred);
514512
}
515513

@@ -598,7 +596,7 @@ function sql_hosts_where($tab) {
598596
}
599597
}
600598

601-
if (sizeof($hosts_array)) {
599+
if (cacti_sizeof($hosts_array)) {
602600
$hostfilter_log = ' host IN(' . implode(',', $hosts_array) . ')';
603601
}
604602

@@ -717,7 +715,7 @@ function syslog_debug($message) {
717715
global $syslog_debug;
718716

719717
if ($syslog_debug) {
720-
echo 'SYSLOG: ' . trim($message) . "\n";
718+
print 'SYSLOG: ' . trim($message) . "\n";
721719
}
722720
}
723721

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

769767
if (cacti_sizeof($hosts)) {
770-
foreach($hosts as $host){
768+
foreach($hosts as $host) {
771769
$save['host'] = $host;
772770
api_plugin_hook_function('syslog_update_hostsalarm', $save);
773771
}

syslog_process.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,15 @@
176176
syslog_debug('Unique ID = ' . $uniqueID);
177177

178178
/* flag all records with the uniqueID prior to moving */
179-
syslog_db_execute('UPDATE `' . $syslogdb_default . '`.`syslog_incoming` SET status=' . $uniqueID . ' WHERE status=0');
179+
syslog_db_execute('UPDATE `' . $syslogdb_default . '`.`syslog_incoming`
180+
SET status = ' . $uniqueID . '
181+
WHERE status = 0');
180182

181183
api_plugin_hook('plugin_syslog_before_processing');
182184

183-
$syslog_incoming = db_affected_rows($syslog_cnn);
185+
$syslog_incoming = db_fetch_cell('SELECT COUNT(seq)
186+
FROM `' . $syslogdb_default . '`.`syslog_incoming`
187+
WHERE status = ' . $uniqueID);
184188

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

@@ -191,7 +195,7 @@
191195

192196
foreach($domains as $domain) {
193197
syslog_db_execute('UPDATE `' . $syslogdb_default . "`.`syslog_incoming`
194-
SET host=SUBSTRING_INDEX(host,'.',1)
198+
SET host = SUBSTRING_INDEX(host, '.', 1)
195199
WHERE host LIKE '%$domain'");
196200
}
197201
}

0 commit comments

Comments
 (0)