' . __('Error') . '
' . __('This installation is already up-to-date. Click here to use Cacti.', '../index.php') . '
'; exit; } elseif (preg_match('/^0\.6/', $old_cacti_version)) { print '' . __('Error') . '
' . __('You are attempting to install Cacti %s onto a 0.6.x database. To continue, you must create a new database, import "cacti.sql" into it, and update "include/config.php" to point to the new database.', CACTI_VERSION) . '
'; exit; } elseif (empty($old_cacti_version)) { print '' . __('Error') . '
' . __("You have created a new database, but have not yet imported the 'cacti.sql' file. At the command line, execute the following to continue:
mysql -u %s -p %s < cacti.sql
This error may also be generated if the cacti database user does not have correct permissions on the Cacti database. Please ensure that the Cacti database user has the ability to SELECT, INSERT, DELETE, UPDATE, CREATE, ALTER, DROP, INDEX on the Cacti database.", $database_username, $database_default) . '
'; print '' . __("In Cacti %s, you must also import MySQL TimeZone information into MySQL and grant the Cacti user SELECT access to the mysql.time_zone_name table", CACTI_VERSION) . '
'; if ($config['cacti_server_os'] == 'unix') { print '' . __("On Linux/UNIX, do the following:") . '
' . __("mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql") . "\n";
} else {
print '' . __("On Windows, you must follow the instructions here Time zone description table. Once that is complete, you can issue the following command to grant the Cacti user access to the tables:") . '
';
}
print __("GRANT SELECT ON mysql.time_zone_name to '%s'@'localhost' IDENTIFIED BY '%s'", $database_username, $database_password) . '';
exit;
}
/* default value for this variable */
if (isset_request_var('install_type')) {
$_SESSION['sess_install_type'] = get_filter_request_var('install_type');
} elseif (isset($_SESSION['sess_install_type'])) {
set_request_var('install_type', $_SESSION['sess_install_type']);
} else {
set_request_var('install_type', '0');
}
/* defaults for the install type dropdown */
if ($old_cacti_version == 'new_install') {
$default_install_type = '1';
} else {
$default_install_type = '3';
}
/* pre-processing that needs to be done for each step */
if (isset_request_var('step') && get_filter_request_var('step') > 0) {
$step = get_filter_request_var('step');
switch($step) {
case '1':
/* license&welcome - send to checkdependencies */
$previous_step = 0;
$step++;
break;
case '2':
$previous_step = 1;
/* checkdependencies - send to install/upgrade */
$step++;
break;
case '3':
$previous_step = 2;
if (get_filter_request_var('install_type') == '1') {
/* install - New Primary Server */
$step = 4;
} elseif (get_filter_request_var('install_type') == '2') {
/* install - New Remote Poller */
$step = 4;
} elseif (get_filter_request_var('install_type') == '3') {
/* install/upgrade - if user chooses "Upgrade" send to upgrade */
$step = 8;
}
break;
case '4':
$previous_step = 3;
/* settingscheck - send to settings-install */
$step = 5;
break;
case '5':
$previous_step = 4;
if (get_request_var('install_type') != 2) {
/* settings-install - send to template-import */
$step = 6;
} else {
/* remote pollers are done, no template import */
$step = 7;
}
break;
case '6':
$previous_step = 5;
/* template-import - send to installfinal */
$step = 7;
break;
case '7':
break;
case '8':
$previous_step = 8;
/* upgrade - if user upgrades send to settings check */
if (version_compare($old_cacti_version, '0.8.5a', '<=')) {
/* upgrade - if user runs old version send to upgrade-oldversion */
$step = 9;
} else {
$step = 7;
}
break;
case '9':
$previous_step = 8;
/* upgrade-oldversion - if user upgrades from old version send to settingscheck */
$step = 4;
break;
}
} else {
$previous_step = 0;
$step = 1;
}
/* installfinal - Install templates, change cacti version and send to login page */
if ($step == '7') {
include_once('../lib/data_query.php');
include_once('../lib/utility.php');
include_once('../lib/import.php');
include_once('../lib/api_automation.php');
/* look for templates that have been checked for install */
if (get_request_var('install_type') == 1) {
$install = Array();
foreach ($_POST as $post => $v) {
if (substr($post, 0, 4) == 'chk_' && is_numeric(substr($post, 4))) {
$install[] = substr($post, 4);
}
}
$path = $config['base_path'] . '/install/templates/';
/* install templates */
$templates = install_setup_get_templates(1);
if (!empty($install)) {
foreach ($install as $i) {
import_package($path . $templates[$i]['filename'], 1, false);
}
}
// Add the correct device type
if ($config['cacti_server_os'] == 'win32') {
$hash = '5b8300be607dce4f030b026a381b91cd';
$version = 2;
$community = 'public';
$avail = 'snmp';
$ip = 'localhost';
$description = "Local Windows Machine";
} else {
$hash = '2d3e47f416738c2d22c87c40218cc55e';
$version = 0;
$community = 'public';
$avail = 'none';
$ip = 'localhost';
$description = "Local Linux Machine";
}
$host_template_id = db_fetch_cell_prepared('SELECT id FROM host_template WHERE hash = ?', array($hash));
// Add the host
if (!empty($host_template_id)) {
cacti_log('Device Template for First Cacti Device is ' . $host_template_id);
$results = shell_exec(read_config_option('path_php_binary') . ' -q ' . $config['base_path'] . "/cli/add_device.php" .
" --description=" . cacti_escapeshellarg($description) . " --ip=" . cacti_escapeshellarg($ip) . " --template=$host_template_id" .
" --notes=" . cacti_escapeshellarg('Initial Cacti Device') . " --poller=1 --site=0 --avail=" . cacti_escapeshellarg($avail) .
" --version=$version --community=" . cacti_escapeshellarg($community));
$host_id = db_fetch_cell_prepared('SELECT id
FROM host
WHERE host_template_id = ?
LIMIT 1',
array($host_template_id));
if (!empty($host_id)) {
$templates = db_fetch_assoc_prepared('SELECT *
FROM host_graph
WHERE host_id = ?',
array($host_id));
if (sizeof($templates)) {
foreach($templates as $template) {
automation_execute_graph_template($host_id, $template['graph_template_id']);
}
}
}
} else {
cacti_log('WARNING: Device Template for your Operating System Not Found. You will need to import Device Templates or Cacti Packages to monitor your Cacti server.');
}
}
if (get_request_var('install_type') == 2) {
global $local_db_cnn_id;
$success = remote_update_config_file();
/* change cacti version */
db_execute('DELETE FROM version', true, $local_db_cnn_id);
db_execute("INSERT INTO version (cacti) VALUES ('" . CACTI_VERSION . "')", true, $local_db_cnn_id);
/* make the poller and poller_output_boost InnoDB */
db_execute('ALTER TABLE poller_output ENGINE=InnoDB');
db_execute('ALTER TABLE poller_output_boost ENGINE=InnoDB');
} else {
/* pre-fill poller cache with initial data on a new install only */
if ($old_cacti_version == 'new_install') {
/* just in case we have hard drive graphs to deal with */
$host_id = db_fetch_cell("SELECT id FROM host WHERE hostname='127.0.0.1'");
if (!empty($host_id)) {
run_data_query($host_id, 6);
}
/* it's always a good idea to re-populate the poller cache to make sure everything is refreshed and up-to-date */
repopulate_poller_cache();
/* fill up the snmpcache */
snmpagent_cache_rebuilt();
/* generate RSA key pair */
rsa_check_keypair();
}
/* change cacti version */
db_execute('DELETE FROM version');
db_execute("INSERT INTO version (cacti) VALUES ('" . CACTI_VERSION . "')");
}
/* clear session */
setcookie(session_name(),'',time() - 3600, $config['url_path']);
kill_session_var('sess_config_array');
kill_session_var('sess_host_cache_array');
/* send to login page */
header ('Location: ../index.php');
exit;
/* upgrade */
} elseif (($step == '8') && (get_filter_request_var('install_type') == '3')) {
// if the version is not found, die
if (!array_key_exists($old_cacti_version, $cacti_version_codes)) {
print " " . __('Error') . "
"
. __('Invalid Cacti version %1$s, cannot upgrade to %2$s', $old_cacti_version, CACTI_VERSION) . "
";
exit;
}
// loop through versions from old version to the current, performing updates for each version in the chain
foreach ($cacti_version_codes as $cacti_upgrade_version => $hash_code) {
// skip versions old than the database version
if (cacti_version_compare($old_cacti_version, $cacti_upgrade_version, '>=')) {
continue;
}
// construct version upgrade include path
$upgrade_file = dirname(__FILE__) . '/upgrades/' . str_replace('.', '_', $cacti_upgrade_version) . '.php';
$upgrade_function = 'upgrade_to_' . str_replace('.', '_', $cacti_upgrade_version);
// check for upgrade version file, then include, check for function and execute
if (file_exists($upgrade_file)) {
include($upgrade_file);
if (function_exists($upgrade_function)) {
call_user_func($upgrade_function);
}
}
}
foreach ($plugins_integrated as $plugin) {
if (api_plugin_is_enabled ($plugin)) {
api_plugin_remove_hooks ($plugin);
api_plugin_remove_realms ($plugin);
db_execute("DELETE FROM plugin_config WHERE directory = '$plugin'");
}
}
}
if (isset_request_var('database_hostname')) {
$_SESSION['database_type'] = 'mysql';
$_SESSION['database_default'] = get_nfilter_request_var('database_default');
$_SESSION['database_hostname'] = get_nfilter_request_var('database_hostname');
$_SESSION['database_username'] = get_nfilter_request_var('database_username');
$_SESSION['database_password'] = get_nfilter_request_var('database_password');
$_SESSION['database_port'] = get_filter_request_var('database_port');
$_SESSION['database_ssl'] = isset_request_var('database_ssl') ? true:false;
}
if (isset($rdatabase_default) &&
isset($rdatabase_username) &&
isset($rdatabase_hostname) &&
isset($rdatabase_port)) {
$remote_good = true;
} else {
$remote_good = false;
}
if (is_writable($config['base_path'] . '/include/config.php')) {
$good_write = true;
} else {
$good_write = false;
}
$enabled = '1';
?>
Cacti Server Installation/Upgrade
include/themes/modern/main.css' type='text/css' rel='stylesheet'>
include/themes/modern/jquery.zoom.css' type='text/css' rel='stylesheet'>
include/themes/modern/jquery-ui.css' type='text/css' rel='stylesheet'>
include/themes/modern/default/style.css' type='text/css' rel='stylesheet'>
include/themes/modern/jquery.multiselect.css' type='text/css' rel='stylesheet'>
include/themes/modern/jquery.timepicker.css' type='text/css' rel='stylesheet'>
include/themes/modern/jquery.colorpicker.css' type='text/css' rel='stylesheet'>
include/themes/modern/pace.css' type='text/css' rel='stylesheet'>
include/fa/css/font-awesome.css' type='text/css' rel='stylesheet'>
images/favicon.ico' rel='shortcut icon'>
images/cacti_logo.gif' sizes='96x96'>