From 62ff22cae949bd25d2d36c7e06e41cbcc13eebef Mon Sep 17 00:00:00 2001 From: cigamit Date: Mon, 24 Sep 2018 18:04:19 -0500 Subject: [PATCH] Initialize the remove data collector data Without these settings populated there is a possibility of database corruption. --- poller.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/poller.php b/poller.php index 393a471917..f2c86a7060 100644 --- a/poller.php +++ b/poller.php @@ -135,13 +135,30 @@ $phostname = db_fetch_cell_prepared('SELECT hostname array($poller_id), '', true, $poller_db_cnn_id); // update the pollers hostname if it is blank, otherwise allow the user to edit it -if ($phostname == '' || $phostname == 'localhost') { +if ($phostname == '' || $phostname == 'localhost' || $phostname == '127.0.0.1') { db_execute_prepared('UPDATE poller SET hostname = ? WHERE id = ?', array($hostname, $poller_id), true, $poller_db_cnn_id); } +$dbhostname = db_fetch_cell_prepared('SELECT dbhost + FROM poller + WHERE id = ?', + array($poller_id), '', true, $poller_db_cnn_id); + +// update the database hostname based upon the entry +if ($dbhostname == '' || $dbhostname == 'localhost' || $dbhostname == '127.0.0.1') { + if ($database_hostname != 'localhost' && $database_hostname != '127.0.0.1') { + $hostname = $database_hostname; + } + + db_execute_prepared('UPDATE poller + SET dbhost = ? + WHERE id = ?', + array($hostname, $poller_id), true, $poller_db_cnn_id); +} + // if you have more than one poller, boost must be enabled $total_pollers = db_fetch_cell('SELECT COUNT(*) FROM poller'); if ($total_pollers > 1) { @@ -768,6 +785,7 @@ function poller_replicate_check() { WHERE id > 1 AND ((UNIX_TIMESTAMP()-$sync_interval) > UNIX_TIMESTAMP(last_sync) OR last_sync='0000-00-00 00:00:00' OR requires_sync='on') + AND dbhost NOT IN ('localhost', '127.0.0.1', '') AND disabled=''"); foreach($pollers as $poller) {