From dc7ffe84e970d910dfb2b3e0e9f1b47cd81fbf55 Mon Sep 17 00:00:00 2001 From: cigamit Date: Wed, 7 Feb 2018 17:04:52 -0600 Subject: [PATCH] Resolving Issue #1305 Realtime not working for the main data collector. --- cmd_realtime.php | 16 +++++++++++----- docs/CHANGELOG | 1 + graph_realtime.php | 4 ++-- include/realtime.js | 13 +++++++++---- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/cmd_realtime.php b/cmd_realtime.php index b8a3d1355b..79dfb90e22 100644 --- a/cmd_realtime.php +++ b/cmd_realtime.php @@ -83,15 +83,17 @@ if (!count($local_data_ids)) { exit(-1); } -$ids = array(); -$hosts = array(); +$ids = array(); +$hosts = array(); +$idbyhost = array(); + foreach ($local_data_ids as $row) { $ids[$row['local_data_id']] = $row['local_data_id']; $hosts[$row['host_id']] = $row['host_id']; + $idbyhost[$row['host_id']][] = $row['local_data_id']; } - $print_data_to_stdout = true; if (sizeof($idbyhost)) { @@ -179,7 +181,7 @@ if (sizeof($idbyhost)) { $poller_items = db_fetch_assoc_prepared('SELECT * FROM poller_item WHERE host_id = ? - AND local_data_id IN(' . implode(',', $local_data_ids) . ')', + AND local_data_id IN(' . implode(',', $local_data_ids['local_data_ids']) . ')', array($host_id)); if (sizeof($poller_items)) { @@ -189,7 +191,10 @@ if (sizeof($idbyhost)) { if (($item['snmp_version'] == 0) || (($item['snmp_community'] == '') && ($item['snmp_version'] != 3))) { $output = 'U'; } else { - $host = db_fetch_row_prepared('SELECT ping_retries, max_oids FROM host WHERE id = ?', array($host_id)); + $host = db_fetch_row_prepared('SELECT ping_retries, max_oids + FROM host + WHERE id = ?', + array($host_id)); if (!sizeof($host)) { $host['ping_retries'] = 1; @@ -276,3 +281,4 @@ if (sizeof($idbyhost)) { $return_value = proc_close($cactiphp); } } + diff --git a/docs/CHANGELOG b/docs/CHANGELOG index 93d8953cae..51d829a703 100644 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -19,6 +19,7 @@ Cacti CHANGELOG -issue#1306: Fix issue #1306 where multi-value args are not parsing correctly -issue#1309: Provide meaningful authentication errors in graph_json.php and graph_image.php -issue#1310: Unable to return to previous page from auth_changepassword.php +-issue#1315: Realtime not working on local data collector 1.1.34 -issue#1040: PHP version 7.2 - ERROR PHP WARNING: sizeof() diff --git a/graph_realtime.php b/graph_realtime.php index bbf3348136..1f8fee4ba7 100644 --- a/graph_realtime.php +++ b/graph_realtime.php @@ -228,7 +228,7 @@ $selectedTheme = get_selected_theme(); - $text) { printf('', @@ -242,7 +242,7 @@ $selectedTheme = get_selected_theme(); - $text) { printf('', diff --git a/include/realtime.js b/include/realtime.js index 28c3db87f5..95ee3f10bc 100644 --- a/include/realtime.js +++ b/include/realtime.js @@ -30,7 +30,12 @@ function imageOptionsChanged(action) { graph_start = $("#graph_start").val(); graph_end = 0; ds_step = $("#ds_step").val(); - local_graph_id = $('#local_graph_id').val(); + + if ($('#local_graph_id').length) { + local_graph_id = $('#local_graph_id').val(); + } else { + local_graph_id = 0; + } if (rtWidth == 0) { rtWidth = $(window).width(); @@ -40,18 +45,17 @@ function imageOptionsChanged(action) { rtHeight = $(window).height()+50; } - url="?top=0&left=0&action="+action+"&local_graph_id="+local_graph_id+"&graph_start=-"+graph_start+"&ds_step="+ds_step+"&count="+count; + url="graph_realtime.php?top=0&left=0&action="+action+"&local_graph_id="+local_graph_id+"&graph_start=-"+graph_start+"&ds_step="+ds_step+"&count="+count; Pace.stop; $.getJSON(url) - .success(function(data) { + .done(function(data) { $('#image').empty().append(''); }) .fail(function(data) { getPresentHTTPError(data); }); - } function stopRealtime() { @@ -158,3 +162,4 @@ function realtimeGrapher() { realtimeTimer = setTimeout('realtimeGrapher()', $('#ds_step').val()*1000); } } +