Skip to content

Commit 5f6f3e0

Browse files
committed
Fixing Issue #111
Can not load host table when use different syslog server
1 parent fd2563b commit 5f6f3e0

2 files changed

Lines changed: 34 additions & 19 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ that.
166166

167167
* issue#110: Syslog Alerts cause DB errors
168168

169+
* issue#111: Can not load host table when use different syslog server
170+
169171
* issue: Massive performance improvement in statistics page rendering
170172

171173
--- 2.5 ---

syslog.php

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -432,21 +432,27 @@ function syslog_stats_filter() {
432432
<option value='-1'<?php if (get_request_var('host') == '-1') { ?> selected<?php } ?>><?php print __('All', 'syslog');?></option>
433433
<option value='-2'<?php if (get_request_var('host') == '-2') { ?> selected<?php } ?>><?php print __('None', 'syslog');?></option>
434434
<?php
435-
$hosts = syslog_db_fetch_assoc('SELECT DISTINCT sh.host_id, sh.host, h.id
436-
FROM `' . $syslogdb_default . '`.`syslog_hosts` AS sh
437-
LEFT JOIN host AS h
438-
ON sh.host = h.hostname
439-
OR sh.host = h.description
440-
OR sh.host LIKE substring_index(h.hostname, ".", 1)
441-
OR sh.host LIKE substring_index(h.description, ".", 1)
442-
ORDER BY host');
435+
if (syslog_db_table_exists('host', false)) {
436+
$hosts = syslog_db_fetch_assoc('SELECT DISTINCT sh.host_id, sh.host, h.id
437+
FROM `' . $syslogdb_default . '`.`syslog_hosts` AS sh
438+
LEFT JOIN host AS h
439+
ON sh.host = h.hostname
440+
OR sh.host = h.description
441+
OR sh.host LIKE substring_index(h.hostname, ".", 1)
442+
OR sh.host LIKE substring_index(h.description, ".", 1)
443+
ORDER BY host');
444+
} else {
445+
$hosts = syslog_db_fetch_assoc('SELECT DISTINCT sh.host_id, sh.host, "0" AS id
446+
FROM `' . $syslogdb_default . '`.`syslog_hosts` AS sh
447+
ORDER BY host');
448+
}
443449

444450
if (cacti_sizeof($hosts)) {
445451
foreach ($hosts as $host) {
446452
if (!empty($host['id'])) {
447453
$class = get_device_leaf_class($host['id']);
448454
} else {
449-
$class = 'deviceUnknown';
455+
$class = 'deviceUp';
450456
}
451457

452458
print '<option class="' . $class . '" value="' . $host['host_id'] . '"'; if (get_request_var('host') == $host['host_id']) { print ' selected'; } print '>' . $host['host'] . '</option>';
@@ -1315,15 +1321,22 @@ function timeshiftFilterRight() {
13151321
$hosts_where = '';
13161322
$hosts_where = api_plugin_hook_function('syslog_hosts_where', $hosts_where);
13171323

1318-
$hosts = syslog_db_fetch_assoc("SELECT sh.host_id, sh.host, h.id
1319-
FROM `" . $syslogdb_default . "`.`syslog_hosts` AS sh
1320-
LEFT JOIN host AS h
1321-
ON sh.host = h.hostname
1322-
OR sh.host = h.description
1323-
OR sh.host LIKE substring_index(h.hostname, '.', 1)
1324-
OR sh.host LIKE substring_index(h.description, '.', 1)
1325-
$hosts_where
1326-
ORDER BY host");
1324+
if (syslog_db_table_exists('host', false)) {
1325+
$hosts = syslog_db_fetch_assoc('SELECT DISTINCT sh.host_id, sh.host, h.id
1326+
FROM `' . $syslogdb_default . "`.`syslog_hosts` AS sh
1327+
LEFT JOIN host AS h
1328+
ON sh.host = h.hostname
1329+
OR sh.host = h.description
1330+
OR sh.host LIKE substring_index(h.hostname, '.', 1)
1331+
OR sh.host LIKE substring_index(h.description, '.', 1)
1332+
$hosts_where
1333+
ORDER BY host");
1334+
} else {
1335+
$hosts = syslog_db_fetch_assoc('SELECT DISTINCT sh.host_id, sh.host, "0" AS id
1336+
FROM `' . $syslogdb_default . "`.`syslog_hosts` AS sh
1337+
$hosts_where
1338+
ORDER BY host");
1339+
}
13271340

13281341
$selected = explode(',', get_request_var('host'));
13291342

@@ -1337,7 +1350,7 @@ function timeshiftFilterRight() {
13371350
if (!empty($host['id'])) {
13381351
$class = get_device_leaf_class($host['id']);
13391352
} else {
1340-
$class = 'deviceUnknown';
1353+
$class = 'deviceUp';
13411354
}
13421355

13431356
print "<option class='$class' value='" . $host['host_id'] . "'";

0 commit comments

Comments
 (0)