array('regexp' => '/^([a-z_A-Z]+)$/')));
/* ==================================================== */
/* present a tabbed interface */
$tabs = array(
'summary' => __('Summary'),
'database' => __('Database'),
'dbsettings' => __('Database Settings'),
'dbstatus' => __('Database Status'),
'phpinfo' => __('PHP Info'),
'changelog' => __('ChangeLog'),
);
/* set the default tab */
load_current_session_value('tab', 'sess_ts_tabs', 'summary');
$current_tab = get_nfilter_request_var('tab');
$page = 'utilities.php?action=view_tech&header=false&tab=' . $current_tab;
$refresh = array(
'seconds' => 999999,
'page' => $page,
'logout' => 'false'
);
set_page_refresh($refresh);
$header_label = __esc('Technical Support [%s]', $tabs[get_request_var('tab')]);
top_header();
if (cacti_sizeof($tabs)) {
$i = 0;
/* draw the tabs */
print "
";
}
/* Display tech information */
html_start_box($header_label, '100%', '', '3', 'center', '');
if (get_request_var('tab') == 'summary') {
/* 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 = 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 */
if ((file_exists(read_config_option('path_snmpget'))) && ((function_exists('is_executable')) && (is_executable(read_config_option('path_snmpget'))))) {
$snmp_version = shell_exec(cacti_escapeshellcmd(read_config_option('path_snmpget')) . ' -V 2>&1');
} else {
$snmp_version = "" . __('NET-SNMP Not Installed or its paths are not set. Please install if you wish to monitor SNMP enabled devices.') . "";
}
/* Check RRDtool issues */
$rrdtool_errors = array();
if (cacti_version_compare($rrdtool_version, get_rrdtool_version(), '<')) {
$rrdtool_errors[] = "" . __('ERROR: Installed RRDtool version does not exceed configured version.
Please visit the %s and select the correct RRDtool Utility Version.', "" . __('Configuration Settings') . '') . "";
}
$graph_gif_count = db_fetch_cell('SELECT COUNT(*) FROM graph_templates_graph WHERE image_format_id = 2');
if ($graph_gif_count > 0) {
$rrdtool_errors[] = "" . __('ERROR: RRDtool 1.2.x+ does not support the GIF images format, but %d" graph(s) and/or templates have GIF set as the image format.', $graph_gif_count) . '';
}
/* Get spine version */
$spine_version = 'Unknown';
if ((file_exists(read_config_option('path_spine'))) && ((function_exists('is_executable')) && (is_executable(read_config_option('path_spine'))))) {
$out_array = array();
exec(cacti_escapeshellcmd(read_config_option('path_spine')) . ' --version', $out_array);
if (cacti_sizeof($out_array) > 0) {
$spine_version = $out_array[0];
}
}
html_section_header(__('General Information'), 2);
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 '' . $config['cacti_server_os'] . ' | ';
form_end_row();
form_alternate_row();
print '' . __('RSA Fingerprint') . ' | ';
print '' . read_config_option('rsa_fingerprint') . ' | ';
form_end_row();
form_alternate_row();
print '' . __('NET-SNMP Version') . ' | ';
print '' . $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) . ' | ';
form_end_row();
form_alternate_row();
print '' . __('Graphs') . ' | ';
print '' . number_format_i18n($graph_count) . ' | ';
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']) . ' ';
$data_total += $item['total'];
}
print __('Total: %s', number_format_i18n($data_total));
} else {
print "0";
}
print ' | ';
form_end_row();
html_section_header(__('Poller Information'), 2);
form_alternate_row();
print '' . __('Interval') . ' | ';
print '' . read_config_option('poller_interval') . ' | ';
if (file_exists(read_config_option('path_spine')) && $poller_options[read_config_option('poller_type')] == 'spine') {
$type = $spine_version;
if (!strpos($spine_version, CACTI_VERSION)) {
$type .= ' (' . __('Different version of Cacti and Spine!') . ')';
}
} else {
$type = $poller_options[read_config_option('poller_type')];
}
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']) . ' ';
$total += $item['total'];
}
print __('Total: %s', number_format_i18n($total));
} else {
print "" . __('No items to poll') . "";
}
print ' | ';
form_end_row();
$processes = db_fetch_cell('SELECT
GROUP_CONCAT(
CONCAT("' . __('Name: ') . '", name, ", ' . __('Procs: ') . '", processes) SEPARATOR "
"
) AS poller
FROM poller
WHERE disabled=""');
$threads = db_fetch_cell('SELECT
GROUP_CONCAT(
CONCAT("' . __('Name: ') . '", name, ", ' . __('Threads: ') . '", threads) SEPARATOR "
"
) AS poller
FROM poller
WHERE disabled=""');
form_alternate_row();
print '' . __('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 '' . html_escape($script_servers) . ' | ';
form_end_row();
if ($config['poller_id'] == 1) {
$max_connections = db_fetch_row('SHOW GLOBAL VARIABLES LIKE "max_connections"');
$max_local_connections = array();
} elseif ($config['connection'] == 'online') {
$max_connections = db_fetch_row('SHOW GLOBAL VARIABLES LIKE "max_connections"');
$max_local_connections = db_fetch_row('SHOW GLOBAL VARIABLES LIKE "max_connections"', false, $local_db_cnn_id);
} else {
$max_connections = array();
$max_local_connections = db_fetch_row('SHOW GLOBAL VARIABLES LIKE "max_connections"');
}
if (cacti_sizeof($max_connections)) {
$max_connections = $max_connections['Value'];
} else {
$max_connections = 0;
}
if (cacti_sizeof($max_local_connections)) {
$max_local_connections = $max_local_connections['Value'];
} else {
$max_local_connections = 0;
}
$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 ($config['poller_id'] == 1) {
$db_connections = '' . __('Main Server: Current: %s, Min Required: %s', $max_connections, $recommend_mc) . '';
} elseif ($config['connection'] == 'online') {
$db_connections = '' . __('Main Server: Current: %s, Min Required: %s', $max_connections, $recommend_mc) . '';
} else {
$db_connections = '';
}
} else {
if ($config['poller_id'] == 1) {
$db_connections = '' . __('Main Server: Current: %s, Min Required: %s', $max_connections, $recommend_mc) . '';
} elseif ($config['connection'] == 'online') {
$db_connections = '' . __('Main Server: Current: %s, Min Required: %s', $max_connections, $recommend_mc) . '';
} else {
$db_connections = '';
}
}
if ($config['poller_id'] > 1) {
if ($recommend_mc > $max_local_connections) {
$db_connections .= '
' . __('Local Server: Current: %s, Min Required: %s', $max_local_connections, $recommend_mc) . '';
} else {
$db_connections .= '
' . __('Local Server: Current: %s, Min Required: %s', $max_local_connections, $recommend_mc) . '';
}
}
form_alternate_row();
print '' . __('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 '';print_r($memInfo);print '
';
$total_memory = 0;
if (cacti_sizeof($memInfo)) {
html_section_header(__('System Memory'), 2);
foreach($memInfo as $name => $value) {
if ($config['cacti_server_os'] == 'win32') {
form_alternate_row();
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 '' . __('%0.2f GB', number_format_i18n($value, 2, 1000)) . ' | ';
form_end_row();
if ($name == 'MemTotal') {
$total_memory = $value;
}
}
}
}
form_end_row();
}
$mysql_info = utilities_get_mysql_info($config['poller_id']);
$database = $mysql_info['database'];
$version = $mysql_info['version'];
$link_ver = $mysql_info['link_ver'];
$variables = $mysql_info['variables'];
// Get Maximum Memory in GB for MySQL/MariaDB
if ($config['poller_id'] == 1) {
if (($database == 'MySQL' && version_compare($version, '8.0', '<')) || $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 == 'MySQL' && version_compare($version, '8.0', '<')) || $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) {
if ($maxPossibleMyMemory > ($total_memory * 0.8)) {
form_alternate_row();
print '' . __('Max Total Memory Possible') . ' | ';
print '' . __('%0.2f 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 '' . __('%0.2f GB', number_format_i18n($maxPossibleMyMemory, 2, 1000)) . ' | ';
form_end_row();
}
} else {
form_alternate_row();
print '' . __('Max Total Memory Possible') . ' | ';
print '' . __('%0.2f GB', number_format_i18n($maxPossibleMyMemory, 2, 1000)) . ' | ';
form_end_row();
}
if ($total_memory > 0) {
if ($systemMemory > ($total_memory * 0.8)) {
form_alternate_row();
print '' . __('Max Core Memory Possible') . ' | ';
print '' . __('%0.2f GB', number_format_i18n($systemMemory, 2, 1000)) . ' (' . __('Reduce Total Core Memory') . ' | ';
form_end_row();
} else {
form_alternate_row();
print '' . __('Max Core Memory Possible') . ' | ';
print '' . __('%0.2f 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 '' . __('%0.2f GB', number_format_i18n($clientMemory, 2, 1000)) . ' (' . __('Reduce Total Client Memory') . ') | ';
form_end_row();
} else {
form_alternate_row();
print '' . __('Max Connection Memory Possible') . ' | ';
print '' . __('%0.2f 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 '' . __('%0.2f GB', number_format_i18n($systemMemory, 2, 1000)) . ' | ';
form_end_row();
form_alternate_row();
print '' . __('Max Connection Memory Possible') . ' | ';
print '' . __('%0.2f GB', number_format_i18n($clientMemory, 2, 1000)) . ' | ';
form_end_row();
}
html_section_header(__('PHP Information'), 2);
form_alternate_row();
print '' . __('PHP Version') . ' | ';
if (version_compare(PHP_VERSION, '5.5.0') >= 0) {
print '' . PHP_VERSION . ' | ';
} else {
print '' . PHP_VERSION . "" . __('PHP Version 5.5.0+ is recommended due to strong password hashing support.') . " | ";
}
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 php_uname();
} else {
print __('N/A');
}
print ' | ';
form_end_row();
form_alternate_row();
print '' . __('PHP SNMP') . ' | ';
print '';
if (function_exists('snmpget')) {
print __('Installed. Note: If you are planning on using SNMPv3, you must remove php-snmp and use the Net-SNMP toolset.');
} else {
print __('Not Installed');
}
print ' | ';
form_end_row();
form_alternate_row();
print "max_execution_time | ";
print '' . ini_get('max_execution_time') . ' | ';
form_end_row();
form_alternate_row();
print "memory_limit | ";
print '' . 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();
} elseif (get_request_var('tab') == 'dbstatus') {
$status = db_fetch_assoc('show global status');
print "";
print '';
print "';
print '';
foreach($status as $s) {
form_alternate_row();
print '| ' . $s['Variable_name'] . ' | ';
print '' . (is_numeric($s['Value']) ? number_format_i18n($s['Value']):$s['Value']) . ' | ';
form_end_row();
}
} elseif (get_request_var('tab') == 'dbsettings') {
$status = db_fetch_assoc('show global variables');
print "";
print '';
print "';
print '';
foreach($status as $s) {
form_alternate_row();
print '| ' . $s['Variable_name'] . ' | ';
if (strlen($s['Value']) > 70) {
$s['Value'] = str_replace(',', ', ', $s['Value']);
}
print '' . (is_numeric($s['Value']) ? number_format_i18n($s['Value']):$s['Value']) . ' | ';
form_end_row();
}
} elseif (get_request_var('tab') == 'changelog') {
$changelog = file($config['base_path'] . '/CHANGELOG');
foreach($changelog as $s) {
if (strlen(trim($s)) && stripos($s, 'CHANGELOG') === false) {
if (strpos($s, '-') === false) {
html_section_header(__('Version %s', $s), 2);
} else {
form_alternate_row();
print '' . $s . ' | ';
form_end_row();
}
}
}
} elseif (get_request_var('tab') == 'database') {
/* Get table status */
if ($config['poller_id'] == 1) {
$tables = db_fetch_assoc('SELECT *
FROM information_schema.tables
WHERE table_schema = SCHEMA()');
} else {
$tables = db_fetch_assoc('SELECT *
FROM information_schema.tables
WHERE table_schema = SCHEMA()', false, $local_db_cnn_id);
}
html_section_header(__('MySQL Table Information - Sizes in KBytes'), 2);
form_alternate_row();
print " ";
if (cacti_sizeof($tables)) {
print "";
print '';
print "';
print '';
foreach ($tables as $table) {
form_alternate_row();
print '| ' . $table['TABLE_NAME'] . ' | ';
print '' . $table['ENGINE'] . ' | ';
print '' . number_format_i18n($table['TABLE_ROWS']) . ' | ';
print '' . number_format_i18n($table['AVG_ROW_LENGTH']) . ' | ';
print '' . number_format_i18n($table['DATA_LENGTH']) . ' | ';
print '' . number_format_i18n($table['INDEX_LENGTH']) . ' | ';
print '' . $table['TABLE_COLLATION'] . ' | ';
print '' . $table['ROW_FORMAT'] . ' | ';
print '' . $table['TABLE_COMMENT'] . ' | ';
form_end_row();
}
print " ";
} else {
print __('Unable to retrieve table status');
}
print ' | ';
form_end_row();
} else {
$php_info = utilities_php_modules();
html_section_header(__('PHP Module Information'), 2);
$php_info = str_replace(
array('width="600"', 'th colspan="2"', ','),
array('', 'th class="subHeaderColumn"', ', '),
$php_info
);
print "| " . $php_info . ' |
';
}
html_end_box();
?>
array(
'filter' => FILTER_VALIDATE_INT,
'pageset' => true,
'default' => '-1'
),
'page' => array(
'filter' => FILTER_VALIDATE_INT,
'default' => '1'
),
'filter' => array(
'filter' => FILTER_DEFAULT,
'pageset' => true,
'default' => ''
),
'sort_column' => array(
'filter' => FILTER_CALLBACK,
'default' => 'time',
'options' => array('options' => 'sanitize_search_string')
),
'sort_direction' => array(
'filter' => FILTER_CALLBACK,
'default' => 'DESC',
'options' => array('options' => 'sanitize_search_string')
),
'username' => array(
'filter' => FILTER_CALLBACK,
'default' => '-1',
'options' => array('options' => 'sanitize_search_string')
),
'result' => array(
'filter' => FILTER_VALIDATE_INT,
'pageset' => true,
'default' => '-1'
)
);
validate_store_request_vars($filters, 'sess_userlog');
/* ================= input validation ================= */
if (get_request_var('rows') == '-1') {
$rows = read_config_option('num_rows_table');
} else {
$rows = get_request_var('rows');
}
?>
|
|
array(__('User'), 'ASC'),
'full_name' => array(__('Full Name'), 'ASC'),
'realm' => array(__('Authentication Realm'), 'ASC'),
'time' => array(__('Date'), 'DESC'),
'result' => array(__('Result'), 'DESC'),
'ip' => array(__('IP Address'), 'DESC')
);
html_header_sort($display_text, get_request_var('sort_column'), get_request_var('sort_direction'), 1, 'utilities.php?action=view_user_log');
$i = 0;
if (cacti_sizeof($user_log)) {
foreach ($user_log as $item) {
form_alternate_row('line' . $i, true);
?>
|
|
|
|
|
|
1) {
db_execute_prepared('DELETE
FROM user_log
WHERE username = ?
AND result IN(1)
ORDER BY time LIMIT ' . ($total_login_rows - 1),
array($user['username']));
}
if ($total_token_rows > 1) {
db_execute_prepared('DELETE
FROM user_log
WHERE username = ?
AND result IN(2)
ORDER BY time
LIMIT ' . ($total_token_rows - 1),
array($user['username']));
}
db_execute_prepared('DELETE
FROM user_log
WHERE username = ?
AND result = 0',
array($user['username']));
}
/* delete inactive users */
db_execute('DELETE
FROM user_log
WHERE user_id NOT IN (SELECT id FROM user_auth)
OR username NOT IN (SELECT username FROM user_auth)');
}
}
function utilities_view_logfile() {
global $log_tail_lines, $page_refresh_interval, $config;
$logfile = basename(get_nfilter_request_var('filename'));
$logbase = basename(read_config_option('path_cactilog'));
if ($logfile == '') {
$logfile = $logbase;
}
if ($logfile == '') {
$logfile = 'cacti.log';
}
$logname = '';
$logpath = '';
if (!clog_validate_filename($logfile, $logpath, $logname, true)) {
raise_message('clog_invalid');
header('Location: utilities.php?action=view_logfile&filename=' . $logbase);
exit(0);
} else {
$logfile = $logpath . '/' . $logfile;
}
/* ================= input validation and session storage ================= */
$filters = array(
'page' => array(
'filter' => FILTER_VALIDATE_INT,
'default' => '1'
),
'tail_lines' => array(
'filter' => FILTER_VALIDATE_INT,
'pageset' => true,
'default' => '-1'
),
'rfilter' => array(
'filter' => FILTER_VALIDATE_IS_REGEX,
'pageset' => true,
'default' => ''
),
'message_type' => array(
'filter' => FILTER_VALIDATE_INT,
'pageset' => true,
'default' => '-1'
),
'reverse' => array(
'filter' => FILTER_VALIDATE_INT,
'default' => '1'
),
'refresh' => array(
'filter' => FILTER_VALIDATE_INT,
'default' => read_config_option('log_refresh_interval')
)
);
validate_store_request_vars($filters, 'sess_log');
/* ================= input validation ================= */
$page_nr = get_request_var('page');
$page = 'utilities.php?action=view_logfile&header=false';
$page .= '&filename=' . basename($logfile) . '&page=' . $page_nr;
$refresh = array(
'seconds' => get_request_var('refresh'),
'page' => $page,
'logout' => 'false'
);
set_page_refresh($refresh);
top_header();
?>
|
|
0) {
$start_string = __('Log [Total Lines: %d - Non-Matching Items Hidden]', $total_rows);
} else {
$start_string = __('Log [Total Lines: %d - All Items Shown]', $total_rows);
}
$rfilter = get_request_var('rfilter');
$reverse = get_request_var('reverse');
$refreshTime = get_request_var('refresh');
$message_type = get_request_var('message_type');
$tail_lines = get_request_var('tail_lines');
$base_url = 'utilities.php?action=view_logfile&filename='.basename($logfile);
$nav = html_nav_bar($base_url, MAX_DISPLAY_PAGES, $page_nr, $number_of_lines, $total_rows, 13, __('Entries'), 'page', 'main');
echo $nav;
html_start_box($start_string, '100%', '', '3', 'center', '');
$linecolor = false;
foreach ($logcontents as $item) {
$host_start = strpos($item, 'Device[');
$ds_start = strpos($item, 'DS[');
if (!$host_start && !$ds_start) {
$new_item = html_escape($item);
} else {
$new_item = '';
while ($host_start) {
$host_end = strpos($item, ']', $host_start);
$host_id = substr($item, $host_start + 7, $host_end - ($host_start + 7));
$new_item .= html_escape(substr($item, 0, $host_start + 7)) . "" . html_escape(substr($item, $host_start + 7, $host_end - ($host_start + 7))) . '';
$item = substr($item, $host_end);
$host_start = strpos($item, 'Device[');
}
$ds_start = strpos($item, 'DS[');
while ($ds_start) {
$ds_end = strpos($item, ']', $ds_start);
$ds_id = substr($item, $ds_start + 3, $ds_end - ($ds_start + 3));
$new_item .= html_escape(substr($item, 0, $ds_start + 3)) . "" . html_escape(substr($item, $ds_start + 3, $ds_end - ($ds_start + 3))) . '';
$item = substr($item, $ds_end);
$ds_start = strpos($item, 'DS[');
}
$new_item .= html_escape($item);
}
/* get the background color */
if (strpos($new_item, 'ERROR') !== false || strpos($new_item, 'FATAL') !== false) {
$class = 'clogError';
} elseif (strpos($new_item, 'WARN') !== false) {
$class = 'clogWarning';
} elseif (strpos($new_item, ' SQL ') !== false) {
$class = 'clogSQL';
} elseif (strpos($new_item, 'DEBUG') !== false) {
$class = 'clogDebug';
} elseif (strpos($new_item, 'STATS') !== false) {
$class = 'clogStats';
} else {
if ($linecolor) {
$class = 'odd';
} else {
$class = 'even';
}
$linecolor = !$linecolor;
}
print "| " . $new_item . " |
";
}
html_end_box();
if ($total_rows) {
echo $nav;
}
bottom_footer();
}
function utilities_clear_logfile() {
load_current_session_value('refresh', 'sess_logfile_refresh', read_config_option('log_refresh_interval'));
$refresh['seconds'] = get_request_var('refresh');
$refresh['page'] = 'utilities.php?action=view_logfile&header=false';
$refresh['logout'] = 'false';
set_page_refresh($refresh);
top_header();
$logfile = read_config_option('path_cactilog');
if ($logfile == '') {
$logfile = './log/cacti.log';
}
html_start_box(__('Clear Cacti Log'), '100%', '', '3', 'center', '');
if (file_exists($logfile)) {
if (is_writable($logfile)) {
/* fill in the current date for printing in the log */
if (defined('CACTI_DATE_TIME_FORMAT')) {
$date = date(CACTI_DATE_TIME_FORMAT);
} else {
$date = date('Y-m-d H:i:s');
}
$log_fh = fopen($logfile, 'w');
fwrite($log_fh, __('%s - WEBUI NOTE: Cacti Log Cleared from Web Management Interface.', $date) . PHP_EOL);
fclose($log_fh);
print '| ' . __('Cacti Log Cleared') . ' |
';
} else {
print "| " . __('Error: Unable to clear log, no write permissions.') . " |
";
}
} else {
print "| " . __('Error: Unable to clear log, file does not exist.'). " |
";
}
html_end_box();
}
function utilities_view_snmp_cache() {
global $poller_actions, $item_rows;
/* ================= input validation and session storage ================= */
$filters = array(
'rows' => array(
'filter' => FILTER_VALIDATE_INT,
'pageset' => true,
'default' => '-1'
),
'page' => array(
'filter' => FILTER_VALIDATE_INT,
'default' => '1'
),
'filter' => array(
'filter' => FILTER_DEFAULT,
'pageset' => true,
'default' => ''
),
'with_index' => array(
'filter' => FILTER_VALIDATE_INT,
'default' => '0'
),
'host_id' => array(
'filter' => FILTER_VALIDATE_INT,
'pageset' => true,
'default' => '-1'
),
'snmp_query_id' => array(
'filter' => FILTER_VALIDATE_INT,
'pageset' => true,
'default' => '-1'
),
'poller_action' => array(
'filter' => FILTER_VALIDATE_INT,
'pageset' => true,
'default' => '-1'
)
);
validate_store_request_vars($filters, 'sess_usnmp');
/* ================= input validation ================= */
if (get_request_var('rows') == '-1') {
$rows = read_config_option('num_rows_table');
} else {
$rows = get_request_var('rows');
}
$refresh['seconds'] = '300';
$refresh['page'] = 'utilities.php?action=view_snmp_cache&header=false';
$refresh['logout'] = 'false';
set_page_refresh($refresh);
?>
|
|
|
|
|
|
|
|
array(
'filter' => FILTER_VALIDATE_INT,
'pageset' => true,
'default' => '-1'
),
'page' => array(
'filter' => FILTER_VALIDATE_INT,
'default' => '1'
),
'filter' => array(
'filter' => FILTER_DEFAULT,
'pageset' => true,
'default' => '',
'options' => array('options' => 'sanitize_search_string')
),
'sort_column' => array(
'filter' => FILTER_CALLBACK,
'default' => 'dtd.name_cache',
'options' => array('options' => 'sanitize_search_string')
),
'sort_direction' => array(
'filter' => FILTER_CALLBACK,
'default' => 'ASC',
'options' => array('options' => 'sanitize_search_string')
),
'host_id' => array(
'filter' => FILTER_VALIDATE_INT,
'pageset' => true,
'default' => '-1'
),
'template_id' => array(
'filter' => FILTER_VALIDATE_INT,
'pageset' => true,
'default' => '-1'
),
'poller_action' => array(
'filter' => FILTER_VALIDATE_INT,
'pageset' => true,
'default' => '-1'
),
'status' => array(
'filter' => FILTER_VALIDATE_INT,
'pageset' => true,
'default' => '-1'
)
);
validate_store_request_vars($filters, 'sess_poller');
/* ================= input validation ================= */
if (get_request_var('rows') == '-1') {
$rows = read_config_option('num_rows_table');
} else {
$rows = get_request_var('rows');
}
$refresh['seconds'] = '300';
$refresh['page'] = 'utilities.php?action=view_poller_cache';
$refresh['logout'] = 'false';
set_page_refresh($refresh);
?>
|
|
0) {
$sql_where .= ($sql_where != '' ? ' AND ':' WHERE') . ' (
dtd.name_cache LIKE ' . db_qstr('%' . get_request_var('filter') . '%') . '
OR pi.arg1 LIKE ' . db_qstr('%' . get_request_var('filter') . '%') . '
OR pi.rrd_path LIKE ' . db_qstr('%' . get_request_var('filter') . '%') . ')';
} else {
$sql_where .= ($sql_where != '' ? ' AND ':' WHERE') . ' (
dtd.name_cache LIKE ' . db_qstr('%' . get_request_var('filter') . '%') . '
OR h.description LIKE ' . db_qstr('%' . get_request_var('filter') . '%') . '
OR pi.arg1 LIKE ' . db_qstr('%' . get_request_var('filter') . '%') . '
OR pi.hostname LIKE ' . db_qstr('%' . get_request_var('filter') . '%') . '
OR pi.rrd_path LIKE ' . db_qstr('%' . get_request_var('filter') . '%') . ')';
}
}
$sql = "SELECT COUNT(*)
FROM poller_item AS pi
INNER JOIN data_local AS dl
ON dl.id = pi.local_data_id
LEFT JOIN data_template_data AS dtd
ON dtd.local_data_id = pi.local_data_id
LEFT JOIN host AS h
ON pi.host_id = h.id
$sql_where";
$total_rows = get_total_row_data($_SESSION['sess_user_id'], $sql, array(), 'poller_item');
$poller_sql = "SELECT pi.*, dtd.name_cache, h.description, h.id AS host_id
FROM poller_item AS pi
INNER JOIN data_local AS dl
ON dl.id = pi.local_data_id
LEFT JOIN data_template_data AS dtd
ON dtd.local_data_id = pi.local_data_id
LEFT JOIN host AS h
ON pi.host_id = h.id
$sql_where
ORDER BY " . get_request_var('sort_column') . ' ' . get_request_var('sort_direction') . ', action ASC
LIMIT ' . ($rows*(get_request_var('page')-1)) . ',' . $rows;
$poller_cache = db_fetch_assoc($poller_sql);
$nav = html_nav_bar('utilities.php?action=view_poller_cache&filter=' . get_request_var('filter'), MAX_DISPLAY_PAGES, get_request_var('page'), $rows, $total_rows, 3, __('Entries'), 'page', 'main');
print $nav;
html_start_box('', '100%', '', '3', 'center', '');
$display_text = array(
'dtd.name_cache' => array(__('Data Source Name'), 'ASC'),
'h.description' => array(__('Device Description'), 'ASC'),
'nosort' => array(__('Details'), 'ASC'));
html_header_sort($display_text, get_request_var('sort_column'), get_request_var('sort_direction'), 1, 'utilities.php?action=view_poller_cache');
$i = 0;
if (cacti_sizeof($poller_cache)) {
foreach ($poller_cache as $item) {
if ($i % 2 == 0) {
$class = 'odd';
} else {
$class = 'even';
}
print "";
?>
|
|
|
|
";
?>
|
|
array(
'link' => 'utilities.php?action=view_tech',
'description' => __('Cacti technical support page. Used by developers and technical support persons to assist with issues in Cacti. Includes checks for common configuration issues.')
),
__('Log Administration') => array(
'link' => 'utilities.php?action=view_logfile',
'description' => __('The Cacti Log stores statistic, error and other message depending on system settings. This information can be used to identify problems with the poller and application.')
),
__('View User Log') => array(
'link' => 'utilities.php?action=view_user_log',
'description' => __('Allows Administrators to browse the user log. Administrators can filter and export the log as well.')
)
);
$utilities[__('Poller Cache Administration')] = array(
__('View Poller Cache') => array(
'link' => 'utilities.php?action=view_poller_cache',
'description' => __('This is the data that is being passed to the poller each time it runs. This data is then in turn executed/interpreted and the results are fed into the RRDfiles for graphing or the database for display.')
),
__('View Data Query Cache') => array(
'link' => 'utilities.php?action=view_snmp_cache',
'description' => __('The Data Query Cache stores information gathered from Data Query input types. The values from these fields can be used in the text area of Graphs for Legends, Vertical Labels, and GPRINTS as well as in CDEF\'s.')
),
__('Rebuild Poller Cache') => array(
'link' => 'utilities.php?action=clear_poller_cache',
'mode' => 'online',
'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.'),
'note' => array (
'message' => __('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.'),
'class' => 'textWarning'
)
),
__('Rebuild Resource Cache') => array(
'link' => 'utilities.php?action=rebuild_resource_cache',
'mode' => 'online',
'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 rebuild, 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(
__('View Boost Status') => array(
'link' => 'utilities.php?action=view_boost_status',
'description' => __('This menu pick allows you to view various boost settings and statistics associated with the current running Boost configuration.')
),
);
$utilities[__('Data Source Statistics Utilities')] = array(
__('Purge Data Source Statistics') => array(
'link' => 'utilities.php?action=purge_data_source_statistics',
'mode' => 'online',
'description' => __('This menu pick will purge all existing Data Source Statistics from the Database. If Data Source Statistics is enabled, the Data Sources Statistics will start collection again on the next Data Collector pass.')
),
);
if ($config['poller_id'] == 1) {
$utilities[__('RRD Utilities')] = array(
__('RRDfile Cleaner') => array(
'link' => 'rrdcleaner.php',
'mode' => 'online',
'description' => __('When you delete Data Sources from Cacti, the corresponding RRDfiles are not removed automatically. Use this utility to facilitate the removal of these old files.')
),
__('RRDfile Checker') => array(
'link' => 'rrdcheck.php',
'mode' => 'online',
'description' => __('Use this utility to display problems with missing rrd files or missing values in rrdfiles. You need enable rrdcheck in Configuration->Settings->Data')
),
);
}
if (snmpagent_enabled()) {
$utilities[__('SNMP Agent Utilities')] = array(
__('View SNMP Agent Cache') => array(
'link' => 'utilities.php?action=view_snmpagent_cache',
'mode' => 'online',
'description' => __('This shows all objects being handled by the SNMP Agent.')
),
__('Rebuild SNMP Agent Cache') => array(
'link' => 'utilities.php?action=rebuild_snmpagent_cache',
'mode' => 'online',
'description' => __('The SNMP cache will be cleared and re-generated if you select this option. Note that it takes another poller run to restore the SNMP cache completely.')
),
__('View SNMP Agent Notification Log') => array(
'link' => 'utilities.php?action=view_snmpagent_events',
'mode' => 'online',
'description' => __('This menu pick allows you to view the latest events SNMP Agent has handled in relation to the registered notification receivers.')
),
__('SNMP Notification Receivers') => array(
'link' => 'managers.php',
'mode' => 'online',
'description' => __('Allows Administrators to maintain SNMP notification receivers.')
),
);
}
api_plugin_hook('utilities_array');
html_start_box(__('Cacti System Utilities'), '100%', '', '3', 'center', '');
foreach($utilities as $header => $content) {
$i = 0;
foreach($content as $title => $details) {
if ((isset($details['mode']) && $details['mode'] == 'online' && $config['connection'] == 'online') || !isset($details['mode'])) {
if ($i == 0) {
html_section_header($header, 2);
}
form_alternate_row();
print "";
print "" . $title . '';
print ' | ';
print '';
print html_escape($details['description']);
if(isset($details['note'])) {
print ' ' . html_escape($details['note']['message']) . '';
}
print ' | ';
form_end_row();
$i++;
}
}
}
api_plugin_hook('utilities_list');
html_end_box();
}
function purge_data_source_statistics() {
$tables = array(
'data_source_stats_daily',
'data_source_stats_hourly',
'data_source_stats_hourly_cache',
'data_source_stats_hourly_last',
'data_source_stats_monthly',
'data_source_stats_weekly',
'data_source_stats_yearly'
);
foreach($tables as $table) {
db_execute('TRUNCATE TABLE ' . $table);
}
if (isset($_SESSION['sess_user_id'])) {
cacti_log('NOTE: Cacti DS Stats purged by user ' . get_username($_SESSION['sess_user_id']), false, 'WEBUI');
} else {
cacti_log('NOTE: Cacti DS Stats purged by cli script');
}
}
function boost_display_run_status() {
global $config, $refresh_interval, $boost_utilities_interval, $boost_refresh_interval, $boost_max_runtime;
/* ================= input validation ================= */
get_filter_request_var('refresh');
/* ==================================================== */
load_current_session_value('refresh', 'sess_boost_utilities_refresh', '30');
$last_run_time = read_config_option('boost_last_run_time', true);
$next_run_time = read_config_option('boost_next_run_time', true);
$rrd_updates = read_config_option('boost_rrd_update_enable', true);
$boost_cache = read_config_option('boost_png_cache_enable', true);
$max_records = read_config_option('boost_rrd_update_max_records', true);
$max_runtime = read_config_option('boost_rrd_update_max_runtime', true);
$update_interval = read_config_option('boost_rrd_update_interval', true);
$peak_memory = read_config_option('boost_peak_memory', true);
$detail_stats = read_config_option('stats_detail_boost', true);
$refresh['seconds'] = get_request_var('refresh');
$refresh['page'] = 'utilities.php?action=view_boost_status&header=false';
$refresh['logout'] = 'false';
set_page_refresh($refresh);
html_start_box(__('Boost Status'), '100%', '', '3', 'center', '');
?>
' . __('Idle') . '';
} elseif (substr_count($boost_status_array[0], 'running')) {
$status = '' . __('Running') . '';
} elseif (substr_count($boost_status_array[0], 'overrun')) {
$status = '' . __('Overrun Warning') . '';
} elseif (substr_count($boost_status_array[0], 'timeout')) {
$status = '' . __('Timed Out') . '';
} else {
$status = '' . __('Other') . '';
}
} else {
$status = '' . __('Disabled') . '';
$boost_status_date = null;
}
$stats_boost = read_config_option('stats_boost', true);
if ($stats_boost != '') {
$stats_boost_array = explode(' ', $stats_boost);
$stats_duration = explode(':', $stats_boost_array[0]);
$boost_last_run_duration = $stats_duration[1];
$stats_rrds = explode(':', $stats_boost_array[1]);
$boost_rrds_updated = $stats_rrds[1];
} else {
$boost_last_run_duration = '';
$boost_rrds_updated = '';
}
/* get cache directory size/contents */
$cache_directory = read_config_option('boost_png_cache_directory', true);
$directory_contents = array();
if (is_dir($cache_directory)) {
if ($handle = @opendir($cache_directory)) {
/* This is the correct way to loop over the directory. */
while (false !== ($file = readdir($handle))) {
$directory_contents[] = $file;
}
closedir($handle);
/* get size of directory */
$directory_size = 0;
$cache_files = 0;
if (cacti_sizeof($directory_contents)) {
/* goto the cache directory */
chdir($cache_directory);
/* check and fry as applicable */
foreach($directory_contents as $file) {
/* only remove jpeg's and png's */
if ((substr_count(strtolower($file), '.png')) ||
(substr_count(strtolower($file), '.jpg'))) {
$cache_files++;
$directory_size += filesize($file);
}
}
}
$directory_size = boost_file_size_display($directory_size);
$cache_files = $cache_files . ' Files';
} else {
$directory_size = '' . __('WARNING:') . '' . __('Cannot open directory');
$cache_files = '' . __('WARNING:') . ' ' . __('Unknown');
}
} else {
$directory_size = '' . __('WARNING:') . ' ' . __('Directory Does NOT Exist!!');
$cache_files = '' . __('WARNING:') . ' ' . __('N/A');
}
$running = db_fetch_cell('SELECT COUNT(*) FROM processes WHERE tasktype="boost" AND taskname="child"');
$i = 0;
/* boost status display */
html_section_header(__('Current Boost Status'), 2);
if ($config['connection'] == 'online') {
form_alternate_row();
print '' . __('Boost On-demand Updating:') . ' | ' . $status . ' | ';
if ($running > 0) {
form_alternate_row();
print '' . __('Running Processes:') . ' | ' . ($running) . ' | ';
}
}
form_alternate_row();
print '' . __('Total Poller Items:') . ' | ' . number_format_i18n($poller_items) . ' | ';
$premaining = ($data_sources ? (round(($pending_ds / $data_sources) * 100, 1)) : 0);
if ($total_records) {
form_alternate_row();
print '' . __('Total Data Sources:') . ' | ' . number_format_i18n($data_sources) . ' | ';
if ($config['connection'] == 'online') {
form_alternate_row();
print '' . __('Remaining Data Sources:') . ' | ' . ($pending_ds > 0 ? number_format_i18n($pending_ds) . " ($premaining %)":__('TBD')) . ' | ';
}
form_alternate_row();
print '' . __('Queued Boost Records:') . ' | ' . number_format_i18n($pending_records) . ' | ';
if ($config['connection'] == 'online') {
form_alternate_row();
print '' . __('Approximate in Process:') . ' | ' . number_format_i18n($remaining) . ' | ';
form_alternate_row();
print '' . __('Total Boost Records:') . ' | ' . number_format_i18n($total_records) . ' | ';
}
}
/* boost status display */
html_section_header(__('Boost Storage Statistics'), 2);
/* describe the table format */
form_alternate_row();
print '' . __('Database Engine:') . ' | ' . $engine . ' | ';
/* tell the user how big the table is */
form_alternate_row();
print '' . __('Current Boost Table(s) Size:') . ' | ' . boost_file_size_display($data_length, 2) . ' | ';
/* tell the user about the average size/record */
form_alternate_row();
print '' . __('Avg Bytes/Record:') . ' | ' . boost_file_size_display($avg_row_length, 0) . ' | ';
/* tell the user about the average size/record */
$output_length = read_config_option('boost_max_output_length');
if ($output_length != '') {
$parts = explode(':', $output_length);
if ((time()-1200) > $parts[0]) {
$ref = true;
} else {
$ref = false;
}
} else {
$ref = true;
}
if ($ref) {
if (strcmp($engine, 'MEMORY') == 0) {
$max_length = db_fetch_cell('SELECT MAX(LENGTH(output)) FROM poller_output_boost');
} else {
$max_length = '0';
}
db_execute("REPLACE INTO settings (name, value) VALUES ('boost_max_output_length', '" . time() . ':' . $max_length . "')");
} else {
$max_length = $parts[1];
}
if ($max_length != 0) {
form_alternate_row();
print '' . __('Max Record Length:') . ' | ' . __('%d Bytes', number_format_i18n($max_length)) . ' | ';
}
/* tell the user about the "Maximum Size" this table can be */
form_alternate_row();
if (strcmp($engine, 'MEMORY')) {
$max_table_allowed = __('Unlimited');
$max_table_records = __('Unlimited');
} else {
$max_table_allowed = boost_file_size_display($max_data_length, 2);
$max_table_records = number_format_i18n(($avg_row_length ? $max_data_length/$avg_row_length : 0), 3, 1000);
}
print '' . __('Max Allowed Boost Table Size:') . ' | ' . $max_table_allowed . ' | ';
/* tell the user about the estimated records that "could" be held in memory */
form_alternate_row();
print '' . __('Estimated Maximum Records:') . ' | ' . $max_table_records . ' Records | ';
if ($config['connection'] == 'online') {
/* boost last runtime display */
html_section_header(__('Previous Runtime Statistics'), 2);
form_alternate_row();
print '' . __('Last Start Time:') . ' | ' . (is_numeric($last_run_time) ? date('Y-m-d H:i:s', $last_run_time):$last_run_time) . ' | ';
/* get the last end time */
$last_end_time = read_config_option('boost_last_end_time', true);
form_alternate_row();
print '' . __('Last End Time:') . ' | ' . ($last_end_time != '' ? date('Y-m-d H:i:s', $last_end_time):__('Never Run')) . ' | ';
form_alternate_row();
print '' . __('Last Run Duration:') . ' | ';
if (is_numeric($boost_last_run_duration)) {
print ($boost_last_run_duration > 60 ? __('%d minutes', (int)$boost_last_run_duration / 60) . ', ': '') . __('%d seconds', (int) $boost_last_run_duration % 60);
if ($rrd_updates != ''){
print ' (' . __('%0.2f percent of update frequency)', round(100 * $boost_last_run_duration / $update_interval / 60));
}
} else {
print __('N/A');
}
print ' | ';
form_alternate_row();
print '' . __('RRD Updates:') . ' | ' . ($boost_rrds_updated != '' ? number_format_i18n($boost_rrds_updated):'-') . ' | ';
form_alternate_row();
print '' . __('Peak Poller Memory:') . ' | ' . ((read_config_option('boost_peak_memory') != '' && is_numeric(read_config_option('boost_peak_memory'))) ? (round(read_config_option('boost_peak_memory')/1024/1024,2)) . ' ' . __('MBytes') : __('N/A')) . ' | ';
form_alternate_row();
$memory_limit = read_config_option('boost_poller_mem_limit');
if ($memory_limit == -1) {
$memory_limit = __('Unlimited');
} elseif ($memory_limit != '') {
$memory_limit = __('%s MBytes', number_format_i18n($memory_limit) );
} else {
$memory_limit = __('N/A');
}
print '' . __('Max Poller Memory Allowed:') . ' | ' . $memory_limit . ' | ';
/* boost last runtime display */
html_section_header(__('Detailed Runtime Statistics'), 2);
form_alternate_row();
if ($detail_stats == '') {
$detail_stats = __('N/A');
} else {
$values = explode(' ', $detail_stats);
$rows = explode(':', $values[0])[1];
$time = explode(':', $values[1])[1];
$recs = explode(':', $values[2])[1];
$rcycle = explode(':', $values[3])[1];
$fandt = explode(':', $values[4])[1];
$lastu = explode(':', $values[5])[1];
$update = explode(':', $values[6])[1];
$delete = explode(':', $values[7])[1];
$detail_stats = __('Records: %s (ds rows), Time: %s (secs), GetRows: %s (secs), ResultsCycle: %s (secs), FileAndTemplate: %s (secs), LastUpdate: %s (secs), RRDUpdate: %s (secs), Delete: %s (secs)',
number_format_i18n($rows),
number_format_i18n($time),
number_format_i18n($recs),
number_format_i18n($rcycle),
number_format_i18n($fandt),
number_format_i18n($lastu),
number_format_i18n($update),
number_format_i18n($delete));
}
print '' . __('Previous Runtime Timers:') . ' | ' . (($detail_stats != '') ? $detail_stats:__('N/A')) . ' | ';
$runtimes = db_fetch_assoc('SELECT name, value, CAST(replace(name, "stats_boost_", "") AS signed) AS ome
FROM settings
WHERE name LIKE "stats_boost_%"
ORDER BY ome');
if (cacti_sizeof($runtimes)) {
foreach($runtimes as $r) {
$process = str_replace('stats_boost_', '', $r['name']);
if ($r['value'] != '') {
$values = explode(' ', $r['value']);
$time = explode(':', $values[0])[1];
$rrds = explode(':', $values[2])[1];
} else {
$time = 0;
$rrds = 0;
}
$rows_to_process = db_fetch_cell_prepared('SELECT COUNT(*)
FROM poller_output_boost_local_data_ids
WHERE process_handler = ?',
array($process));
$runtime = db_fetch_cell_prepared('SELECT UNIX_TIMESTAMP() - UNIX_TIMESTAMP(started)
FROM processes
WHERE tasktype = "boost"
AND taskname = "child"
AND taskid = ?',
array($process));
form_alternate_row();
if ($rows_to_process > 0) {
print '' . __esc('Process: %d', $process) . ' | ' . __('Status: Running, Remaining: %s (dses), CurrentRuntime: %s (secs), PrevRuntime: %s (secs), PrevProcessed: %10s (ds rows)', number_format_i18n($rows_to_process), number_format_i18n($runtime), number_format_i18n($time), number_format_i18n($rrds)) . ' | ';
} else {
print '' . __esc('Process: %d', $process) . ' | ' . __('Status: Idle, PrevRuntime: %s (secs), PrevProcessed: %10s (ds rows)', number_format_i18n($time), number_format_i18n($rrds)) . ' | ';
}
}
}
/* boost runtime display */
html_section_header(__('Run Time Configuration'), 2);
form_alternate_row();
print '' . __('Update Frequency:') . ' | ' . ($rrd_updates == '' ? __('N/A') : $boost_refresh_interval[$update_interval]) . ' | ';
form_alternate_row();
print '' . __('Concurrent Processes:') . ' | ' . read_config_option('boost_parallel') . ' | ';
form_alternate_row();
print '' . __('Next Start Time:') . ' | ' . (is_numeric($next_run_time) ? date('Y-m-d H:i:s', $next_run_time):$next_run_time) . ' | ';
form_alternate_row();
print '' . __('Maximum Records:') . ' | ' . number_format_i18n($max_records) . ' ' . __('Records') . ' | ';
form_alternate_row();
print '' . __('Maximum Allowed Runtime:') . ' | ' . $boost_max_runtime[$max_runtime] . ' | ';
/* boost caching */
html_section_header(__('Image Caching'), 2);
form_alternate_row();
print '' . __('Image Caching Status:') . ' | ' . ($boost_cache == '' ? __('Disabled') : __('Enabled')) . ' | ';
form_alternate_row();
print '' . __('Cache Directory:') . ' | ' . $cache_directory . ' | ';
form_alternate_row();
print '' . __('Cached Files:') . ' | ' . $cache_files . ' | ';
form_alternate_row();
print '' . __('Cached Files Size:') . ' | ' . $directory_size . ' | ';
html_end_box(true);
}
}
/**
*
*
* snmpagent_utilities_run_cache()
*
* @param mixed
* @return
*/
function snmpagent_utilities_run_cache() {
global $item_rows;
get_filter_request_var('mib', FILTER_CALLBACK, array('options' => 'sanitize_search_string'));
$mibs = db_fetch_assoc('SELECT DISTINCT mib FROM snmpagent_cache');
$registered_mibs = array();
if($mibs && $mibs >0) {
foreach($mibs as $mib) { $registered_mibs[] = $mib['mib']; }
}
/* ================= input validation ================= */
if(!in_array(get_request_var('mib'), $registered_mibs) && get_request_var('mib') != '-1' && get_request_var('mib') != '') {
die_html_input_error();
}
/* ==================================================== */
/* ================= input validation and session storage ================= */
$filters = array(
'rows' => array(
'filter' => FILTER_VALIDATE_INT,
'pageset' => true,
'default' => '-1'
),
'page' => array(
'filter' => FILTER_VALIDATE_INT,
'default' => '1'
),
'filter' => array(
'filter' => FILTER_DEFAULT,
'pageset' => true,
'default' => ''
),
'mib' => array(
'filter' => FILTER_CALLBACK,
'default' => '-1',
'options' => array('options' => 'sanitize_search_string')
)
);
validate_store_request_vars($filters, 'sess_snmpac');
/* ================= input validation ================= */
if (get_request_var('rows') == -1) {
$rows = read_config_option('num_rows_table');
} else {
$rows = get_request_var('rows');
}
?>
|
|
' . $name . '';
}else {
print "$name | ";
}
form_selectable_cell($mib, $item['oid']);
form_selectable_cell($item['kind'], $item['oid']);
form_selectable_cell($max_access, $item['oid']);
form_selectable_ecell((in_array($item['kind'], array(__('Scalar'), __('Column Data'))) ? $item['value'] : __('N/A')), $item['oid']);
form_end_row();
}
}
html_end_box();
if (cacti_sizeof($snmp_cache)) {
print $nav;
}
?>
'LOW',
SNMPAGENT_EVENT_SEVERITY_MEDIUM => 'MEDIUM',
SNMPAGENT_EVENT_SEVERITY_HIGH => 'HIGH',
SNMPAGENT_EVENT_SEVERITY_CRITICAL => 'CRITICAL'
);
$severity_colors = array(
SNMPAGENT_EVENT_SEVERITY_LOW => '#00FF00',
SNMPAGENT_EVENT_SEVERITY_MEDIUM => '#FFFF00',
SNMPAGENT_EVENT_SEVERITY_HIGH => '#FF0000',
SNMPAGENT_EVENT_SEVERITY_CRITICAL => '#FF00FF'
);
$receivers = db_fetch_assoc('SELECT DISTINCT manager_id, hostname
FROM snmpagent_notifications_log
INNER JOIN snmpagent_managers
ON snmpagent_managers.id = snmpagent_notifications_log.manager_id');
/* ================= input validation ================= */
get_filter_request_var('receiver');
if(!in_array(get_request_var('severity'), array_keys($severity_levels)) && get_request_var('severity') != '-1' && get_request_var('severity') != '') {
die_html_input_error();
}
/* ==================================================== */
if (isset_request_var('purge')) {
db_execute('TRUNCATE table snmpagent_notifications_log');
/* reset filters */
set_request_var('clear', true);
}
/* ================= input validation and session storage ================= */
$filters = array(
'rows' => array(
'filter' => FILTER_VALIDATE_INT,
'pageset' => true,
'default' => '-1'
),
'page' => array(
'filter' => FILTER_VALIDATE_INT,
'default' => '1'
),
'filter' => array(
'filter' => FILTER_DEFAULT,
'pageset' => true,
'default' => ''
),
'severity' => array(
'filter' => FILTER_VALIDATE_INT,
'pageset' => true,
'default' => '-1'
),
'receiver' => array(
'filter' => FILTER_VALIDATE_INT,
'pageset' => true,
'default' => '-1'
)
);
validate_store_request_vars($filters, 'sess_snmpl');
/* ================= input validation ================= */
if (get_request_var('rows') == -1) {
$rows = read_config_option('num_rows_table');
} else {
$rows = get_request_var('rows');
}
?>
|
|
";
print "" . date('Y-m-d H:i:s', $item['time']) . ' | ';
print '' . html_escape($item['hostname']) . ' | ';
if($item['description']) {
print '' . html_escape($item['notification']) . ' | ';
}else {
print '' . html_escape($item['notification']) . ' | ';
}
print "$varbinds | ";
form_end_row();
}
} else {
print '| ' . __('No SNMP Notification Log Entries') . ' |
';
}
html_end_box();
if (cacti_sizeof($logs)) {
print $nav;
}
?>