Merge branch 'develop' into feature/1.2.x

Conflicts:
	lib/html.php
This commit is contained in:
Tony Roman committed 2017-11-19 08:20:39 -05:00
commit 711d362c19
7 files changed
+147 -63

No files matched your search

+18 -15
View File
@@ -7,31 +7,34 @@ Cacti CHANGELOG
1.1.28
-issue#958: User Group Tree permissions not calculated fully
-issue#959: Issue viewing email reports due to email client decoder issues
-issue#992: RRDfile naming issues that result from random sorting during export on prior versions
-issue#1012: Issue where disabled devices will not appear on the Tree edit page
-issue#1044: Handle invalid exclusion regex properly when viewing the Cacti Log
-issue#959: Issue viewing email reports due to email client decoding problems
-issue#992: RRDfile naming issues that result from random sorting during export
-issue#1012: Issue where disabled devices will not appear in Tree editor
-issue#1044: Handle invalid exclusion regex properly when viewing the log
-issue#1045: Issue with multiple pages and confirmation dialogs
-issue#1048: Issue importing vdefs from a template
-issue#1053: Remote Data Collector issues with https and self signed certificates
-issue#1048: Problem importing vdefs from templates
-issue#1053: Remote Data Collector now works with https and self signed certificates
-issue#1055: Errors in data source statistics inserts when invalid output is encountered
-issue#1057: CVE-2017-16641 - Potential vulnerability in RRDtool functions
-issue#1058: ICMP Ping to and IPv6 address fails to gather data for ping latency
-issue#1059: Aggregate item filter should use regular expressions to avoid SQL errors due to flawed filter logic
-issue#1064: When a Device Template is removed, Automation Templates for that Device Template remain
-issue#1066: CVE-2017-16660 in remote_agent.php logging function
-issue#1066: CVE-2017-16661 in view Cacti log file
-issue#1071: CVE-2017-16785 in global_session.php Reflection XSS issue
-issue#1066: CVE-2017-16661 in view log file
-issue#1071: CVE-2017-16785 in global_session.php Reflection XSS
-issue#1074: Boost records get stuck in archive
-issue#1079: Undefined index in lib/snmpagent.php
-issue#1085: Undefined function html_log_input_error in debug
-issue#1087: add_device.php --proxy option does not work with non-snmp devices
-issue: Minor performance increase in boost process
-issue#1085: Undefined function html_log_input_error
-issue#1086: Rerun data queries in automation process has no effect
-issue#1087: cli/add_device.php --proxy option does not work with non-snmp devices
-issue#1088: Set timeout for remote data collector context
-issue: Minor performance increase in boost processing
-issue: Poller output not empty not processed correctly on Log tab
-feature: Add a timeout to the remote agent for realtime graphs
-feature: updated Dutch translations
-feature: Timeout to the remote agent for realtime graphs
-feature: Updated Dutch translations
-feature: Database update adding additional indexes for increased performance
-feature: updated PHPMailer to version 5.2.26
-feature: updated phpseclib to version 2.0.7
-feature: Updated PHPMailer to version 5.2.26
-feature: Updated phpseclib to version 2.0.7
1.1.27
-issue#1033: Issues inserting into dsstats table due to legacy data
+80 -31
View File
@@ -554,9 +554,10 @@ function boost_timer_get_overhead() {
/* boost_get_arch_table_name - returns current archive boost table or false if no arch table is present currently */
function boost_get_arch_table_name() {
global $database_default;
$tables = db_fetch_assoc("SELECT table_name AS name
FROM information_schema.tables
WHERE table_schema='$database_default'
WHERE table_schema = '$database_default'
AND table_name LIKE 'poller_output_boost_arch_%'");
foreach($tables as $table) {
@@ -565,6 +566,7 @@ function boost_get_arch_table_name() {
return $table['name'];
}
}
return false;
}
@@ -595,7 +597,7 @@ function boost_process_poller_output($local_data_id = '', $rrdtool_pipe = '') {
$orig_local_data_id = $local_data_id;
/* aquire lock in order to prevent race conditions */
while (!db_fetch_cell("SELECT GET_LOCK('boost.single_ds.$local_data_id', 1)")) {
while (!db_fetch_cell("SELECT GET_LOCK('boost.single_ds.$orig_local_data_id', 1)")) {
usleep(50000);
}
} else {
@@ -618,19 +620,22 @@ function boost_process_poller_output($local_data_id = '', $rrdtool_pipe = '') {
/* get the records */
if ($single_local_data_id) {
$query_string = '';
$arch_tables = db_fetch_assoc("SELECT table_name AS name
$arch_tables = db_fetch_assoc("SELECT table_name AS name
FROM information_schema.tables
WHERE table_schema='$database_default'
WHERE table_schema = '$database_default'
AND table_name LIKE 'poller_output_boost_arch_%'");
if (count($arch_tables)) {
foreach($arch_tables as $table) {
$rows = db_fetch_cell('SELECT COUNT(*) FROM '.$table['name']);
$rows = db_fetch_cell('SELECT COUNT(*) FROM ' . $table['name']);
if (db_table_exists($table['name']) && is_numeric($rows) && intval($rows) > 0) {
if ($query_string != '') {
$query_string .= ' UNION ';
}
$query_string .= ' (SELECT local_data_id, UNIX_TIMESTAMP(time) AS timestamp, rrd_name, output FROM ' . $table['name'] . " WHERE local_data_id='$local_data_id') ";
$query_string .= ' (SELECT local_data_id, UNIX_TIMESTAMP(time) AS timestamp, rrd_name, output
FROM ' . $table['name'] . "
WHERE local_data_id = $local_data_id) ";
}
}
}
@@ -643,14 +648,32 @@ function boost_process_poller_output($local_data_id = '', $rrdtool_pipe = '') {
$query_string .= " (SELECT local_data_id, UNIX_TIMESTAMP(time) AS timestamp, rrd_name, output
FROM poller_output_boost
WHERE local_data_id=$orig_local_data_id
AND time < FROM_UNIXTIME('$timestamp'))";
WHERE local_data_id = $orig_local_data_id
AND time < FROM_UNIXTIME($timestamp))";
$query_string .= ' ORDER BY local_data_id ASC, timestamp ASC, rrd_name ASC ';
$query_string .= ' ORDER BY timestamp ASC, rrd_name ASC ';
} else {
$query_string = "SELECT local_data_id, UNIX_TIMESTAMP(time) AS timestamp, rrd_name, output
FROM $archive_table FORCE INDEX (PRIMARY)
ORDER BY local_data_id ASC, time ASC, rrd_name ASC
$query_string = '';
$arch_tables = db_fetch_assoc("SELECT table_name AS name
FROM information_schema.tables
WHERE table_schema = '$database_default'
AND table_name LIKE 'poller_output_boost_arch_%'");
if (count($arch_tables)) {
foreach($arch_tables as $table) {
$rows = db_fetch_cell('SELECT COUNT(*) FROM ' . $table['name']);
if (db_table_exists($table['name']) && is_numeric($rows) && intval($rows) > 0) {
if ($query_string != '') {
$query_string .= ' UNION ';
}
$query_string .= ' (SELECT local_data_id, UNIX_TIMESTAMP(time) AS timestamp, rrd_name, output
FROM ' . $table['name'] . ') ';
}
}
}
$query_string .= "ORDER BY local_data_id ASC, time ASC, rrd_name ASC
LIMIT $data_ids_to_get ";
}
@@ -660,7 +683,8 @@ function boost_process_poller_output($local_data_id = '', $rrdtool_pipe = '') {
/* log memory */
if ($get_memory) {
$cur_memory = memory_get_usage();
$cur_memory = memory_get_usage();
if ($cur_memory > $memory_used) {
$memory_used = $cur_memory;
}
@@ -676,19 +700,24 @@ function boost_process_poller_output($local_data_id = '', $rrdtool_pipe = '') {
cacti_log("NOTE: Updating Local Data ID:'$local_data_id', Total of '" . sizeof($results) . "' Updates to Process", false, 'BOOST', $log_verbosity);
}
if (sizeof($results) > 0) {
if (sizeof($results)) {
$rrdp_auto_close = false;
if (!$rrdtool_pipe) {
$rrdtool_pipe = rrd_init();
$rrdtool_pipe = rrd_init();
$rrdp_auto_close = true;
}
/* create an array keyed off of each .rrd file */
$local_data_id = -1;
$time = -1;
$outbuf = '';
$last_update = -1;
$last_item = array('local_data_id' => -1, 'timestamp' => -1, 'rrd_name' => '');
$local_data_id = -1;
$time = -1;
$outbuf = '';
$last_update = -1;
$last_item = array(
'local_data_id' => -1,
'timestamp' => -1,
'rrd_name' => ''
);
/* we are going to blow away all record if ok */
$vals_in_buffer = 0;
@@ -696,12 +725,17 @@ function boost_process_poller_output($local_data_id = '', $rrdtool_pipe = '') {
/* cut last DS (likely to be incomplete due to LIMIT)*/
if (!$single_local_data_id) {
reset($results);
$first_ds = $results[key($results)];
$first_ds = intval($first_ds['local_data_id']);
end($results);
$last_ds = $results[key($results)];
$last_ds = intval($last_ds['local_data_id']);
reset($results);
if ($first_ds == $last_ds) {
if (sizeof($results) == $data_ids_to_get) {
cacti_log("FALURE: Current LIMIT ($data_ids_to_get) is too low to run multiple DS RRD writes, consider raising it", false, 'BOOST');
@@ -722,6 +756,7 @@ function boost_process_poller_output($local_data_id = '', $rrdtool_pipe = '') {
$outlen = 0;
boost_timer('results_cycle', BOOST_TIMER_START);
/* go through each poller_output_boost entries and process */
foreach ($results as $item) {
$item['timestamp'] = trim($item['timestamp']);
@@ -734,7 +769,9 @@ function boost_process_poller_output($local_data_id = '', $rrdtool_pipe = '') {
continue;
}
if (!$single_local_data_id && $first_ds != $last_ds && $last_ds == $item['local_data_id']) {
if (!$single_local_data_id &&
$first_ds != $last_ds &&
$last_ds == $item['local_data_id']) {
/* we faced last and possibly incomplete DS, bail out */
break;
}
@@ -802,6 +839,7 @@ function boost_process_poller_output($local_data_id = '', $rrdtool_pipe = '') {
cacti_log("WARNING: RRD Update Warning '" . $return_value . "' for Local Data ID '$local_data_id'", false, 'BOOST');
}
}
$output = ' ' . $item['timestamp'];
$outbuf .= $output;
$outlen += strlen($output);
@@ -838,6 +876,7 @@ function boost_process_poller_output($local_data_id = '', $rrdtool_pipe = '') {
$first_tmpl = true;
$multi_ok = false;
for ($i=0; $i<count($values); $i++) {
if (preg_match("/^([a-zA-Z0-9_\.-]+):([eE0-9\+\.-]+)$/", $values[$i], $matches)) {
if (isset($rrd_field_names[$matches[1]])) {
@@ -897,24 +936,34 @@ function boost_process_poller_output($local_data_id = '', $rrdtool_pipe = '') {
cacti_log("WARNING: RRD Update Warning '" . $return_value . "' for Local Data ID '$local_data_id'", false, 'BOOST');
}
}
boost_timer('results_cycle', BOOST_TIMER_END);
/* remove the entries from the table */
boost_timer('delete', BOOST_TIMER_START);
if ($single_local_data_id) {
$tables = db_fetch_assoc("SELECT table_name AS name
FROM information_schema.tables
WHERE table_schema='$database_default'
AND (table_name LIKE 'poller_output_boost_arch_%' OR table_name LIKE 'poller_output_boost')");
if (count($tables)) {
foreach($tables as $table) {
db_execute_prepared('DELETE FROM ' . $table['name'] . ' WHERE local_data_id = ? AND time < FROM_UNIXTIME(?)', array($local_data_id, $timestamp));
if (count($arch_tables)) {
foreach($arch_tables as $table) {
db_execute_prepared('DELETE FROM ' . $table['name'] . '
WHERE local_data_id = ?',
array($local_data_id));
}
}
db_execute_prepared('DELETE FROM poller_output_boost
WHERE local_data_id = ?
AND time < FROM_UNIXTIME(?)',
array($local_data_id, $timestamp));
} else {
db_execute_prepared("DELETE FROM $archive_table WHERE local_data_id BETWEEN ? AND ?", array($first_ds, ($last_ds - 1)));
if (count($arch_tables)) {
foreach($arch_tables as $table) {
db_execute_prepared('DELETE FROM ' . $table['name'] . '
WHERE local_data_id BETWEEN ? AND ?',
array($first_ds, $last_ds));
}
}
}
boost_timer('delete', BOOST_TIMER_END);
if ($rrdp_auto_close) {
@@ -1099,7 +1148,7 @@ function boost_rrdtool_function_create($local_data_id, $initial_time, $show_sour
- There is multiple data sources and this item is not the main one.
- There is only one data source (then use it) */
if (sizeof($data_sources) > 0) {
if (sizeof($data_sources)) {
foreach ($data_sources as $data_source) {
/* use the cacti ds name by default or the user defined one, if entered */
$data_source_name = get_data_source_item_name($data_source['id']);
+13 -1
View File
@@ -4527,9 +4527,10 @@ function get_url_type() {
*
* @returns - an array of stream context options or false */
function get_default_contextoption($protocol = false, $options = false) {
$fgc_contextoption = false;
$timeout = read_config_option('script_timeout');
if (!$protocol) {
$protocol = get_url_type();
}
@@ -4544,11 +4545,22 @@ function get_default_contextoption($protocol = false, $options = false) {
);
}
if ($protocol == 'https') {
$fgc_contextoption['https'] = array(
'timeout' => $timeout
);
} elseif ($protocol == 'http') {
$fgc_contextoption['http'] = array(
'timeout' => $timeout
);
}
if (is_array($options)) {
$fgc_contextoption = array_replace_recursive($fgc_contextoption, $options);
}
$fgc_contextoption = api_plugin_hook_function('fgc_contextoption', $fgc_contextoption);
return $fgc_contextoption;
}
+1 -1
View File
@@ -827,7 +827,7 @@ function html_escape($string) {
$charset = 'UTF-8';
}
return htmlspecialchars($string, ENT_QUOTES, $charset, true);
return htmlspecialchars($string, ENT_QUOTES, $charset, false);
}
/* html_split_string - takes a string and breaks it into a number of <br> separated segments
+3 -1
View File
@@ -309,6 +309,8 @@ function html_graph_preview_filter($page, $action, $devices_where = '', $templat
</span>
</td>
</tr>
</table>
<table class='filterTable'>
<tr id='realtime' style='display:none;'>
<td>
<?php print __('Window');?>
@@ -466,7 +468,7 @@ function html_graph_preview_filter($page, $action, $devices_where = '', $templat
$(function() {
$.when(initPage())
.pipe(function() {
initializeGraphs();
initializeGraphs();
});
});
+29 -13
View File
@@ -203,11 +203,7 @@ if (!$master && $thread == 0) {
}
if ($master) {
$networks = db_fetch_assoc_prepared('SELECT *
FROM automation_networks
WHERE poller_id = ?',
array($poller_id));
$networks = db_fetch_assoc_prepared('SELECT * FROM automation_networks WHERE poller_id = ?', array($poller_id));
$launched = 0;
if (sizeof($networks)) {
foreach($networks as $network) {
@@ -259,11 +255,7 @@ if (!$master && $thread == 0) {
automation_primeIPAddressTable($network_id);
$threads = db_fetch_cell_prepared('SELECT threads
FROM automation_networks
WHERE id = ?',
array($network_id));
$threads = db_fetch_cell_prepared('SELECT threads FROM automation_networks WHERE id = ?', array($network_id));
automation_debug("Automation will use $threads Threads\n");
$curthread = 1;
@@ -330,7 +322,10 @@ if (!$master && $thread == 0) {
exit;
function discoverDevices($network_id, $thread) {
$network = db_fetch_row_prepared('SELECT * FROM automation_networks WHERE id = ?', array($network_id));
$network = db_fetch_row_prepared('SELECT *
FROM automation_networks
WHERE id = ?',
array($network_id));
$temp = db_fetch_assoc('SELECT automation_templates.*, host_template.name
FROM automation_templates
@@ -445,7 +440,7 @@ function discoverDevices($network_id, $thread) {
}
}
$exists = db_fetch_row_prepared('SELECT snmp_version, status
$exists = db_fetch_row_prepared('SELECT id, snmp_version, status
FROM host
WHERE hostname IN (?,?)',
array($device['ip_address'], $device['hostname']));
@@ -525,7 +520,7 @@ function discoverDevices($network_id, $thread) {
$snmp_sysName_short = $snmp_sysName;
}
$exists = db_fetch_row_prepared('SELECT status, snmp_version
$exists = db_fetch_row_prepared('SELECT id, status, snmp_version
FROM host
WHERE hostname IN (?,?)',
array($snmp_sysName_short, $snmp_sysName));
@@ -537,6 +532,9 @@ function discoverDevices($network_id, $thread) {
if ($exists['snmp_version'] > 0) {
addSNMPDevice($network_id, getmypid());
}
// Rerun data queries if specified
rerunDataQueries($exists['id'], $network);
}
automation_debug(' Device is in Cacti!');
@@ -710,6 +708,9 @@ function discoverDevices($network_id, $thread) {
if ($exists['snmp_version'] > 0) {
addSNMPDevice($network_id, getmypid());
}
// Rerun data queries if specified
rerunDataQueries($exists['id'], $network);
}
automation_debug(", Status: Already in Cacti\n");
@@ -761,6 +762,21 @@ function killProcess($pid) {
return posix_kill($pid, SIGTERM);
}
function rerunDataQueries($host_id, &$network) {
if ($network['rerun_data_queries'] == 'on') {
$snmp_queries = db_fetch_assoc_prepared('SELECT snmp_query_id
FROM host_snmp_query
WHERE host_id = ?',
array($host_id));
if (sizeof($snmp_queries)) {
foreach($snmp_queries as $query) {
run_data_query($host_id, $query['snmp_query_id']);
}
}
}
}
function registerTask($network_id, $pid, $poller_id, $task = 'collector') {
db_execute_prepared("REPLACE INTO automation_processes
(pid, poller_id, network_id, task, status, heartbeat)
+3 -1
View File
@@ -275,8 +275,10 @@ function output_rrd_data($start_time, $force = false) {
/* split poller_output_boost */
$archive_table = 'poller_output_boost_arch_' . time();
db_execute("RENAME TABLE poller_output_boost TO $archive_table");
db_execute("CREATE TABLE poller_output_boost LIKE $archive_table");
$more_arch_tables = db_fetch_assoc_prepared("SELECT table_name AS name
FROM information_schema.tables
WHERE table_schema = ?
@@ -347,7 +349,7 @@ function output_rrd_data($start_time, $force = false) {
if (count($tables)) {
foreach($tables as $table) {
$rows = db_fetch_cell('SELECT count(*) FROM '.$table['name']);
$rows = db_fetch_cell('SELECT count(*) FROM ' . $table['name']);
if (is_numeric($rows) && intval($rows) == 0) {
db_execute('DROP TABLE ' . $table['name']);
}