session_id(), 'time' => time()])); } else { raise_message('lockout', __esc('Cacti maintenance lockout has been cleared by \'%s\'. Press the button again after Cacti maintenance is over.', get_username($admin)), MESSAGE_LEVEL_INFO); cacti_log('WARNING: Cacti maintenance lockout has been cleared by the primary administrator!'); set_config_option('cacti_lockout_status', ''); } } header('Location: support.php?tab=summary'); exit; } function support_view_tech() : void { global $database_hostname, $poller_options, $input_types, $local_db_cnn_id; // ================= input validation ================= gfrv('tab', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '/^([a-z_A-Z]+)$/']]); // redact is a display-only toggle; coerce to a strict 0/1 and never fail on bad input set_request_var('redact', gnrv('redact') === '1' ? 1 : 0); // ==================================================== // present a tabbed interface $tabs = [ 'summary' => [ 'display' => __('Summary'), 'header' => true ], 'environment' => [ 'display' => __('Environment'), 'header' => true ], 'database' => [ 'display' => __('Database Tables'), 'header' => true ], 'dbsettings' => [ 'display' => __('Database Settings'), 'header' => true ], 'dbstatus' => [ 'display' => __('Database Status'), 'header' => true ], 'dbperms' => [ 'display' => __('Database Permissions'), 'header' => true ], 'processes' => [ 'display' => __('Database Queries'), 'header' => false ], 'background' => [ 'display' => __('Background Processes'), 'header' => false ], 'poller' => [ 'display' => __('Poller Stats'), 'header' => true ], 'phpinfo' => [ 'display' => __('PHP Info'), 'header' => true ], 'log' => [ 'display' => __('Recent Log'), 'header' => true ], 'changelog' => [ 'display' => __('ChangeLog'), 'header' => true ], ]; // set the default tab load_current_session_value('tab', 'sess_ts_tabs', 'summary'); $current_tab = gnrv('tab'); // the regex above only guarantees the shape of the value; fall back to the // default when it is not one of the tabs this page actually renders if (!isset($tabs[$current_tab])) { $current_tab = 'summary'; set_request_var('tab', $current_tab); } // carried on the tab links so redaction stays in effect while navigating $redact = (grv('redact') == 1); // the processes and background will set their own timeouts $page = 'support.php?tab=' . $current_tab . ($redact ? '&redact=1' : ''); if ($current_tab != 'processes' && $current_tab != 'background') { $refresh = [ 'seconds' => 999999, 'page' => $page, 'logout' => 'false' ]; set_page_refresh($refresh); } $header_label = __esc('Technical Support [ %s ]', $tabs[$current_tab]['display']); top_header(); if (cacti_sizeof($tabs)) { // draw the tabs print "
'; } // Display tech information if ($tabs[$current_tab]['header'] === true) { html_start_box($header_label, '100%', false, 3, 'center', ''); } switch (grv('tab')) { case 'summary': show_tech_summary(); break; case 'environment': show_tech_environment(); break; case 'dbstatus': show_database_status(); break; case 'dbperms': show_database_permissions(); break; case 'dbsettings': show_database_settings(); break; case 'changelog': show_cacti_changelog(); break; case 'database': show_database_tables(); break; case 'poller': show_cacti_poller(); break; case 'phpinfo': show_php_modules(); break; case 'log': show_tech_log(); break; case 'processes': show_database_processes(); break; case 'background': show_cacti_processes(); break; } if ($tabs[$current_tab]['header'] === true) { html_end_box(); } ?> __('Any')]; $none = ['0' => __('None')]; $refresh = [ 1 => __esc('%d Seconds', 1), 3 => __esc('%d Seconds', 3), 5 => __esc('%d Seconds', 5), 10 => __esc('%d Seconds', 10), 15 => __esc('%d Seconds', 15), 20 => __esc('%d Seconds', 20) ]; $pollers = [ '0' => __('No'), '1' => __('Yes') ]; $chars = [ 150 => __esc('%d Chars', 150), 180 => __esc('%d Chars', 180), 300 => __esc('%d Chars', 300), 500 => __esc('%d Chars', 500), 1000 => __esc('%d Chars', 1000), ]; return [ 'rows' => [ [ 'filter' => [ 'method' => 'textbox', 'friendly_name' => __('Search'), 'filter' => FILTER_DEFAULT, 'placeholder' => __('Enter a search term'), 'size' => '30', 'default' => '', 'pageset' => true, 'max_length' => '120', 'value' => '' ], 'refresh' => [ 'method' => 'drop_array', 'friendly_name' => __('Refresh'), 'filter' => FILTER_VALIDATE_INT, 'default' => '5', 'pageset' => true, 'array' => $refresh, 'value' => '5' ], 'poller' => [ 'method' => 'drop_array', 'friendly_name' => __('Include Poller'), 'filter' => FILTER_VALIDATE_INT, 'default' => '0', 'pageset' => true, 'array' => $pollers, 'value' => '0' ], 'length' => [ 'method' => 'drop_array', 'friendly_name' => __('Template'), 'filter' => FILTER_VALIDATE_INT, 'default' => '180', 'pageset' => true, 'array' => $chars, 'value' => '180' ], 'rows' => [ 'method' => 'drop_array', 'friendly_name' => __('Queries'), 'filter' => FILTER_VALIDATE_INT, 'default' => '-1', 'pageset' => true, 'array' => $item_rows, 'value' => '-1' ] ] ], 'buttons' => [ 'go' => [ 'method' => 'submit', 'display' => __('Go'), 'title' => __('Apply Filter to Table'), ], 'clear' => [ 'method' => 'button', 'display' => __('Clear'), 'title' => __('Reset Filter to Default Values'), ] ], 'sort' => [ 'sort_column' => 'runtime', 'sort_direction' => 'DESC' ], 'javascript' => [ 'ready' => "$('#refresh').click(function() { clearTimeout(myRefresh); });" ] ]; } function draw_database_process_filter(bool $render = false) : void { $filters = create_database_process_filter(); $header = __('Technical Support [ Database Queries ]'); // create the page filter $pageFilter = new CactiTableFilter($header, 'support.php?tab=processes', 'form_db_stats', 'sess_ts_proc'); $pageFilter->set_filter_array($filters); if ($render) { $pageFilter->render(); } else { $pageFilter->sanitize(); } } function show_database_processes() : void { global $item_rows; draw_database_process_filter(true); if (grv('rows') == '-1') { $rows = read_config_option('num_rows_table'); } else { $rows = grv('rows'); } $sql_where = 'WHERE info NOT LIKE \'%FROM processlist%\' AND info IS NOT NULL'; $sql_params = []; // form the 'where' clause for our main sql query if (grv('filter') != '') { $sql_where .= ' AND ' . '(command LIKE ? OR info LIKE ?)'; $sql_params[] = '%' . grv('filter') . '%'; $sql_params[] = '%' . grv('filter') . '%'; } if (grv('poller') == '0') { $sql_where .= ' AND ' . 'info NOT LIKE \'%poller_output%\' AND ' . 'info NOT LIKE \'%poller_item%\' AND info NOT LIKE \'%SQL_NO_CACHE%\''; } $total_rows = db_fetch_cell_prepared("SELECT COUNT(*) FROM information_schema.processlist $sql_where", $sql_params); $sql_order = get_order_string(); $sql_limit = ' LIMIT ' . ((int) $rows * (max(1, (int) grv('page')) - 1)) . ',' . (int) $rows; $info_len = (int) grv('length'); $version = db_get_global_variable('innodb_version'); if (db_column_exists('information_schema`.`processlist', 'query_id')) { $query_id = 'query_id'; $time_ms = 'ROUND(time_ms/1000,2) AS runtime'; } else { $query_id = "'N/A' AS query_id"; $time_ms = '`time` AS runtime'; } $processes = db_fetch_assoc_prepared("SELECT id, $query_id, user, state, $time_ms, LENGTH(info) AS query_len, SUBSTRING(REPLACE(REPLACE(REPLACE(info, '\n', ' '), ',', ', '), '\t', ' '), 1, $info_len) AS info FROM information_schema.processlist $sql_where $sql_order $sql_limit", $sql_params); $display_text = [ 'id' => [ 'display' => __('Process ID'), 'align' => 'left', 'sort' => 'ASC', 'tip' => __('The Connection ID of the running process.') ], 'query_id' => [ 'display' => __('Query ID'), 'align' => 'left', 'sort' => 'ASC', 'tip' => __('The Query ID of the currently running Query.') ], 'user' => [ 'display' => __('User'), 'align' => 'left', 'sort' => 'ASC', 'tip' => __('The MariaDB/MySQL user currently running the Query.') ], 'runtime' => [ 'display' => __('Run Time'), 'align' => 'right', 'tip' => __('The Runtime of the current query in seconds.') ], 'query_len' => [ 'display' => __('Query Length'), 'align' => 'right', 'tip' => __('The total string length of the Query.') ], 'state' => [ 'display' => __('Query State'), 'align' => 'center', 'sort' => 'ASC', 'tip' => __('The MariaDB/MySQL process state.') ], 'info' => [ 'display' => __('Query Details'), 'align' => 'left', 'tip' => __('The Query Details for the current query upto a maximum string length.') ] ]; $nav = html_nav_bar('support.php?tab=processes', MAX_DISPLAY_PAGES, grv('page'), $rows, $total_rows, 7, __('Queries'), 'page', 'main'); print $nav; html_start_box('', '100%', false, 3, 'center', ''); html_header_sort($display_text, grv('sort_column'), grv('sort_direction'), 1, 'support.php?tab=processes', 'main'); if (cacti_sizeof($processes)) { foreach ($processes as $p) { form_alternate_row('line' . $p['id'], false); form_selectable_cell($p['id'], $p['id']); form_selectable_cell($p['query_id'], $p['id']); form_selectable_ecell($p['user'], $p['id']); form_selectable_cell(number_format_i18n($p['runtime'], 2), $p['id'], '', 'right'); form_selectable_cell(number_format_i18n($p['query_len']), $p['id'], '', 'right'); form_selectable_ecell($p['state'], $p['id'], '', 'center'); form_selectable_ecell($p['info'], $p['id'], '', 'white-space:pre-wrap'); form_end_row(); } } else { print "| " . __('Description') . ' | '; print "" . __('ID') . ' | '; print "" . __('Avg Polling Time') . ' | '; print "" . __('Actual Polling Time') . ' | '; print '' . htmle($host['description']) . ' | '; print '' . $host['id'] . ' | '; print '' . number_format_i18n($host['avg_time'],3) . ' | '; print '' . number_format_i18n($host['polling_time'],3) . ' | '; form_end_row(); } print '
|---|
| " . __('Description') . ' | '; print "" . __('ID') . ' | '; print "" . __('Failed/Total polls') . ' | '; print '' . htmle($host['description']) . ' | '; print '' . $host['id'] . ' | '; print '' . number_format_i18n($host['ratio'],3) . ' | '; form_end_row(); } print '
|---|
| " . __('Name') . ' | '; print "" . __('Engine') . ' | '; print "" . __('Rows') . ' | '; print "" . __('Avg Row Length') . ' | '; print "" . __('Data Length') . ' | '; print "" . __('Index Length') . ' | '; print "" . __('Collation') . ' | '; print "" . __('Row Format') . ' | '; print "" . __('Comment') . ' | '; print '' . htmle($table['TABLE_NAME']) . ' | '; print '' . htmle($table['ENGINE']) . ' | '; print '' . number_format_i18n($table['TABLE_ROWS'], -1) . ' | '; print '' . number_format_i18n($table['AVG_ROW_LENGTH'], -1) . ' | '; print '' . number_format_i18n($table['DATA_LENGTH'], -1) . ' | '; print '' . number_format_i18n($table['INDEX_LENGTH'], -1) . ' | '; print '' . htmle($table['TABLE_COLLATION']) . ' | '; print '' . htmle($table['ROW_FORMAT']) . ' | '; print '' . htmle($table['TABLE_COMMENT']) . ' | '; form_end_row(); } print '
|---|
| " . __('Variable Name') . ' | '; print "" . __('Value') . ' | '; print '' . htmle($s['Variable_name']) . ' | '; if (strlen($s['Value']) > 70) { $s['Value'] = str_replace(',', ', ', $s['Value']); } print '' . (is_numeric($s['Value']) ? number_format_i18n($s['Value'], -1) : htmle($s['Value'])) . ' | '; form_end_row(); } } function show_database_permissions() : void { $status = db_get_permissions(true); $display_text = [ __('Permission Name'), __('Database'), __('Value'), __('Permission Name'), __('Database'), __('Value') ]; html_header($display_text); $r = 0; $j = 1; foreach ($status as $database => $perms) { $first = true; $r = 0; foreach ($perms as $key => $value) { if (($r % 2) == 0 || $first) { form_alternate_row("line$j"); } print '' . $key . ' | '; print '' . $database . ' | '; print '' . ($value ? __('Yes') : __('No')) . ' | '; if (($r % 2) == 1) { form_end_row(); } $r++; $first = false; } if (($r % 2) == 1) { print ''; print ' | '; print ' | '; form_end_row(); $j++; } } } function show_database_status() : void { $status = db_fetch_assoc('show global status'); print " |
|---|
| " . __('Variable Name') . ' | '; print "" . __('Value') . ' | '; print '' . htmle($s['Variable_name']) . ' | '; print '' . (is_numeric($s['Value']) ? number_format_i18n($s['Value'], -1) : htmle($s['Value'])) . ' | '; form_end_row(); } } function show_tech_summary() : void { global $database_hostname, $poller_options, $input_types, $local_db_cnn_id; // When on, identifying values on this tab and in the copied report are masked. $redact = (grv('redact') == 1); // Get poller stats $poller_item = db_fetch_assoc('SELECT action, count(action) AS total FROM poller_item GROUP BY action'); // Get system stats $host_count = db_fetch_cell('SELECT COUNT(*) FROM host WHERE deleted = ""'); $graph_count = db_fetch_cell('SELECT COUNT(*) FROM graph_local'); $data_count = db_fetch_assoc('SELECT i.type_id, COUNT(i.type_id) AS total FROM data_template_data AS d, data_input AS i WHERE d.data_input_id = i.id AND local_data_id > 0 GROUP BY i.type_id'); // Get RRDtool version $rrdtool_version = __('Unknown'); $rrdtool_release = __('Unknown'); $storage_location = read_config_option('storage_location'); $out_array = []; if ($storage_location == 0) { if ((file_exists(read_config_option('path_rrdtool'))) && ((function_exists('is_executable')) && (is_executable(read_config_option('path_rrdtool'))))) { exec(cacti_escapeshellcmd(read_config_option('path_rrdtool')), $out_array); } } else { $rrdtool_pipe = rrd_init(); $out_array[] = rrdtool_execute('info', false, RRDTOOL_OUTPUT_STDOUT, $rrdtool_pipe, 'WEBLOG'); rrd_close($rrdtool_pipe); } if (cacti_sizeof($out_array) > 0) { if (preg_match('/^RRDtool ([0-9.]+)/', $out_array[0], $m)) { preg_match('/^([0-9]+\.[0-9]+\.[0.9]+)/', $m[1], $m2); $rrdtool_release = $m[1]; $rrdtool_version = $rrdtool_release; } } // Get SNMP cli version. $snmp_installed distinguishes raw tool output // (must be escaped when printed) from the pre-built status span below // (already markup, must not be escaped). $snmpget_path = (string) read_config_option('path_snmpget'); if ($snmpget_path !== '' && !str_contains($snmpget_path, "\0") && is_file($snmpget_path) && is_executable($snmpget_path)) { $snmp_version = (string) shell_exec(cacti_escapeshellcmd($snmpget_path) . ' -V 2>&1'); $snmp_installed = true; } else { $snmp_version = "" . __('NET-SNMP Not Installed or its paths are not set. Please install if you wish to monitor SNMP enabled devices.') . ''; $snmp_installed = false; } // Check RRDtool issues $rrdtool_errors = []; if (cacti_version_compare($rrdtool_version, get_rrdtool_version(), '<')) { $rrdtool_errors[] = "" . __('ERROR: Installed RRDtool version does not exceed configured version.' . __('Diagnostics Export') . ' | '; print '' . ' | '; form_end_row(); $lockout = read_config_option('cacti_lockout_status', true); $enabled = read_config_option('auth_maint_lockout_type', true); form_alternate_row(); print '' . __('Cacti Lockout Status') . ' | '; if ($enabled >= 0) { if ($lockout != '') { $lockout = json_decode($lockout, true); $unlock_time = $lockout['time'] + (30 * 60); $unlock_hms = date('H:i', $unlock_time); print ''; } else { print ' | '; } } else { print ' | '; } form_end_row(); form_alternate_row(); print ' | ' . __('Date') . ' | '; print '' . date('r') . ' | '; form_end_row(); api_plugin_hook_function('custom_version_info'); form_alternate_row(); print '' . __('Cacti Version') . ' | '; print '' . CACTI_VERSION . ' | '; form_end_row(); form_alternate_row(); print '' . __('Cacti OS') . ' | '; print '' . CACTI_SERVER_OS . ' | '; form_end_row(); $rsa_fingerprint = read_config_option('rsa_fingerprint'); if ($redact && $rsa_fingerprint != '') { $rsa_fingerprint = substr($rsa_fingerprint, 0, 8) . '… (' . __('masked') . ')'; } form_alternate_row(); print '' . __('RSA Fingerprint') . ' | '; print '' . html_escape($rsa_fingerprint) . ' | '; form_end_row(); form_alternate_row(); print '' . __('NET-SNMP Version') . ' | '; if (!$snmp_installed) { // Pre-built status span; already markup, render as-is. print '' . $snmp_version . ' | '; } else { print '' . ($redact ? html_escape(support_redact($snmp_version)) : html_escape($snmp_version)) . ' | '; } form_end_row(); form_alternate_row(); print '' . __('RRDtool Version') . ' ' . __('Configured') . ' | '; print '' . get_rrdtool_version() . '+ | '; form_end_row(); form_alternate_row(); print '' . __('RRDtool Version') . ' ' . __('Found') . ' | '; print '' . $rrdtool_release . ' | '; form_end_row(); if (!empty($rrdtool_errors)) { form_alternate_row(); print ''; $br = ''; print ' | ';
foreach ($rrdtool_errors as $rrdtool_error) {
print $br . $rrdtool_error;
$br = ' '; } print ' | ';
form_end_row();
}
form_alternate_row();
print '' . __('Devices') . ' | '; print '' . number_format_i18n($host_count, -1) . ' | '; form_end_row(); form_alternate_row(); print '' . __('Graphs') . ' | '; print '' . number_format_i18n($graph_count, -1) . ' | '; form_end_row(); form_alternate_row(); print '' . __('Data Sources') . ' | '; print '';
$data_total = 0;
if (cacti_sizeof($data_count)) {
foreach ($data_count as $item) {
print $input_types[$item['type_id']] . ': ' . number_format_i18n($item['total'], -1) . ' '; $data_total += $item['total']; } print __('Total: %s', number_format_i18n($data_total, -1)); } else { print "0"; } print ' | ';
form_end_row();
html_section_header(__('Poller Information'), 2);
form_alternate_row();
print '' . __('Interval') . ' | '; print '' . read_config_option('poller_interval') . ' | '; $poller_type_name = $poller_options[read_config_option('poller_type')] ?? __('Unknown'); if (file_exists(read_config_option('path_spine')) && $poller_type_name == 'spine') { $type = $spine_version; if (!strpos($spine_version, CACTI_VERSION)) { $type .= ' (' . __('Different version of Cacti and Spine!') . ')'; } } else { $type = $poller_type_name; } form_end_row(); form_alternate_row(); print '' . __('Type') . ' | '; print '' . $type . ' | '; form_end_row(); form_alternate_row(); print '' . __('Items') . ' | '; print '';
$total = 0;
if (cacti_sizeof($poller_item)) {
foreach ($poller_item as $item) {
print __('Action[%s]', $item['action']) . ': ' . number_format_i18n($item['total'], -1) . ' '; $total += $item['total']; } print __('Total: %s', number_format_i18n($total, -1)); } else { print "" . __('No items to poll') . ''; } print ' | ';
form_end_row();
$processes = db_fetch_cell('SELECT
GROUP_CONCAT(
CONCAT("' . __('Name: ') . '", name, ", ' . __('Procs: ') . '", processes) SEPARATOR "' . __('Concurrent Processes') . ' | '; print '' . $processes . ' | '; form_end_row(); form_alternate_row(); print '' . __('Max Threads') . ' | '; print '' . $threads . ' | '; form_end_row(); $script_servers = read_config_option('php_servers'); form_alternate_row(); print '' . __('PHP Servers') . ' | '; print '' . htmle($script_servers) . ' | '; form_end_row(); if (POLLER_ID == 1) { $max_connections = db_get_global_variable('max_connections'); $max_local_connections = 0; } elseif (CACTI_CONNECTION == 'online') { $max_connections = db_get_global_variable('max_connections'); $max_local_connections = db_get_global_variable('max_connections', $local_db_cnn_id); } else { $max_connections = 0; $max_local_connections = db_get_global_variable('max_connections'); } $total_dc_threads = db_fetch_cell("SELECT SUM((processes * threads) + (processes * $script_servers)) AS threads FROM poller WHERE disabled = ''"); $recommend_mc = $total_dc_threads + 100; if ($recommend_mc > $max_connections) { if (POLLER_ID == 1) { $db_connections = '' . __('Main Server: Current: %s, Min Required: %s', $max_connections, $recommend_mc) . ''; } elseif (CACTI_CONNECTION == 'online') { $db_connections = '' . __('Main Server: Current: %s, Min Required: %s', $max_connections, $recommend_mc) . ''; } else { $db_connections = ''; } } else { if (POLLER_ID == 1) { $db_connections = '' . __('Main Server: Current: %s, Min Required: %s', $max_connections, $recommend_mc) . ''; } elseif (CACTI_CONNECTION == 'online') { $db_connections = '' . __('Main Server: Current: %s, Min Required: %s', $max_connections, $recommend_mc) . ''; } else { $db_connections = ''; } } if (POLLER_ID > 1) { if ($recommend_mc > $max_local_connections) { $db_connections .= '' . __('Minimum Connections:') . ' | '; print '' . $db_connections . ' ' . __('Assumes 100 spare connections for Web page users and other various connections.') . ' ' . __('The minimum required can vary greatly if there is heavy user Graph viewing activity.') . ' ' . __('Each browser tab can use upto 10 connections depending on the browser.') . ' | ';
form_end_row();
form_alternate_row();
print '' . __('Script Timeout') . ' | '; print '' . read_config_option('script_timeout') . ' | '; form_end_row(); form_alternate_row(); print '' . __('Max OID') . ' | '; print '' . read_config_option('max_get_size') . ' | '; form_end_row(); form_alternate_row(); print '' . __('Last Run Statistics') . ' | '; print '' . read_config_option('stats_poller') . ' | '; form_end_row(); // Get System Memory $memInfo = utilities_get_system_memory(); // print '$name | "; print '' . number_format_i18n($value / 1000, 2) . ' MB | '; form_end_row(); } else { switch($name) { case 'SwapTotal': case 'SwapFree': case 'Cached': case 'MemTotal': case 'MemFree': case 'MemAvailable': case 'Buffers': case 'Active': case 'Inactive': // Convert to GBi $value /= (1000 * 1000 * 1000); form_alternate_row(); print "$name | "; print '' . __('%s GB', number_format_i18n($value, 2, 1000)) . ' | '; form_end_row(); if ($name == 'MemTotal') { $total_memory = $value; } } } } form_end_row(); } $mysql_info = get_mysql_info(POLLER_ID); $database = $mysql_info['database']; $version = $mysql_info['version']; $link_ver = $mysql_info['link_ver']; $variables = $mysql_info['variables']; $myhost = php_uname('n'); $dbhost = $database_hostname; if ($dbhost == 'localhost' || $myhost == $dbhost) { $local_db = true; } else { $local_db = false; } // Get Maximum Memory in GB for MySQL/MariaDB if (POLLER_ID == 1) { if ($database == 'MariaDB') { $systemMemory = db_fetch_cell('SELECT (@@GLOBAL.key_buffer_size + @@GLOBAL.query_cache_size + @@GLOBAL.tmp_table_size + @@GLOBAL.innodb_buffer_pool_size + @@GLOBAL.innodb_log_buffer_size) / 1024 / 1024 / 1024'); $maxPossibleMyMemory = db_fetch_cell('SELECT ( (@@GLOBAL.key_buffer_size + @@GLOBAL.query_cache_size + @@GLOBAL.tmp_table_size + @@GLOBAL.innodb_buffer_pool_size + @@GLOBAL.innodb_log_buffer_size + @@GLOBAL.max_connections * ( @@GLOBAL.sort_buffer_size + @@GLOBAL.read_buffer_size + @@GLOBAL.read_rnd_buffer_size + @@GLOBAL.join_buffer_size + @@GLOBAL.thread_stack + @@GLOBAL.binlog_cache_size) ) / 1024 / 1024 / 1024)'); } else { $systemMemory = db_fetch_cell('SELECT (@@GLOBAL.key_buffer_size + @@GLOBAL.tmp_table_size + @@GLOBAL.innodb_buffer_pool_size + @@GLOBAL.innodb_log_buffer_size) / 1024 / 1024 / 1024'); $maxPossibleMyMemory = db_fetch_cell('SELECT ( (@@GLOBAL.key_buffer_size + @@GLOBAL.tmp_table_size + @@GLOBAL.innodb_buffer_pool_size + @@GLOBAL.innodb_log_buffer_size + @@GLOBAL.max_connections * ( @@GLOBAL.sort_buffer_size + @@GLOBAL.read_buffer_size + @@GLOBAL.read_rnd_buffer_size + @@GLOBAL.join_buffer_size + @@GLOBAL.thread_stack + @@GLOBAL.binlog_cache_size) ) / 1024 / 1024 / 1024)'); } $clientMemory = db_fetch_cell('SELECT @@GLOBAL.max_connections * ( @@GLOBAL.sort_buffer_size + @@GLOBAL.read_buffer_size + @@GLOBAL.read_rnd_buffer_size + @@GLOBAL.join_buffer_size + @@GLOBAL.thread_stack + @@GLOBAL.binlog_cache_size) / 1024 / 1024 / 1024'); } else { if ($database == 'MariaDB') { $maxPossibleMyMemory = db_fetch_cell('SELECT ( (@@GLOBAL.key_buffer_size + @@GLOBAL.query_cache_size + @@GLOBAL.tmp_table_size + @@GLOBAL.innodb_buffer_pool_size + @@GLOBAL.innodb_log_buffer_size + @@GLOBAL.max_connections * ( @@GLOBAL.sort_buffer_size + @@GLOBAL.read_buffer_size + @@GLOBAL.read_rnd_buffer_size + @@GLOBAL.join_buffer_size + @@GLOBAL.thread_stack + @@GLOBAL.binlog_cache_size) ) / 1024 / 1024 / 1024)', '', false, $local_db_cnn_id); $systemMemory = db_fetch_cell('SELECT (@@GLOBAL.key_buffer_size + @@GLOBAL.query_cache_size + @@GLOBAL.tmp_table_size + @@GLOBAL.innodb_buffer_pool_size + @@GLOBAL.innodb_log_buffer_size) / 1024 / 1024 / 1024', '', false, $local_db_cnn_id); } else { $maxPossibleMyMemory = db_fetch_cell('SELECT ( (@@GLOBAL.key_buffer_size + @@GLOBAL.tmp_table_size + @@GLOBAL.innodb_buffer_pool_size + @@GLOBAL.innodb_log_buffer_size + @@GLOBAL.max_connections * ( @@GLOBAL.sort_buffer_size + @@GLOBAL.read_buffer_size + @@GLOBAL.read_rnd_buffer_size + @@GLOBAL.join_buffer_size + @@GLOBAL.thread_stack + @@GLOBAL.binlog_cache_size) ) / 1024 / 1024 / 1024)', '', false, $local_db_cnn_id); $systemMemory = db_fetch_cell('SELECT (@@GLOBAL.key_buffer_size + @@GLOBAL.tmp_table_size + @@GLOBAL.innodb_buffer_pool_size + @@GLOBAL.innodb_log_buffer_size) / 1024 / 1024 / 1024', '', false, $local_db_cnn_id); } $clientMemory = db_fetch_cell('SELECT @@GLOBAL.max_connections * ( @@GLOBAL.sort_buffer_size + @@GLOBAL.read_buffer_size + @@GLOBAL.read_rnd_buffer_size + @@GLOBAL.join_buffer_size + @@GLOBAL.thread_stack + @@GLOBAL.binlog_cache_size) / 1024 / 1024 / 1024', '', false, $local_db_cnn_id); } html_section_header(__('MySQL/MariaDB Memory Statistics (Source: MySQL Tuner)'), 2); if ($total_memory > 0 && $local_db) { if ($maxPossibleMyMemory > ($total_memory * 0.8)) { form_alternate_row(); print '' . __('Max Total Memory Possible') . ' | '; print '' . __('%s GB', number_format_i18n($maxPossibleMyMemory, 2, 1000)) . ' | '; form_end_row(); form_alternate_row(); print ''; print ' | ' . __('Reduce MySQL/MariaDB Memory to less than 80% of System Memory. Preserve additional Cache Memory for RRDfiles if the Database is on the same system as the RRDfiles. See Core and Client Totals below for explanation of calculation method.') . ' | '; form_end_row(); } else { form_alternate_row(); print '' . __('Max Total Memory Possible') . ' | '; print '' . __('%s GB', number_format_i18n($maxPossibleMyMemory, 2, 1000)) . ' | '; form_end_row(); } } else { form_alternate_row(); print '' . __('Max Total Memory Possible') . ' | '; print '' . __('%s GB', number_format_i18n($maxPossibleMyMemory, 2, 1000)) . ' | '; form_end_row(); } if ($total_memory > 0 && $local_db) { if ($systemMemory > ($total_memory * 0.8)) { form_alternate_row(); print '' . __('Max Core Memory Possible') . ' | '; print '' . __('%s GB', number_format_i18n($systemMemory, 2, 1000)) . ' (' . __('Reduce Total Core Memory') . ' | '; form_end_row(); } else { form_alternate_row(); print '' . __('Max Core Memory Possible') . ' | '; print '' . __('%s GB', number_format_i18n($systemMemory, 2, 1000)) . ' | '; form_end_row(); } form_alternate_row(); print '' . __('Calculation Formula') . ' | '; print 'SELECT @@GLOBAL.key_buffer_size + @@GLOBAL.query_cache_size + @@GLOBAL.tmp_table_size + @@GLOBAL.innodb_buffer_pool_size + @@GLOBAL.innodb_log_buffer_size | ';
form_end_row();
if ($clientMemory > ($total_memory * 0.8)) {
form_alternate_row();
print '' . __('Max Connection Memory Possible') . ' | '; print '' . __('%s GB', number_format_i18n($clientMemory, 2, 1000)) . ' (' . __('Reduce Total Client Memory') . ') | '; form_end_row(); } else { form_alternate_row(); print '' . __('Max Connection Memory Possible') . ' | '; print '' . __('%s GB', number_format_i18n($clientMemory, 2, 1000)) . ' | '; form_end_row(); } form_alternate_row(); print '' . __('Calculation Formula') . ' | '; print 'SELECT @@GLOBAL.max_connections * ( @@GLOBAL.sort_buffer_size + @@GLOBAL.read_buffer_size + @@GLOBAL.read_rnd_buffer_size + @@GLOBAL.join_buffer_size + @@GLOBAL.thread_stack + @@GLOBAL.binlog_cache_size) | ';
form_end_row();
} else {
form_alternate_row();
print '' . __('Max Core Memory Possible') . ' | '; print '' . __('%s GB', number_format_i18n($systemMemory, 2, 1000)) . ' | '; form_end_row(); form_alternate_row(); print '' . __('Calculation Formula') . ' | '; print 'SELECT @@GLOBAL.key_buffer_size + @@GLOBAL.query_cache_size + @@GLOBAL.tmp_table_size + @@GLOBAL.innodb_buffer_pool_size + @@GLOBAL.innodb_log_buffer_size | ';
form_end_row();
form_alternate_row();
print '' . __('Max Connection Memory Possible') . ' | '; print '' . __('%s GB', number_format_i18n($clientMemory, 2, 1000)) . ' | '; form_end_row(); form_alternate_row(); print '' . __('Calculation Formula') . ' | '; print 'SELECT @@GLOBAL.max_connections * ( @@GLOBAL.sort_buffer_size + @@GLOBAL.read_buffer_size + @@GLOBAL.read_rnd_buffer_size + @@GLOBAL.join_buffer_size + @@GLOBAL.thread_stack + @@GLOBAL.binlog_cache_size) | ';
form_end_row();
}
html_section_header(__('PHP Information'), 2);
form_alternate_row();
print '' . __('PHP Version') . ' | '; print '' . PHP_VERSION . ' | '; form_end_row(); form_alternate_row(); print '' . __('PHP OS') . ' | '; print '' . PHP_OS . ' | '; form_end_row(); form_alternate_row(); print '' . __('PHP uname') . ' | '; print ''; if (function_exists('php_uname')) { print html_escape($redact ? support_redact(php_uname()) : php_uname()); } else { print __('N/A'); } print ' | '; form_end_row(); form_alternate_row(); print '' . __('PHP SNMP') . ' | '; print ''; if (!function_exists('snmpget')) { print __('Not Installed'); } elseif (!CACTI_PHP_SNMP) { print __('Installed, but disabled by $php_snmp_support in include/config.php. The Net-SNMP binaries are used instead.'); } else { print __('Installed.'); } print ' | '; form_end_row(); form_alternate_row(); print 'max_execution_time | '; print '' . html_escape(ini_get('max_execution_time')) . ' | '; form_end_row(); form_alternate_row(); print 'memory_limit | '; print '' . html_escape(ini_get('memory_limit'));
// Calculate memory suggestion based off of data source count
$memory_suggestion = $data_total * 32768;
// Set minimum - 16M
if ($memory_suggestion < 16777216) {
$memory_suggestion = 16777216;
}
// Set maximum - 512M
if ($memory_suggestion > 536870912) {
$memory_suggestion = 536870912;
}
// Suggest values in 8M increments
$memory_suggestion = round($memory_suggestion / 8388608) * 8388608;
if (memory_bytes(ini_get('memory_limit')) < $memory_suggestion) {
print " "; if ((ini_get('memory_limit') == -1)) { print __("You've set memory limit to 'unlimited'.") . ' '; } print __('It is highly suggested that you alter you php.ini memory_limit to %s or higher.', memory_readable($memory_suggestion)) . ' ' . __('This suggested memory value is calculated based on the number of data source present and is only to be used as a suggestion, actual values may vary system to system based on requirements.'); print ' '; } print ' | ';
form_end_row();
utilities_get_mysql_recommendations();
utilities_get_mysql_capabilities();
// Shareable diagnostics report (Feature: Copy Diagnostics).
// When the redact toggle is on, hostnames/IPs embedded in the SNMP version
// line and web server string are masked via support_redact(), and the RSA
// fingerprint is truncated. The report does not include the DB host,
// credentials or absolute paths.
$snmp_line = $snmp_installed ? trim(explode("\n", $snmp_version)[0]) : trim(strip_tags($snmp_version));
$web_server = (string) ($_SERVER['SERVER_SOFTWARE'] ?? __('Unknown'));
$poller_report = $poller_options[read_config_option('poller_type')] ?? __('Unknown');
if ($redact) {
$snmp_line = support_redact($snmp_line);
$web_server = support_redact($web_server);
}
if ($poller_report == 'spine' && $spine_version != 'Unknown') {
$poller_report = $spine_version;
}
$rsa = read_config_option('rsa_fingerprint');
if ($rsa == '') {
$rsa_report = __('N/A');
} elseif ($redact) {
$rsa_report = substr($rsa, 0, 8) . '… (' . __('masked') . ')';
} else {
$rsa_report = $rsa;
}
$report = "### Cacti Diagnostics\n";
$report .= '- ' . __('Cacti Version') . ': ' . CACTI_VERSION . "\n";
$report .= '- ' . __('Cacti OS') . ': ' . CACTI_SERVER_OS . "\n";
$report .= '- ' . __('Web Server') . ': ' . $web_server . "\n";
$report .= '- ' . __('PHP Version') . ': ' . PHP_VERSION . "\n";
$report .= '- ' . __('PHP OS') . ': ' . PHP_OS . "\n";
$report .= '- ' . __('Database') . ': ' . trim($database . ' ' . $version) . "\n";
$report .= '- ' . __('RRDtool Version Configured') . ': ' . get_rrdtool_version() . "+\n";
$report .= '- ' . __('RRDtool Version Found') . ': ' . $rrdtool_release . "\n";
$report .= '- ' . __('NET-SNMP Version') . ': ' . $snmp_line . "\n";
$report .= '- ' . __('Poller Interval') . ': ' . read_config_option('poller_interval') . "\n";
$report .= '- ' . __('Poller Type') . ': ' . $poller_report . "\n";
$report .= '- ' . __('Last Run Statistics') . ': ' . read_config_option('stats_poller') . "\n";
$report .= '- ' . 'memory_limit: ' . ini_get('memory_limit') . "\n";
$report .= '- ' . 'max_execution_time: ' . ini_get('max_execution_time') . "\n";
$report .= '- ' . __('System Memory') . ': ' . ($total_memory > 0 ? number_format_i18n($total_memory, 2, 1000) . ' GB' : __('N/A')) . "\n";
$report .= '- ' . __('RSA Fingerprint') . ': ' . $rsa_report . "\n";
form_alternate_row();
print "'; form_end_row(); } function show_tech_environment() : void { // utility_php_verify_extensions() alone can't tell whether a module is // really loaded in both contexts: it seeds CLI-only extensions such as // pcntl with 'web' => true (not required in web), so checking either the // seeded flag or a bare extension_loaded() in isolation misreports one // context or the other. Verify web in-process, shell out to cli_check.php // for the real CLI state (same path_php_binary lookup already used below // for rrdtool/snmpget), and combine with the web && cli rule from // utility_php_set_installed(), the same one lib/installer.php relies on. $extensions = false; utility_php_verify_extensions($extensions, 'web'); $php_binary = read_config_option('path_php_binary'); if ($php_binary != '' && file_exists($php_binary) && is_executable($php_binary)) { $cli_json = shell_exec(cacti_escapeshellcmd($php_binary) . ' -q ' . cacti_escapeshellarg(CACTI_PATH_INSTALL . '/cli_check.php') . ' extensions'); $cli_ext = @json_decode((string) $cli_json, true); if (is_array($cli_ext)) { foreach ($cli_ext as $name => $ext) { if (isset($extensions[$name])) { $extensions[$name]['cli'] = !empty($ext['cli']); } } } } utility_php_set_installed($extensions); html_section_header(__('Required PHP Extensions'), 2); foreach ($extensions as $name => $extension) { $loaded = !empty($extension['installed']); form_alternate_row(); print ' | ' . html_escape($name) . ' | '; print '' . tech_env_status($loaded ? DB_STATUS_SUCCESS : DB_STATUS_ERROR, $loaded ? __('Installed') : __('Missing')) . ' | '; form_end_row(); } // Recommended (optional) extensions such as php-snmp. $optionals = false; utility_php_verify_optionals($optionals, 'web'); html_section_header(__('Recommended PHP Extensions'), 2); foreach ($optionals as $name => $optional) { $loaded = !empty($optional['web']); form_alternate_row(); print '' . html_escape($name) . ' | '; print '' . tech_env_status($loaded ? DB_STATUS_SUCCESS : DB_STATUS_WARNING, $loaded ? __('Installed') : __('Not installed')) . ' | '; form_end_row(); } // Key php.ini values and thresholds (reuses the installer's recommendations). $recommends = false; utility_php_verify_recommends($recommends, 'web'); html_section_header(__('PHP Configuration'), 2); foreach ($recommends as $recommend) { if ($recommend['name'] == 'location' || $recommend['name'] == 'version') { continue; } form_alternate_row(); print '' . html_escape($recommend['name']) . ' | '; print '' . tech_env_status((int) $recommend['status'], __('Current: %s, Recommended: %s', $recommend['current'], $recommend['value'])) . ' | '; form_end_row(); } $file_uploads = (bool) ini_get('file_uploads'); form_alternate_row(); print 'file_uploads | '; print '' . tech_env_status($file_uploads ? DB_STATUS_SUCCESS : DB_STATUS_ERROR, $file_uploads ? __('On') : __('Off')) . ' | '; form_end_row(); // Required binaries: existence + version. $binaries = [ 'path_php_binary' => '-v', 'path_rrdtool' => '--version', 'path_snmpget' => '-V', ]; html_section_header(__('Required Binaries'), 2); foreach ($binaries as $option => $arg) { $path = read_config_option($option); form_alternate_row(); print '' . html_escape($option) . ' | '; if ($path != '' && file_exists($path) && function_exists('is_executable') && is_executable($path)) { if (is_function_enabled('shell_exec')) { $out = shell_exec(cacti_escapeshellarg($path) . ' ' . $arg . ' 2>&1'); $version = ($out != '' ? trim(explode("\n", $out)[0]) : __('Unknown version')); print '' . tech_env_status(DB_STATUS_SUCCESS, $version) . ' | '; } else { print '' . tech_env_status(DB_STATUS_WARNING, __('Version unavailable: shell_exec() is disabled')) . ' | '; } } else { print '' . tech_env_status(DB_STATUS_ERROR, __('Not found or not executable: %s', $path)) . ' | '; } form_end_row(); } // Writable directories. cache/rra/log must be writable; scripts/resource // are usually read-only so a non-writable result is only a warning. $directories = [ CACTI_PATH_CACHE => true, CACTI_PATH_RRA => true, CACTI_PATH_LOG => true, CACTI_PATH_SCRIPTS => false, CACTI_PATH_RESOURCE => false, ]; html_section_header(__('Writable Directories'), 2); foreach ($directories as $directory => $required) { $writable = is_writable($directory); if ($writable) { $status = DB_STATUS_SUCCESS; $text = __('Writable'); } else { $status = ($required ? DB_STATUS_ERROR : DB_STATUS_WARNING); $text = __('Not writable'); } form_alternate_row(); print '' . html_escape($directory) . ' | '; print '' . tech_env_status($status, $text) . ' | '; form_end_row(); } } /** * tech_env_status - render a status badge for the technical support report. * $text is treated as plain text and escaped here, so callers pass raw values * and must not pre-escape (doing so would double-encode). */ function tech_env_status(int $status, string $text) : string { [$class, $icon] = match ($status) { DB_STATUS_SUCCESS => ['deviceUp', 'fa-check-circle'], DB_STATUS_ERROR => ['deviceDown', 'fa-times-circle'], default => ['deviceRecovering', 'fa-exclamation-triangle'], }; return " " . html_escape($text) . ''; } /** * support_redact - mask identifying details in a display string so a support * report can be shared publicly. Display-only and deliberately conservative: * it prefers to over-mask rather than leak. Not applied to version numbers. */ function support_redact(string $value) : string { if ($value === '') { return $value; } // IPv6 before IPv4 so the longer pattern wins. The candidate pattern is // deliberately loose (it also matches "::" compression and would catch // non-addresses like MACs or "1:2:3"); filter_var() gates the replacement // so only strings that are genuinely IPv6 get masked. $value = preg_replace_callback('/(?:[0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{0,4}/', function ($m) { return filter_var($m[0], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false ? '" . __('Log not available.') . ' | '; form_end_row(); return; } $lines = support_tail_severity($logfile, $max_lines, $cap_bytes); if (!cacti_sizeof($lines)) { form_alternate_row(); print "" . __('No recent WARN, ERROR or SECURITY log entries found.') . ' | '; form_end_row(); return; } form_alternate_row(); print "";
print "";
foreach ($lines as $line) {
if ($redact) {
$line = support_redact($line);
}
print html_escape($line) . "\n";
}
print ' | ';
form_end_row();
}
|---|