From 88c3a9907302977e217a1181c53534aeca479e75 Mon Sep 17 00:00:00 2001 From: Micke2k Date: Thu, 24 Mar 2016 04:09:49 +0400 Subject: [PATCH 1/5] First attempt at new install 1. Added check for RRD 1.5 2. Backported dependencies check 3. Backported template installer 4. Added theme selection Tested and working with new installation on Linux. Backported a template for testing as well -> Disk IO. I will test the Upgrade and Windows installation as well as clean it up and add some extras. --- install/index.php | 435 ++++++++++++++++++++++--- install/templates/Disk IO Usage.xml.gz | Bin 0 -> 11290 bytes 2 files changed, 396 insertions(+), 39 deletions(-) create mode 100644 install/templates/Disk IO Usage.xml.gz diff --git a/install/index.php b/install/index.php index 82345f5ab0..7185b72d96 100644 --- a/install/index.php +++ b/install/index.php @@ -24,13 +24,15 @@ define('IN_CACTI_INSTALL', 1); -include('../include/global.php'); +include_once('../include/global.php'); + +top_header(); + +api_plugin_hook('console_before'); /* allow the upgrade script to run for as long as it needs to */ ini_set('max_execution_time', '0'); -/* verify all required php extensions */ -if (!verify_php_extensions()) {exit;} $cacti_versions = array('0.8', '0.8.1', '0.8.2', '0.8.2a', '0.8.3', '0.8.3a', '0.8.4', '0.8.5', '0.8.5a', '0.8.6', '0.8.6a', '0.8.6b', '0.8.6c', '0.8.6d', '0.8.6e', '0.8.6f', '0.8.6g', '0.8.6h', '0.8.6i', '0.8.6j', '0.8.6k', @@ -64,24 +66,16 @@ exit; } -function verify_php_extensions() { - global $database_type; - $extensions = array('session', 'sockets', 'xml', 'PDO', 'pdo_' . $database_type); - $ok = true; - $missing_extension = "

Error

-

The following PHP extensions are missing:

Please install those PHP extensions and retry

"; - } - return $ok; + return $extensions; } + function db_install_execute($cacti_version, $sql) { $sql_install_cache = (isset($_SESSION['sess_sql_install_cache']) ? $_SESSION['sess_sql_install_cache'] : array()); @@ -144,12 +138,153 @@ function find_best_path($binary_name) { } } + +function plugin_setup_get_templates() { + global $config; + $templates = Array( + 'Disk IO Usage.xml.gz' + ); + + $path = $config['base_path'] . '/install/templates'; + $info = Array(); + foreach ($templates as $xmlfile) { + $filename = "compress.zlib:///$path/$xmlfile"; + $xml = file_get_contents($filename);; + //Loading Template Information from package + $xmlget = simplexml_load_string($xml); + $data = to_array($xmlget); + if (is_array($data['info']['author'])) $data['info']['author'] = '1'; + if (is_array($data['info']['email'])) $data['info']['email'] = '2'; + if (is_array($data['info']['description'])) $data['info']['description'] = '3'; + if (is_array($data['info']['homepage'])) $data['info']['homepage'] = '4'; + + $data['info']['filename'] = $xmlfile; + $info[] = $data['info']; + } + return $info; +} + +function plugin_setup_install_template($xmlfile, $opt = 0, $interval = 5) { + global $config; + if ($opt) { + $path = $config['base_path'] . '/install/templates/'; + } else { + $path = $config['base_path'] . '/install/templates/'; + } + + if ($interval == 1) { + $interval = array(1, 2, 3, 4, 5); + } else { + $interval = array(1, 2, 3, 4); + } + + /* set new timeout and memory settings */ + ini_set("max_execution_time", "5"); + ini_set("memory_limit", "64M"); + + $public_key = <<") !== FALSE) { + $binary_signature = base64_decode(trim(str_replace(array('', ''), '', $x))); + $x = " \n"; + } + $xml .= "$x"; + } + fclose($f); + + // Verify Signature + $ok = openssl_verify($xml, $binary_signature, $public_key); + if ($ok == 1) { + //print " File is signed correctly\n"; + } elseif ($ok == 0) { + //print " ERROR: File has been tampered with\n"; + //exit; + return; + } else { + //print " ERROR: Could not verify signature!\n"; + //exit; + return; + } + //print "Loading Plugin Information from package\n"; + $xmlget = simplexml_load_string($xml); + $data = to_array($xmlget); + + $plugin = $data['info']['name']; + //print "Verifying each files signature\n"; + if (isset($data['files']['file']['data'])) { + $data['files']['file'] = array($data['files']['file']); + } + + foreach ($data['files']['file'] as $f) { + + $binary_signature = base64_decode($f['filesignature']); + $fdata = base64_decode($f['data']); + $ok = openssl_verify($fdata, $binary_signature, $public_key); + if ($ok == 1) { + //print " File OK : " . $f['name'] . "\n"; + } else { + //print " ERROR: Could not verify signature for file: " . $f['name'] . "\n"; + //exit; + return; + } + } + include_once($config['base_path'] . "/lib/import.php"); + + $p = $config['base_path']; + $error = false; + //print "Writing Files\n"; + foreach ($data['files']['file'] as $f) { + $fdata = base64_decode($f['data']); + $name = $f['name']; + if (substr($name, 0, 8) == 'scripts/' || substr($name, 0, 9) == 'resource/') { + $filename = "$p/$name"; + //print " Writing $filename\n"; + $file = fopen($filename,'wb'); + fwrite($file ,$fdata, strlen($fdata)); + fclose($file); + clearstatcache(); + if (!file_exists($filename)) { + //print " Unable to create directory: $filename\n"; + } + } else { + $debug_data = import_xml_data($fdata, false, $interval); + } + } + //print "File creation complete\n"; +} + + +function to_array ($data) { + if (is_object($data)) { + $data = get_object_vars($data); + } + return (is_array($data)) ? array_map(__FUNCTION__,$data) : $data; +} + + /* Here, we define each name, default value, type, and path check for each value we want the user to input. The "name" field must exist in the 'settings' table for this to work. Cacti also uses different default values depending on what OS it is running on. */ +function install_file_paths () { +global $config, $settings; + + /* RRDTool Binary Path */ +$input = array(); $input['path_rrdtool'] = $settings['path']['path_rrdtool']; if ($config['cacti_server_os'] == 'unix') { @@ -324,6 +459,7 @@ function find_best_path($binary_name) { } } + /* log file path */ $input['path_cactilog'] = $settings['path']['path_cactilog']; $input['path_cactilog']['description'] = 'The path to your Cacti log file.'; @@ -333,6 +469,16 @@ function find_best_path($binary_name) { $input['path_cactilog']['default'] = $config['base_path'] . '/log/cacti.log'; } +/* Theme */ +$input['selected_theme'] = $settings['visual']['selected_theme']; +$input['selected_theme']['description'] = 'Please select one of the available Themes to skin your Cacti with.'; +if (config_value_exists('selected_theme')) { + $input['selected_theme']['default'] = read_config_option('selected_theme'); +} else { + $input['selected_theme']['default'] = 'modern'; +} + + /* RRDTool Version */ if ((file_exists($input['path_rrdtool']['default'])) && (($config['cacti_server_os'] == 'win32') || (is_executable($input['path_rrdtool']['default']))) ) { $input['rrdtool_version'] = $settings['general']['rrdtool_version']; @@ -342,7 +488,9 @@ function find_best_path($binary_name) { exec("\"" . $input['path_rrdtool']['default'] . "\"", $out_array); if (sizeof($out_array) > 0) { - if (preg_match('/^RRDtool 1\.4/', $out_array[0])) { + if (preg_match('/^RRDtool 1\.5/', $out_array[0])) { + $input['rrdtool_version']['default'] = 'rrd-1.5.x'; + }else if (preg_match('/^RRDtool 1\.4\./', $out_array[0])) { $input['rrdtool_version']['default'] = 'rrd-1.4.x'; }else if (preg_match('/^RRDtool 1\.3\./', $out_array[0])) { $input['rrdtool_version']['default'] = 'rrd-1.3.x'; @@ -353,7 +501,8 @@ function find_best_path($binary_name) { } } } - + return $input; +} /* default value for this variable */ if (!isset($_REQUEST['install_type'])) { $_REQUEST['install_type'] = 0; @@ -369,38 +518,69 @@ function find_best_path($binary_name) { /* pre-processing that needs to be done for each step */ if (isset($_REQUEST['step']) && $_REQUEST['step'] > 0) { $step = intval($_REQUEST['step']); + + /* license and welcome screen - send to dependencies */ if ($step == '1') { $step = '2'; - } elseif (($step == '2') && ($_REQUEST['install_type'] == '1')) { + /* check for dependencies - send to install/upgrade */ + } elseif ($step == '2') { $step = '3'; - } elseif (($step == '2') && ($_REQUEST['install_type'] == '3')) { + /* install/upgrade - if user chooses "New Install" send to pathcheck */ + } elseif (($step == '3') && ($_REQUEST['install_type'] == '1')) { + $step = '4'; + /* install/upgrade - if user chooses "Upgrade" send to upgrade */ + } elseif (($step == '3') && ($_REQUEST['install_type'] == '3')) { $step = '8'; + /* upgrade-oldversion - if user runs old version send to oldversionwarning*/ } elseif (($step == '8') && ($old_version_index <= array_search('0.8.5a', $cacti_versions))) { $step = '9'; + /* upgrade - if user upgrades send to pathcheck */ } elseif ($step == '8') { - $step = '3'; + $step = '4'; + /* oldversionwarning - if user upgrades from old version send to dependencies */ } elseif ($step == '9') { $step = '3'; - } elseif ($step == '3') { - $step = '4'; + /* pathcheck - send to installpaths */ + } elseif ($step == '4') { + $step = '5'; + /* installpaths - send to templates */ + } elseif ($step == '5') { + $step = '6'; + /* templates - send to install and finalize */ + } elseif ($step == '6') { + $step = '7'; } } else { $step = 1; } -if ($step == '4') { + + + + +/* install and finalize - Install templates, change cacti version and send to login page */ +if ($step == '7') { include_once('../lib/data_query.php'); include_once('../lib/utility.php'); - $i = 0; - - /* get all items on the form and write values for them */ - while (list($name, $array) = each($input)) { - if (isset($_POST[$name])) { - db_execute("replace into settings (name,value) values ('$name','" . $_POST[$name] . "')"); + + /* look for templates that have been checked for install */ + $install = Array(); + foreach ($_POST as $post => $v) { + if (substr($post, 0, 4) == 'chk_' && is_numeric(substr($post, 4))) { + $install[] = substr($post, 4); + } } - } - + /* install templates */ + $templates = plugin_setup_get_templates(1); + if (!empty($install)) { + foreach ($install as $i) { + plugin_setup_install_template($templates[$i]['filename'], 1, $templates[$i]['interval']); + } + } + + /* clear session */ + setcookie(session_name(),'',time() - 3600,'/'); kill_session_var('sess_config_array'); @@ -425,11 +605,17 @@ function find_best_path($binary_name) { rsa_check_keypair(); } + /* change cacti version */ db_execute('DELETE FROM version'); db_execute("INSERT INTO version (cacti) VALUES ('" . $config["cacti_version"] . "')"); + /* send to login page */ header ('Location: ../index.php'); exit; + + + + /* upgrade */ }elseif (($step == '8') && ($_REQUEST['install_type'] == '3')) { /* if the version is not found, die */ if (!is_int($old_version_index)) { @@ -622,8 +808,65 @@ function find_best_path($binary_name) { but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

+ + + Pre-installation Check
'; + print 'Cacti requies several PHP Modules to be installed to work properly. If any of these are not installed, you will be unable to continue the installation until corrected.

'; + + html_start_box(" " . __("Required PHP Modules") . "", "30", 0, "", "", false); + html_header(array(array('name' => 'Name'), array('name' => 'Required'), array('name' => 'Installed'))); + + + form_selectable_cell('PHP Version', ''); + form_selectable_cell('5.2.0+', ''); + form_selectable_cell((version_compare(PHP_VERSION, '5.2.0', '<') ? "" . PHP_VERSION . "" : "" . PHP_VERSION . ""), ''); + form_end_row(); + + $extensions = array( array('name' => 'session', 'installed' => false), + array('name' => 'sockets', 'installed' => false), + array('name' => 'mysql', 'installed' => false), + array('name' => 'xml', 'installed' => false), + array('name' => 'pcre', 'installed' => false), + array('name' => 'json', 'installed' => false), + ); + + $ext = verify_php_extensions($extensions); + $i = 0; + $enabled = true; + foreach ($ext as $id =>$e) { + form_alternate_row_color($colors["alternate"], $colors["light"], $i, 'line' . $id); $i++; + form_selectable_cell($e['name'], ''); + form_selectable_cell('Yes', ''); + form_selectable_cell(($e['installed'] ? 'Yes' : 'NO'), ''); + form_end_row(); + if (!$e['installed']) $enabled = false; + } + html_end_box(false); + + print '
' . __('
These extensions may increase the performance of your Cacti install but are not necessary.

'); + $extensions = array( array('name' => 'snmp', 'installed' => false), + array('name' => 'mysqli', 'installed' => false), + array('name' => 'gd', 'installed' => false), + + ); + + $ext = verify_php_extensions($extensions); + $i = 0; + html_start_box(" " . __("Other Modules") . "", "30", 0, "", "", false); + html_header(array(array('name' => 'Name'), array('name' => 'Required'), array('name' => 'Installed'))); + foreach ($ext as $id => $e) { + form_alternate_row_color($colors["alternate"], $colors["light"], $i, 'line' . $id); $i++; + //print '' . $e['name'] . 'Yes' . ($e['installed'] ? 'Yes' : 'NO') . ''; + form_selectable_cell($e['name'], ''); + form_selectable_cell('Yes', ''); + form_selectable_cell(($e['installed'] ? 'Yes' : 'NO'), ''); + form_end_row(); + } + html_end_box(false); - +?> +

Please select the type of installation

@@ -644,11 +887,20 @@ function find_best_path($binary_name) { print "Server Operating System Type: " . $config['cacti_server_os'] . '
'; ?>

- + + + + + +

Make sure all of these values are correct before continuing.

-

NOTE: Once you click 'Finish', +

NOTE: Once you click 'Finish', all of your settings will be saved and your database will be upgraded if this is an upgrade. You can change any of the settings on this screen at a later time by going to 'Cacti Settings' from within Cacti.

+ + + Settings installed

'; + + /* Check if /resource is writable */ + print "

Next step is template installation. For installation to work the '". $config['base_path'] . "/resource' folder needs to be writable by the webserver.

"; + + + if (is_writable('../resource/snmp_queries')) { + $writeaccess_snmp_q = "Writable"; + } else { + $writeaccess_snmp_q = "is not writable"; + $writable=FALSE; + } + + if (is_writable('../resource/script_server')) { + $writeaccess_script_s = "Writable"; + } else { + $writeaccess_script_s = "is not writable"; + $writable=FALSE; + } + if (is_writable('../resource/script_queries')) { + $writeaccess_script_q = "Writable"; + } else { + $writeaccess_script_q = "is not writable"; + $writable=FALSE; + } + + + print "

". $config['base_path'] . "/resource/snmp_queries is $writeaccess_snmp_q

"; + print "

". $config['base_path'] . "/resource/script_server is $writeaccess_script_s

"; + print "

". $config['base_path'] . "/resource/script_queries is $writeaccess_script_q


"; + + /* Print help message for unix and windows if directory is not writable */ + if (($config['cacti_server_os'] == "unix") && isset($writable)) { + print 'Make sure your webserver has read and write access to the entire folder structure.
Example: chown -R apache.apache /resource
'; + } elseif (($config['cacti_server_os'] == "win32") && isset($writable)){ + print 'Check Permissions'; + } + + + + ?> + + + +

Make sure all of these values are correct before continuing.

+ Template Setup"; + print "Templates allow you to monitor and graph a vast assortment of data within Cacti. While the base Cacti install provides basic templates for most devices, you can select a few extra templates below to include in your install.

"; + print "
"; + + $templates = plugin_setup_get_templates(); + + html_start_box('Templates', '100%', '3', 'center', "", ""); + html_header_checkbox(array(array('name' => 'Name'), array('name' => 'Description'), array('name' => 'Author'), array('name' => 'Homepage'))); + $i = 0; + foreach ($templates as $id => $p) { + form_alternate_row_color($colors["alternate"], $colors["light"], $i, 'line' . $id); $i++; + form_selectable_cell($p['name'], $id); + form_selectable_cell($p['description'], $id); + form_selectable_cell($p['author'], $id); + if ($p['homepage'] != '') { + form_selectable_cell("" . $p['homepage'] . "", $id); + } else { + form_selectable_cell('', $id); + } + form_checkbox_cell($p['name'], $id); + form_end_row(); + html_end_box(false); + + } + + ?> + +

Upgrade results:

- +

Important Upgrade Notice

@@ -782,5 +1135,9 @@ function find_best_path($binary_name) {
- - +-p5h++kgG*{p#-a9{>OK z{%#iC{HCoQgMXXDe@`A~%bWLa(`$5db@z1h>17uFroMk$ex@6<=O^#}({Ib!-C`Er zzJHs4r(52Abn}2_e)FE59{%6kx9-e+TK(_c&C~n0B?{?nDk&7=Ei z_3*U1zpMA?-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CH 2/5] Fix for vdef table creation Tables were not created because primary key was: KEY PRIMARY 'id' Instead of PRIMARY KEY 'id Saw some weird behaviour when switching between 0.8.8g and 1.0, this was solved when browser was closed between upgrades. Removed top and bottom header Issues: 1. the new way of creating tables with db_create_table doesnt give any log output, if it fails it fails silently. 2. after upgrade user are sent to login page but cant login with admin/admin, realm problem? --- cacti.sql | 4 ++-- install/0_8_8g_to_1_0_0.php | 14 +++++++++----- install/index.php | 12 +++++------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/cacti.sql b/cacti.sql index 5fe1e41bca..7b4b87a460 100644 --- a/cacti.sql +++ b/cacti.sql @@ -3669,7 +3669,7 @@ CREATE TABLE vdef ( hash varchar(32) NOT NULL default '', name varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL default '', PRIMARY KEY (id) -) ENGINE=MyISAM; +) ENGINE=MyISAM COMMENT='vdef'; -- -- Dumping data for table `vdef` @@ -3696,7 +3696,7 @@ CREATE TABLE vdef_items ( value varchar(150) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL default '', PRIMARY KEY (id), KEY vdef_id (vdef_id) -) ENGINE=MyISAM; +) ENGINE=MyISAM COMMENT='vdef items'; -- -- Dumping data for table `vdef_items` diff --git a/install/0_8_8g_to_1_0_0.php b/install/0_8_8g_to_1_0_0.php index 02b15ed5f8..d8620f216e 100644 --- a/install/0_8_8g_to_1_0_0.php +++ b/install/0_8_8g_to_1_0_0.php @@ -1232,27 +1232,31 @@ function upgrade_to_1_0_0() { ADD COLUMN legend_direction varchar(10) DEFAULT NULL AFTER t_legend_direction'); /* create new table VDEF */ - unset($data); + $data = array(); $data['columns'][] = array('name' => 'id', 'type' => 'mediumint(8)', 'unsigned' => 'unsigned', 'NULL' => false, 'auto_increment' => true); $data['columns'][] = array('name' => 'hash', 'type' => 'varchar(32)', 'NULL' => false, 'default' => ''); $data['columns'][] = array('name' => 'name', 'type' => 'varchar(255)', 'NULL' => false, 'default' => ''); - $data['keys'][] = array('name' => 'PRIMARY', 'columns' => 'id', 'primary' => true); + $data['primary'] = 'id'; + $data['comment'] = 'vdef'; $data['type'] = 'MyISAM'; db_table_create('vdef', $data); /* create new table VDEF_ITEMS */ - unset($data); + $data = array(); $data['columns'][] = array('name' => 'id', 'type' => 'mediumint(8)', 'unsigned' => 'unsigned', 'NULL' => false, 'auto_increment' => true); $data['columns'][] = array('name' => 'hash', 'type' => 'varchar(32)', 'NULL' => false, 'default' => ''); $data['columns'][] = array('name' => 'vdef_id', 'type' => 'mediumint(8)', 'unsigned' => 'unsigned', 'NULL' => false, 'default' => 0); $data['columns'][] = array('name' => 'sequence', 'type' => 'mediumint(8)', 'unsigned' => 'unsigned', 'NULL' => false, 'default' => 0); $data['columns'][] = array('name' => 'type', 'type' => 'tinyint(2)', 'NULL' => false, 'default' => 0); $data['columns'][] = array('name' => 'value', 'type' => 'varchar(150)', 'NULL' => false, 'default' => ''); - $data['keys'][] = array('name' => 'PRIMARY', 'columns' => 'id', 'primary' => true); + $data['primary'] = 'id'; $data['keys'][] = array('name' => 'vdef_id', 'columns' => 'vdef_id'); + $data['comment'] = 'vdef items'; $data['type'] = 'MyISAM'; db_table_create('vdef_items', $data); + + /* fill table VDEF */ db_install_execute("1.0.0", "REPLACE INTO `vdef` VALUES (1, 'e06ed529238448773038601afb3cf278', 'Maximum');"); db_install_execute("1.0.0", "REPLACE INTO `vdef` VALUES (2, 'e4872dda82092393d6459c831a50dc3b', 'Minimum');"); @@ -1353,7 +1357,7 @@ function upgrade_to_1_0_0() { db_install_execute('1.0.0', "REPLACE INTO data_source_profiles_cf (data_source_profile_id, consolidation_function_id) - SELECT '$id' AS data_source_profile_id, consolidation_function_id FROM rra_cf WHERE id=" . $r); + SELECT '$id' AS data_source_profile_id, consolidation_function_id FROM rra_cf WHERE rra_id=" . $r); } db_install_execute('1.0.0', "UPDATE data_template_data diff --git a/install/index.php b/install/index.php index 7185b72d96..fe49e35f1f 100644 --- a/install/index.php +++ b/install/index.php @@ -26,9 +26,7 @@ include_once('../include/global.php'); -top_header(); -api_plugin_hook('console_before'); /* allow the upgrade script to run for as long as it needs to */ ini_set('max_execution_time', '0'); @@ -877,6 +875,11 @@ function install_file_paths () {

+ WARNING - If you are upgrading from a previous version please close all Cacti browser sessions and clear cache before continuing

'; + } + ?> +

The following information has been determined from Cacti's configuration file. If it is not correct, please edit 'include/config.php' before continuing.

@@ -1136,8 +1139,3 @@ function install_file_paths () { Date: Sat, 26 Mar 2016 02:39:32 +0400 Subject: [PATCH 3/5] Added session db to upgrade This fixed the login issue. Now upgraded database and new installed database is exactly equal, no difference. Still need to fix/test: 1. output for array sql log 2. test windows 3. cleanup, import more features, make it look better Works: Linux New install Upgrade from 0.8.8g --- cacti.sql | 11 ++++--- install/0_8_8g_to_1_0_0.php | 64 ++++++++++++++++++++++--------------- 2 files changed, 44 insertions(+), 31 deletions(-) diff --git a/cacti.sql b/cacti.sql index 7b4b87a460..535e2a62ab 100644 --- a/cacti.sql +++ b/cacti.sql @@ -295,7 +295,7 @@ CREATE TABLE `automation_networks` ( `ping_retries` int(10) unsigned DEFAULT '0', `sched_type` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Schedule type: manual or automatic', `threads` int(10) unsigned DEFAULT '1', - `run_limit` int(10) unsigned DEFAULT '0', + `run_limit` int(10) unsigned DEFAULT '0' COMMENT 'The maximum runtime for the discovery', `start_at` varchar(20) DEFAULT NULL, `next_start` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `recur_every` int(10) unsigned DEFAULT '1', @@ -393,7 +393,7 @@ CREATE TABLE `automation_templates` ( `sysOid` varchar(60) DEFAULT '', `sequence` int(10) unsigned DEFAULT '0', PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=3 COMMENT='Plugin Discovery - Templates of SysDesc matches to use to au'; +) ENGINE=MyISAM AUTO_INCREMENT=3 COMMENT='Templates of SysDescr SysName and SysOID matches to use for automation'; -- -- Dumping data for table `automation_templates` @@ -1386,7 +1386,7 @@ CREATE TABLE `data_source_profiles_cf` ( `consolidation_function_id` smallint(5) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`data_source_profile_id`,`consolidation_function_id`), KEY `data_source_profile_id` (`data_source_profile_id`) -) ENGINE=MyISAM; +) ENGINE=MyISAM COMMENT='Maps the Data Source Profile Consolidation Functions'; -- -- Dumping data for table `data_source_profiles_cf` @@ -3265,6 +3265,7 @@ CREATE TABLE user_auth ( password varchar(2048) NOT NULL default '0', realm mediumint(8) NOT NULL default '0', full_name varchar(100) default '0', + email_address varchar(128) NULL, must_change_password char(2) default NULL, password_change char(2) default 'on', show_tree char(2) default 'on', @@ -3294,8 +3295,8 @@ CREATE TABLE user_auth ( -- Dumping data for table `user_auth` -- -INSERT INTO user_auth VALUES (1,'admin','21232f297a57a5a743894a0e4a801fc3',0,'Administrator','on','on','on','on','on',1,1,1,1,1,1,'on',-1,-1,-1,'',0,0,0); -INSERT INTO user_auth VALUES (3,'guest','43e9a4ab75570f5b',0,'Guest Account','on','on','on','on','on',3,1,1,1,1,1,'',-1,-1,-1,'',0,0,0); +INSERT INTO user_auth VALUES (1,'admin','21232f297a57a5a743894a0e4a801fc3',0,'Administrator','','on','on','on','on','on',1,1,1,1,1,1,'on',-1,-1,-1,'',0,0,0); +INSERT INTO user_auth VALUES (3,'guest','43e9a4ab75570f5b',0,'Guest Account','','on','on','on','on','on',3,1,1,1,1,1,'',-1,-1,-1,'',0,0,0); -- -- Table structure for table `user_auth_cache` diff --git a/install/0_8_8g_to_1_0_0.php b/install/0_8_8g_to_1_0_0.php index d8620f216e..d5f4cbb7c1 100644 --- a/install/0_8_8g_to_1_0_0.php +++ b/install/0_8_8g_to_1_0_0.php @@ -73,7 +73,7 @@ function upgrade_to_1_0_0() { db_install_execute('1.0', "CREATE TABLE IF NOT EXISTS `settings_user_group` ( `group_id` smallint(8) unsigned NOT NULL DEFAULT '0', `name` varchar(50) NOT NULL DEFAULT '', - `value` varchar(255) NOT NULL DEFAULT '', + `value` varchar(2048) NOT NULL DEFAULT '', PRIMARY KEY (`group_id`,`name`)) ENGINE=MyISAM COMMENT='Stores the Default User Group Graph Settings';"); @@ -147,8 +147,8 @@ function upgrade_to_1_0_0() { `rrd_name` varchar(19) NOT NULL default '', `time` datetime NOT NULL default '0000-00-00 00:00:00', `output` varchar(512) NOT NULL, - PRIMARY KEY USING BTREE (`local_data_id`,`time`,`rrd_name`)) - ENGINE=MEMORY;"); + PRIMARY KEY USING BTREE (`local_data_id`,`rrd_name`,`time`)) + ENGINE=MyISAM ROW_FORMAT=FIXED"); db_install_execute('1.0', "CREATE TABLE IF NOT EXISTS `poller_output_boost_processes` ( `sock_int_value` bigint(20) unsigned NOT NULL auto_increment, @@ -351,8 +351,7 @@ function upgrade_to_1_0_0() { db_install_execute('1.0', "ALTER TABLE graph_tree_items MODIFY COLUMN id BIGINT UNSIGNED NOT NULL auto_increment, ADD COLUMN parent BIGINT UNSIGNED default NULL AFTER id, - ADD COLUMN position int UNSIGNED default NULL AFTER parent, - ADD INDEX parent (parent)"); + ADD COLUMN position int UNSIGNED default NULL AFTER parent"); db_install_execute('1.0', "CREATE TABLE IF NOT EXISTS `user_auth_cache` ( `user_id` int(10) unsigned NOT NULL DEFAULT '0', @@ -365,8 +364,8 @@ function upgrade_to_1_0_0() { // Add secpass fields db_install_add_column ('1.0', 'user_auth', array('name' => 'lastchange', 'type' => 'int(12)', 'NULL' => false, 'default' => '-1')); db_install_add_column ('1.0', 'user_auth', array('name' => 'lastlogin', 'type' => 'int(12)', 'NULL' => false, 'default' => '-1')); - db_install_add_column ('1.0', 'user_auth', array('name' => 'password_history', 'type' => 'varchar(4096)', 'NULL' => false, 'default' => '')); - db_install_add_column ('1.0', 'user_auth', array('name' => 'locked', 'type' => 'varchar(3)', 'NULL' => false, 'default' => '')); + db_install_add_column ('1.0', 'user_auth', array('name' => 'password_history', 'type' => 'INT(12)', 'NULL' => false, 'default' => '-1')); + db_install_add_column ('1.0', 'user_auth', array('name' => 'locked', 'type' => 'text', 'NULL' => false, 'default' => '')); db_install_add_column ('1.0', 'user_auth', array('name' => 'failed_attempts', 'type' => 'int(5)', 'NULL' => false, 'default' => '0')); db_install_add_column ('1.0', 'user_auth', array('name' => 'lastfail', 'type' => 'int(12)', 'NULL' => false, 'default' => '0')); @@ -464,13 +463,13 @@ function upgrade_to_1_0_0() { // Adding email column for future user db_install_add_column ('1.0', 'user_auth', array('name' => 'email_address', 'type' => 'varchar(128)', 'NULL' => true, 'after' => 'full_name')); - db_install_add_column ('1.0', 'user_auth', array('name' => 'password_change', 'type' => 'char(2)', 'NULL' => false, 'default' => 'on', 'after' => 'email_address')); + db_install_add_column ('1.0', 'user_auth', array('name' => 'password_change', 'type' => 'char(2)', 'NULL' => true, 'default' => 'on', 'after' => 'must_change_password')); db_install_execute('1.0', 'DROP TABLE IF EXISTS poller_output_realtime'); db_install_execute('1.0', "CREATE TABLE poller_output_realtime ( local_data_id mediumint(8) unsigned NOT NULL default '0', rrd_name varchar(19) NOT NULL default '', - time timestamp NOT NULL default '0000-00-00 00:00:00', + time datetime NOT NULL default '0000-00-00 00:00:00', output text NOT NULL, poller_id varchar(30) NOT NULL default '', PRIMARY KEY (local_data_id,rrd_name,`time`), @@ -1096,15 +1095,15 @@ function upgrade_to_1_0_0() { `ping_retries` int(10) unsigned DEFAULT '0', `sched_type` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Schedule type: manual or automatic', `threads` int(10) unsigned DEFAULT '1', - `run_limit` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'The maximum runtime for the discovery', + `run_limit` int(10) unsigned NULL DEFAULT '0' COMMENT 'The maximum runtime for the discovery', `start_at` varchar(20) DEFAULT NULL, `next_start` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `recur_every` int(10) unsigned DEFAULT '1', `day_of_week` varchar(45) DEFAULT NULL COMMENT 'The days of week to run in crontab format', `month` varchar(45) DEFAULT NULL COMMENT 'The months to run in crontab format', `day_of_month` varchar(45) DEFAULT NULL COMMENT 'The days of month to run in crontab format', - `hour` varchar(45) DEFAULT NULL COMMENT 'The hours to run in crontab format', - `min` varchar(45) DEFAULT NULL COMMENT 'The minutes to run in crontab format', + `monthly_week` varchar(45) DEFAULT NULL, + `monthly_day` varchar(45) DEFAULT NULL, `last_runtime` double NOT NULL DEFAULT '0' COMMENT 'The last runtime for discovery', `last_started` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'The time the discovery last started', `last_status` varchar(128) NOT NULL DEFAULT '' COMMENT 'The last exit message if any', @@ -1118,7 +1117,7 @@ function upgrade_to_1_0_0() { `pid` int(8) unsigned NOT NULL, `poller_id` int(10) unsigned DEFAULT '0', `network_id` int(10) unsigned NOT NULL DEFAULT '0', - `task` varchar(20) NOT NULL DEFAULT '', + `task` varchar(20) NULL DEFAULT '', `status` varchar(20) DEFAULT NULL, `command` varchar(20) DEFAULT NULL, `up_hosts` int(10) unsigned DEFAULT '0', @@ -1126,7 +1125,7 @@ function upgrade_to_1_0_0() { `heartbeat` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`pid`, `network_id`)) ENGINE=MEMORY - COMMENT='Table required for parallelization of data collection'"); + COMMENT='Table tracking active poller processes'"); db_install_execute('1.0', "CREATE TABLE IF NOT EXISTS `automation_snmp` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, @@ -1159,13 +1158,13 @@ function upgrade_to_1_0_0() { `id` int(8) NOT NULL AUTO_INCREMENT, `host_template` int(8) NOT NULL DEFAULT '0', `availability_method` int(10) unsigned DEFAULT '2', - `sysDescr` varchar(255) NOT NULL DEFAULT '', - `sysName` varchar(255) NOT NULL DEFAULT '', - `sysOid` varchar(60) NOT NULL DEFAULT '', + `sysDescr` varchar(255) NULL DEFAULT '', + `sysName` varchar(255) NULL DEFAULT '', + `sysOid` varchar(60) NULL DEFAULT '', `sequence` int(10) unsigned DEFAULT '0', PRIMARY KEY (`id`)) ENGINE=MyISAM - COMMENT='Templates of SysDescr SysName and SysOID matches to use to automation'"); + COMMENT='Templates of SysDescr SysName and SysOID matches to use for automation'"); db_install_execute('1.0', "DELETE FROM plugin_config WHERE directory='discovery'"); db_install_execute('1.0', "DELETE FROM plugin_realms WHERE plugin='discovery'"); @@ -1181,7 +1180,7 @@ function upgrade_to_1_0_0() { db_install_execute('1.0', 'INSERT IGNORE INTO user_auth_realm (user_id, realm_id) VALUES (1, 23)'); } - db_install_execute('1.0', "ALTER TABLE colors ADD COLUMN name varchar(40) AFTER id, ADD COLUMN read_only CHAR(2) DEFAULT '' AFTER hex, ADD UNIQUE INDEX hex(hex)"); + db_install_execute('1.0', "ALTER TABLE colors ADD COLUMN name varchar(40) DEFAULT '' AFTER id, ADD COLUMN read_only CHAR(2) DEFAULT '' AFTER hex, ADD UNIQUE INDEX hex(hex)"); if (file_exists(dirname(__FILE__) . '/import_colors.php')) { shell_exec('php -q ' . dirname(__FILE__) . '/import_colors.php'); @@ -1189,11 +1188,11 @@ function upgrade_to_1_0_0() { db_install_execute('1.0', "ALTER TABLE settings MODIFY COLUMN value varchar(2048) NOT NULL default ''"); db_install_execute('1.0', "ALTER TABLE settings_graphs MODIFY COLUMN value varchar(2048) NOT NULL default ''"); - db_install_execute('1.0', "ALTER TABLE user_auth MODIFY COLUMN password varchar(2048) NOT NULL default ''"); + db_install_execute('1.0', "ALTER TABLE user_auth MODIFY COLUMN password varchar(2048) NOT NULL default '0'"); db_install_execute('1.0', 'RENAME TABLE settings_graphs TO settings_user'); - db_install_execute('1.0', 'ALTER TABLE user_auth ADD COLUMN reset_perms INT unsigned NOT NULL default "0" AFTER lastfail'); + db_install_execute('1.0', 'ALTER TABLE user_auth ADD COLUMN reset_perms INT(12) unsigned NOT NULL default "0" AFTER lastfail'); rsa_check_keypair(); @@ -1220,8 +1219,8 @@ function upgrade_to_1_0_0() { ADD COLUMN no_gridfit char(2) DEFAULT NULL AFTER t_no_gridfit, ADD COLUMN t_unit_length char(2) DEFAULT "0" AFTER no_gridfit, ADD COLUMN unit_length varchar(10) DEFAULT NULL AFTER t_unit_length, - ADD COLUMN t_tab_width char(2) DEFAULT "0" AFTER unit_length, - ADD COLUMN tab_width varchar(10) DEFAULT NULL AFTER t_tab_width, + ADD COLUMN t_tab_width char(2) DEFAULT "30" AFTER unit_length, + ADD COLUMN tab_width varchar(20) DEFAULT NULL AFTER t_tab_width, ADD COLUMN t_dynamic_labels char(2) default "0" AFTER tab_width, ADD COLUMN dynamic_labels char(2) default NULL AFTER t_dynamic_labels, ADD COLUMN t_force_rules_legend char(2) DEFAULT "0" AFTER dynamic_labels, @@ -1231,6 +1230,18 @@ function upgrade_to_1_0_0() { ADD COLUMN t_legend_direction char(2) DEFAULT "0" AFTER legend_position, ADD COLUMN legend_direction varchar(10) DEFAULT NULL AFTER t_legend_direction'); + + /* create new table sessions */ + $data = array(); + $data['columns'][] = array('name' => 'id', 'type' => 'varchar(32)', 'NULL' => false ); + $data['columns'][] = array('name' => 'remote_addr', 'type' => 'varchar(25)', 'NULL' => false, 'default' => ''); + $data['columns'][] = array('name' => 'access', 'type' => 'INT(10)', 'unsigned' => 'unsigned', 'NULL' => true); + $data['columns'][] = array('name' => 'data', 'type' => 'text', 'NULL' => true); + $data['primary'] = 'id'; + $data['comment'] = 'Used for Database based Session Storage'; + $data['type'] = 'InnoDB'; + db_table_create('sessions', $data); + /* create new table VDEF */ $data = array(); $data['columns'][] = array('name' => 'id', 'type' => 'mediumint(8)', 'unsigned' => 'unsigned', 'NULL' => false, 'auto_increment' => true); @@ -1285,7 +1296,7 @@ function upgrade_to_1_0_0() { db_install_execute('1.0.0', "ALTER TABLE data_template_data ADD COLUMN t_data_source_profile_id CHAR(2) default '', - ADD COLUMN data_source_profile_id mediumint(8) not null default '0'"); + ADD COLUMN data_source_profile_id mediumint(8) unsigned not null default '0'"); db_install_execute('1.0.0', "CREATE TABLE `data_source_profiles` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, @@ -1298,6 +1309,7 @@ function upgrade_to_1_0_0() { PRIMARY KEY (`id`)) ENGINE=MyISAM COMMENT='Stores Data Source Profiles'"); + db_install_execute('1.0.0', "CREATE TABLE `data_source_profiles_cf` ( `data_source_profile_id` mediumint(8) unsigned NOT NULL DEFAULT '0', @@ -1399,8 +1411,8 @@ function upgrade_to_1_0_0() { ADD COLUMN no_gridfit char(2) DEFAULT NULL AFTER t_no_gridfit, ADD COLUMN t_unit_length char(2) DEFAULT "0" AFTER no_gridfit, ADD COLUMN unit_length varchar(10) DEFAULT NULL AFTER t_unit_length, - ADD COLUMN t_tab_width char(2) DEFAULT "0" AFTER unit_length, - ADD COLUMN tab_width varchar(10) DEFAULT NULL AFTER t_tab_width, + ADD COLUMN t_tab_width char(2) DEFAULT "30" AFTER unit_length, + ADD COLUMN tab_width varchar(20) DEFAULT NULL AFTER t_tab_width, ADD COLUMN t_dynamic_labels char(2) default "0" AFTER tab_width, ADD COLUMN dynamic_labels char(2) default NULL AFTER t_dynamic_labels, ADD COLUMN t_force_rules_legend char(2) DEFAULT "0" AFTER dynamic_labels, From a58bd0e21c1a32516685c0604b87fd2680e2607f Mon Sep 17 00:00:00 2001 From: Micke2k Date: Sat, 26 Mar 2016 22:47:28 +0400 Subject: [PATCH 4/5] Fixed comments Change cacti.sql datetime to timestamp, good idea? --- cacti.sql | 26 +++++++++++++------------- install/0_8_8g_to_1_0_0.php | 10 +++++----- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cacti.sql b/cacti.sql index 535e2a62ab..89bac9afab 100644 --- a/cacti.sql +++ b/cacti.sql @@ -2542,8 +2542,8 @@ CREATE TABLE host ( disabled char(2) default NULL, status tinyint(2) NOT NULL default '0', status_event_count mediumint(8) unsigned NOT NULL default '0', - status_fail_date datetime NOT NULL default '0000-00-00 00:00:00', - status_rec_date datetime NOT NULL default '0000-00-00 00:00:00', + status_fail_date timestamp NOT NULL default '0000-00-00 00:00:00', + status_rec_date timestamp NOT NULL default '0000-00-00 00:00:00', status_last_error varchar(255) default '', min_time decimal(10,5) default '9.99999', max_time decimal(10,5) default '0.00000', @@ -2772,7 +2772,7 @@ CREATE TABLE poller ( id smallint(5) unsigned NOT NULL auto_increment, hostname varchar(250) NOT NULL default '', ip_address int(11) unsigned NOT NULL default '0', - last_update datetime NOT NULL default '0000-00-00 00:00:00', + last_update timestamp NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (id) ) ENGINE=MyISAM; @@ -2782,7 +2782,7 @@ CREATE TABLE poller ( CREATE TABLE poller_command ( poller_id smallint(5) unsigned NOT NULL default '0', - time datetime NOT NULL default '0000-00-00 00:00:00', + time timestamp NOT NULL default '0000-00-00 00:00:00', action tinyint(3) unsigned NOT NULL default '0', command varchar(200) NOT NULL default '', PRIMARY KEY (poller_id,action,command) @@ -2832,7 +2832,7 @@ CREATE TABLE poller_item ( CREATE TABLE poller_output ( local_data_id mediumint(8) unsigned NOT NULL default '0', rrd_name varchar(19) NOT NULL default '', - time datetime NOT NULL default '0000-00-00 00:00:00', + time timestamp NOT NULL default '0000-00-00 00:00:00', output text NOT NULL, PRIMARY KEY (local_data_id,rrd_name,time) /*!50060 USING BTREE */ ) ENGINE=MyISAM; @@ -2844,7 +2844,7 @@ CREATE TABLE poller_output ( CREATE TABLE `poller_output_boost` ( `local_data_id` mediumint(8) unsigned NOT NULL default '0', `rrd_name` varchar(19) NOT NULL default '', - `time` datetime NOT NULL default '0000-00-00 00:00:00', + `time` timestamp NOT NULL default '0000-00-00 00:00:00', `output` varchar(512) NOT NULL, PRIMARY KEY USING BTREE (`local_data_id`,`rrd_name`,`time`) ) ENGINE=MyISAM ROW_FORMAT=FIXED; @@ -2866,7 +2866,7 @@ CREATE TABLE `poller_output_boost_processes` ( CREATE TABLE IF NOT EXISTS poller_output_realtime ( local_data_id mediumint(8) unsigned NOT NULL default '0', rrd_name varchar(19) NOT NULL default '', - `time` datetime NOT NULL default '0000-00-00 00:00:00', + `time` timestamp NOT NULL default '0000-00-00 00:00:00', output text NOT NULL, poller_id varchar(30) NOT NULL default '', PRIMARY KEY (local_data_id,rrd_name,`time`), @@ -2897,8 +2897,8 @@ CREATE TABLE poller_time ( id mediumint(8) unsigned NOT NULL auto_increment, pid int(11) unsigned NOT NULL default '0', poller_id smallint(5) unsigned NOT NULL default '0', - start_time datetime NOT NULL default '0000-00-00 00:00:00', - end_time datetime NOT NULL default '0000-00-00 00:00:00', + start_time timestamp NOT NULL default '0000-00-00 00:00:00', + end_time timestamp NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (id) ) ENGINE=MyISAM; @@ -3262,7 +3262,7 @@ INSERT INTO snmp_query_graph_sv VALUES (49,'183bb486c92a566fddcb0585ede37865',22 CREATE TABLE user_auth ( id mediumint(8) unsigned NOT NULL auto_increment, username varchar(50) NOT NULL default '0', - password varchar(2048) NOT NULL default '0', + password varchar(2048) NOT NULL default '', realm mediumint(8) NOT NULL default '0', full_name varchar(100) default '0', email_address varchar(128) NULL, @@ -3280,8 +3280,8 @@ CREATE TABLE user_auth ( enabled char(2) NOT NULL DEFAULT 'on', lastchange int(12) NOT NULL DEFAULT '-1', lastlogin int(12) NOT NULL DEFAULT '-1', - password_history int(12) NOT NULL DEFAULT '-1', - locked text NOT NULL, + password_history varchar(4096) NOT NULL DEFAULT '-1', + locked varchar(3) NOT NULL DEFAULT '', failed_attempts int(5) NOT NULL DEFAULT '0', lastfail int(12) NOT NULL DEFAULT '0', reset_perms int(12) UNSIGNED NOT NULL DEFAULT '0', @@ -3448,7 +3448,7 @@ INSERT INTO user_auth_realm VALUES (101,1); CREATE TABLE user_log ( username varchar(50) NOT NULL default '0', user_id mediumint(8) NOT NULL default '0', - time datetime NOT NULL default '0000-00-00 00:00:00', + time timestamp NOT NULL default '0000-00-00 00:00:00', result tinyint(1) NOT NULL default '0', ip varchar(40) NOT NULL default '', PRIMARY KEY (username,user_id,time), diff --git a/install/0_8_8g_to_1_0_0.php b/install/0_8_8g_to_1_0_0.php index d5f4cbb7c1..673b5bbab9 100644 --- a/install/0_8_8g_to_1_0_0.php +++ b/install/0_8_8g_to_1_0_0.php @@ -145,7 +145,7 @@ function upgrade_to_1_0_0() { db_install_execute('1.0', "CREATE TABLE IF NOT EXISTS `poller_output_boost` ( `local_data_id` mediumint(8) unsigned NOT NULL default '0', `rrd_name` varchar(19) NOT NULL default '', - `time` datetime NOT NULL default '0000-00-00 00:00:00', + `time` timestamp NOT NULL default '0000-00-00 00:00:00', `output` varchar(512) NOT NULL, PRIMARY KEY USING BTREE (`local_data_id`,`rrd_name`,`time`)) ENGINE=MyISAM ROW_FORMAT=FIXED"); @@ -364,8 +364,8 @@ function upgrade_to_1_0_0() { // Add secpass fields db_install_add_column ('1.0', 'user_auth', array('name' => 'lastchange', 'type' => 'int(12)', 'NULL' => false, 'default' => '-1')); db_install_add_column ('1.0', 'user_auth', array('name' => 'lastlogin', 'type' => 'int(12)', 'NULL' => false, 'default' => '-1')); - db_install_add_column ('1.0', 'user_auth', array('name' => 'password_history', 'type' => 'INT(12)', 'NULL' => false, 'default' => '-1')); - db_install_add_column ('1.0', 'user_auth', array('name' => 'locked', 'type' => 'text', 'NULL' => false, 'default' => '')); + db_install_add_column ('1.0', 'user_auth', array('name' => 'password_history', 'type' => 'varchar(4096)', 'NULL' => false, 'default' => '-1')); + db_install_add_column ('1.0', 'user_auth', array('name' => 'locked', 'type' => 'varchar(3)', 'NULL' => false, 'default' => '')); db_install_add_column ('1.0', 'user_auth', array('name' => 'failed_attempts', 'type' => 'int(5)', 'NULL' => false, 'default' => '0')); db_install_add_column ('1.0', 'user_auth', array('name' => 'lastfail', 'type' => 'int(12)', 'NULL' => false, 'default' => '0')); @@ -469,7 +469,7 @@ function upgrade_to_1_0_0() { db_install_execute('1.0', "CREATE TABLE poller_output_realtime ( local_data_id mediumint(8) unsigned NOT NULL default '0', rrd_name varchar(19) NOT NULL default '', - time datetime NOT NULL default '0000-00-00 00:00:00', + time timestamp NOT NULL default '0000-00-00 00:00:00', output text NOT NULL, poller_id varchar(30) NOT NULL default '', PRIMARY KEY (local_data_id,rrd_name,`time`), @@ -1188,7 +1188,7 @@ function upgrade_to_1_0_0() { db_install_execute('1.0', "ALTER TABLE settings MODIFY COLUMN value varchar(2048) NOT NULL default ''"); db_install_execute('1.0', "ALTER TABLE settings_graphs MODIFY COLUMN value varchar(2048) NOT NULL default ''"); - db_install_execute('1.0', "ALTER TABLE user_auth MODIFY COLUMN password varchar(2048) NOT NULL default '0'"); + db_install_execute('1.0', "ALTER TABLE user_auth MODIFY COLUMN password varchar(2048) NOT NULL default ''"); db_install_execute('1.0', 'RENAME TABLE settings_graphs TO settings_user'); From 5f2a415b2d223bc560df32239fd90addfe4dd55a Mon Sep 17 00:00:00 2001 From: Micke2k Date: Sun, 27 Mar 2016 23:09:54 +0400 Subject: [PATCH 5/5] Changed all table to use timestamp Added back index parent. Although i don't think it should be used since it is not in cacti.sql, see attached screenshot. cacti2 is the upgraded, and cacti is new installation. --- install/0_8_8g_to_1_0_0.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/install/0_8_8g_to_1_0_0.php b/install/0_8_8g_to_1_0_0.php index 673b5bbab9..b7b53e98cd 100644 --- a/install/0_8_8g_to_1_0_0.php +++ b/install/0_8_8g_to_1_0_0.php @@ -351,7 +351,9 @@ function upgrade_to_1_0_0() { db_install_execute('1.0', "ALTER TABLE graph_tree_items MODIFY COLUMN id BIGINT UNSIGNED NOT NULL auto_increment, ADD COLUMN parent BIGINT UNSIGNED default NULL AFTER id, - ADD COLUMN position int UNSIGNED default NULL AFTER parent"); + ADD COLUMN position int UNSIGNED default NULL AFTER parent, + ADD INDEX parent (parent)"); + db_install_execute('1.0', "CREATE TABLE IF NOT EXISTS `user_auth_cache` ( `user_id` int(10) unsigned NOT NULL DEFAULT '0', @@ -361,6 +363,27 @@ function upgrade_to_1_0_0() { ENGINE=MyISAM COMMENT='Caches Remember Me Details'"); + db_install_execute('1.0', "ALTER TABLE host + MODIFY COLUMN status_fail_date timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + MODIFY COLUMN status_rec_date timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'"); + + db_install_execute('1.0', "ALTER TABLE poller + MODIFY COLUMN last_update timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'"); + + db_install_execute('1.0', "ALTER TABLE poller_command + MODIFY COLUMN time timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'"); + + db_install_execute('1.0', "ALTER TABLE poller_output + MODIFY COLUMN time timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'"); + + db_install_execute('1.0', "ALTER TABLE poller_time + MODIFY COLUMN start_time timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + MODIFY COLUMN end_time timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'"); + + db_install_execute('1.0', "ALTER TABLE user_log + MODIFY COLUMN time timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'"); + + // Add secpass fields db_install_add_column ('1.0', 'user_auth', array('name' => 'lastchange', 'type' => 'int(12)', 'NULL' => false, 'default' => '-1')); db_install_add_column ('1.0', 'user_auth', array('name' => 'lastlogin', 'type' => 'int(12)', 'NULL' => false, 'default' => '-1'));