mirror of
https://github.com/Cacti/cacti.git
synced 2026-12-05 14:44:14 +09:00
Resolving Issue #970
- Resource Cache does not properly cache in plugin sub-directores on remote data collectors. - Adding small feature to allow purging/rebuilding of the resource cache from the Cacti Utilities page - Backporting some html_escape() function calls replacing htmlspecialchars() on the Utilities page due to scope of change. - Updating cacti.pot due to minor feature enhancement.
This commit is contained in:
1 parent
4680aa3a7e
commit
6ec1131b26
5 files changed
+5982
-6117
No files matched your search
@@ -6,7 +6,9 @@ Cacti CHANGELOG
|
||||
-issue: Move Graph removal function to Graph API
|
||||
|
||||
1.1.24
|
||||
-issue#970: Remote Data Collector Cache Synchronization missing plugin sub-directories
|
||||
-issue: Long sysDescriptions on automation page cause columns to be hidden
|
||||
-feature: Allow Resynchronization of Poller Resource Cache
|
||||
|
||||
1.1.23
|
||||
-issue#963: SQL Errors with snmpagent and MariaDB 10.2
|
||||
|
||||
@@ -235,6 +235,9 @@ $messages = array(
|
||||
'type' => 'info'),
|
||||
'reports_item_save_failed' => array(
|
||||
'message' => '<font style="color:red;"><i>' . __('Report Item Save Failed') . '</i></font>',
|
||||
'type' => 'info'),
|
||||
'resource_cache_rebuild' => array(
|
||||
'message' => '<i>' . __('Poller Resource Cache Cleared. Main Data Collector will rebuild at the next poller start, and Remote Data Collectors will sync afterwards.'),
|
||||
'type' => 'info')
|
||||
);
|
||||
|
||||
|
||||
+26
-6
@@ -388,7 +388,7 @@ function process_poller_output(&$rrdtool_pipe, $remainder = FALSE) {
|
||||
db_fetch_assoc_prepared('SELECT ' . SQL_NO_CACHE . '
|
||||
CONCAT(data_template_id, "_", data_name) AS keyname, data_source_names AS data_source_name
|
||||
FROM poller_data_template_field_mappings'),
|
||||
'keyname', Array('data_source_name'));
|
||||
'keyname', array('data_source_name'));
|
||||
}
|
||||
|
||||
if (sizeof($results)) {
|
||||
@@ -646,12 +646,24 @@ function update_resource_cache($poller_id = 1) {
|
||||
if (sizeof($cache)) {
|
||||
foreach($cache as $item) {
|
||||
if (!file_exists($item['path'])) {
|
||||
db_execute_prepared('DELETE FROM poller_resource_cache WHERE path = ?', array($item['path']));
|
||||
db_execute_prepared('DELETE FROM poller_resource_cache
|
||||
WHERE path = ?',
|
||||
array($item['path']));
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ($poller_id > 1) {
|
||||
$paths['plugins'] = array('recursive' => true, 'path' => $mpath . '/plugins');
|
||||
$plugin_paths = db_fetch_assoc('SELECT resource_type, path
|
||||
FROM poller_resource_cache
|
||||
WHERE path LIKE "plugins/%"
|
||||
GROUP BY resource_type');
|
||||
|
||||
if (sizeof($plugin_paths)) {
|
||||
foreach ($plugin_paths as $path) {
|
||||
$paths[$path['resource_type']] = array('recursive' => false, 'path' => dirname($mpath . '/' . $path['path']));
|
||||
}
|
||||
}
|
||||
|
||||
foreach($paths as $type => $path) {
|
||||
if (is_writable($path['path'])) {
|
||||
@@ -680,7 +692,7 @@ function cache_in_path($path, $type, $recursive = true) {
|
||||
$last_md5 = read_config_option($settings_path);
|
||||
|
||||
if (empty($last_md5) || $last_md5 != $curr_md5) {
|
||||
cacti_log("Type:" . $type . ", Path:" . $path . ", Last MD5:" . $last_md5 . ", Curr MD5:" . $curr_md5);
|
||||
cacti_log('Type:' . $type . ', Path:' . $path . ', Last MD5:' . $last_md5 . ', Curr MD5:' . $curr_md5, false, 'POLLER', POLLER_VERBOSITY_MEDIUM);
|
||||
cacti_log("NOTE: Detecting Resource Change. Updating Resource Cache for '$path'", false, 'POLLER');
|
||||
update_db_from_path($path, $type, $recursive);
|
||||
}
|
||||
@@ -726,7 +738,7 @@ function update_db_from_path($path, $type, $recursive = true) {
|
||||
if (is_dir($path)) {
|
||||
$pobject = dir($path);
|
||||
|
||||
while(($entry = $pobject->read()) !== false) {
|
||||
while (($entry = $pobject->read()) !== false) {
|
||||
if ($entry != '.' && $entry != '..' && $entry != '.git' && $entry != '') {
|
||||
$spath = ltrim(trim(str_replace($config['base_path'], '', $path), '/ \\') . '/' . $entry, '/ \\');
|
||||
if (is_dir($path . DIRECTORY_SEPARATOR . $entry)) {
|
||||
@@ -816,7 +828,11 @@ function resource_cache_out($type, $path) {
|
||||
$curr_md5 = md5sum_path($path['path']);
|
||||
|
||||
if (empty($last_md5) || $last_md5 != $curr_md5) {
|
||||
$entries = db_fetch_assoc_prepared('SELECT id, path, md5sum FROM poller_resource_cache WHERE resource_type = ?', array($type));
|
||||
$entries = db_fetch_assoc_prepared('SELECT id, path, md5sum
|
||||
FROM poller_resource_cache
|
||||
WHERE resource_type = ?',
|
||||
array($type));
|
||||
|
||||
if (sizeof($entries)) {
|
||||
foreach($entries as $e) {
|
||||
$mypath = $config['base_path'] . DIRECTORY_SEPARATOR . $e['path'];
|
||||
@@ -873,6 +889,7 @@ function resource_cache_out($type, $path) {
|
||||
cacti_log("ERROR: Cache in cannot write to '" . $tmpfile . "', purge this location");
|
||||
}
|
||||
} elseif (is_writeable($mypath) || (!file_exists($mypath) && is_writable(dirname($mypath)))) {
|
||||
cacti_log("INFO: Updating '" . $mypath . "' from Cache!", false, 'POLLER');
|
||||
file_put_contents($mypath, $contents);
|
||||
} else {
|
||||
cacti_log("ERROR: Cache in cannot write to '" . $mypath . "', purge this location");
|
||||
@@ -941,7 +958,10 @@ function replicate_out($remote_poller_id = 1) {
|
||||
global $config;
|
||||
|
||||
if ($config['poller_id'] == 1) {
|
||||
$cinfo = db_fetch_row_prepared('SELECT * FROM poller WHERE id = ?', array($remote_poller_id));
|
||||
$cinfo = db_fetch_row_prepared('SELECT *
|
||||
FROM poller
|
||||
WHERE id = ?',
|
||||
array($remote_poller_id));
|
||||
|
||||
if (!sizeof($cinfo)) {
|
||||
raise_message('poller_notfound');
|
||||
|
||||
+5934
-6111
File diff suppressed because it is too large.
Load diff
@@ -40,6 +40,10 @@ switch (get_request_var('action')) {
|
||||
ini_set('max_execution_time', $max_execution);
|
||||
header('Location: utilities.php?action=view_poller_cache');exit;
|
||||
break;
|
||||
case 'rebuild_resource_cache':
|
||||
rebuild_resource_cache();
|
||||
header('Location: utilities.php?header=false');exit;
|
||||
break;
|
||||
case 'view_snmp_cache':
|
||||
top_header();
|
||||
utilities_view_snmp_cache();
|
||||
@@ -122,6 +126,15 @@ switch (get_request_var('action')) {
|
||||
Utilities Functions
|
||||
----------------------- */
|
||||
|
||||
function rebuild_resource_cache() {
|
||||
db_execute('DELETE FROM settings WHERE name LIKE "md5dirsum%"');
|
||||
db_execute('TRUNCATE TABLE poller_resource_cache');
|
||||
|
||||
raise_message('resource_cache_rebuild');
|
||||
|
||||
cacti_log('NOTE: Poller Resource Cache scheduled for rebuild by user ' . get_username($_SESSION['sess_user_id']), false, 'WEBUI');
|
||||
}
|
||||
|
||||
function utilities_view_tech($php_info = '') {
|
||||
global $database_default, $config, $rrdtool_versions, $poller_options, $input_types;
|
||||
|
||||
@@ -1827,6 +1840,10 @@ function utilities() {
|
||||
'link' => 'utilities.php?action=clear_poller_cache',
|
||||
'description' => __('The Poller Cache will be re-generated if you select this option. Use this option only in the event of a database crash if you are experiencing issues after the crash and have already run the database repair tools. Alternatively, if you are having problems with a specific Device, simply re-save that Device to rebuild its Poller Cache. There is also a command line interface equivalent to this command that is recommended for large systems. <i class="deviceDown">NOTE: On large systems, this command may take several minutes to hours to complete and therefore should not be run from the Cacti UI. You can simply run \'php -q cli/rebuild_poller_cache.php --help\' at the command line for more information.</i>')
|
||||
),
|
||||
__('Rebuild Resource Cache') => array(
|
||||
'link' => 'utilities.php?action=rebuild_resource_cache',
|
||||
'description' => __('When operating multiple Data Collectors in Cacti, Cacti will attempt to maintain state for key files on all Data Collectors. This includes all core, non-install related website and plugin files. When you force a Resource Cache rebild, Cacti will clear the local Resource Cache, and then rebuild it at the next scheduled poller start. This will trigger all Remote Data Collectors to recheck their website and plugin files for consistency.')
|
||||
),
|
||||
);
|
||||
|
||||
$utilities[__('Boost Utilities')] = array(
|
||||
|
||||
Reference in new issue
Block a user