. ************************************************************************ */ /** * * install.php, TSM Monitor * * install php file * * @author Frank Fegert * @package tsmmonitor */ include_once "includes/global.php"; $_SESSION["stylesheet"] = "style_classic.css"; if ($_REQUEST["step"] != "80" || $_REQUEST["refresh"] != "") { include_once "includes/page_head.php"; } // Allow the upgrade script to run for as long as it needs to ini_set("max_execution_time", "0"); // Some variables and HTML snippets $input_err = ""; $page_foot = " "; $error_head = "

Error

"; // Check if the necessary PHP functions are enabled $funcs = array("popen"); $func_ena = true; foreach ($funcs as $func) { if (!function_exists($func)){ $func_ena = false; $func_miss .= "
  • $func
  • \n"; } } if (!$func_ena) { echo $error_head; echo "

    The following PHP functions are missing:

    Please enable those PHP functions in your php.ini and retry the installation process.

    "; echo $page_foot; exit; } // Check if the necessary PHP extensions are loaded $exts = array("session", "sockets"); $ext_load = true; foreach ($exts as $ext) { if (!extension_loaded($ext)){ $ext_load = false; $ext_miss .= "
  • $ext
  • \n"; } } if (!$ext_load) { echo $error_head; echo "

    The following PHP extensions are missing:

    Please install those PHP extensions and retry the installation process.

    "; echo $page_foot; exit; } // Try to find current (old) version in the array $tsm_monitor_versions = array("0.1.0", "0.1.1"); $old_tsm_monitor_version = $adodb->fetchCellDB("SELECT confval FROM cfg_config WHERE confkey='version'", ''); $old_version_index = array_search($old_tsm_monitor_version, $tsm_monitor_versions); // Do a version check if ($old_tsm_monitor_version == $config["tsm_monitor_version"]) { echo $error_head; echo "

    This installation is already up-to-date. Click here to use TSM Monitor.

    "; echo $page_foot; exit; } else if (empty($old_tsm_monitor_version)) { echo $error_head; echo "

    You have created a new database, but have not yet imported the 'tsmmonitor.sql' file. At the command line, execute the following to continue:

    mysql -u $db_user -p $db_password < tsmmonitor.sql

    This error may also be generated if the TSM Monitor database user does not have correct permissions on the TSM Monitor database.
    Please ensure that the TSM Monitor database user has the ability to SELECT, INSERT, DELETE, UPDATE, CREATE, ALTER, DROP, INDEX on the TSM Monitor database.

    "; echo $page_foot; exit; } // Default for the install type if (!isset($_REQUEST["install_type"])) { $_REQUEST["install_type"] = 0; } // Defaults for the install type dropdown if ($old_tsm_monitor_version == "new_install") { $default_install_type = "10"; } else { $default_install_type = "20"; } // Pre-processing that needs to be done for each step // Intro and license page if (empty($_REQUEST["step"])) { // Unset config data remaining from potential previous calls unset($_SESSION["install"]); $_REQUEST["step"] = 10; } else { // Install or update chooser page if ($_REQUEST["step"] == "10") { $_REQUEST["step"] = "20"; } // Initial admin user password page elseif ($_REQUEST["step"] == "20") { if ($_REQUEST["install_type"] == "10") { $_REQUEST["step"] = "30"; } elseif ($_REQUEST["install_type"] == "20") { $_REQUEST["step"] = "60"; } } // Binary and logfile path page elseif ($_REQUEST["step"] == "30") { // Check if passwords are not empty and match if ($_POST["adminpw"] == "" || $_POST["adminpwr"] == "") { $input_err = "Empty passwords are not allowed."; $_REQUEST["step"] = "30"; } else if ($_POST["adminpw"] != $_POST["adminpwr"]) { $input_err = "Passwords do not match."; $_REQUEST["step"] = "30"; } else { $_REQUEST["step"] = "40"; $_SESSION["install"]["adminpw"] = md5($_POST["adminpw"]); // dsmadmc binary path $_SESSION["install"]["paths"]["path_dsmadmc"]["name"] = "dsmadmc Binary Path"; $_SESSION["install"]["paths"]["path_dsmadmc"]["desc"] = "The path to the TSM admin client binary."; $which_dsmadmc = $tsmmonitor->findPath("dsmadmc", $config["search_path"]); if (isset($tsmmonitor->configarray["settings"]["paths"]["path_dsmadmc"])) { $_SESSION["install"]["paths"]["path_dsmadmc"]["default"] = $tsmmonitor->configarray["settings"]["path_dsmadmc"]; } else if (!empty($which_dsmadmc)) { $_SESSION["install"]["paths"]["path_dsmadmc"]["default"] = $which_dsmadmc; } else { $_SESSION["install"]["paths"]["path_dsmadmc"]["default"] = "dsmadmc"; } // php/php5 binary path $_SESSION["install"]["paths"]["path_php"]["name"] = "PHP Binary Path"; $_SESSION["install"]["paths"]["path_php"]["desc"] = "The path to the PHP binary."; $which_php = $tsmmonitor->findPath("php", $config["search_path"]); if(!isset($which_php)) { $which_php = $tsmmonitor->findPath("php5", $config["search_path"]); } if (isset($tsmmonitor->configarray["settings"]["paths"]["path_php"])) { $_SESSION["install"]["paths"]["path_php"]["default"] = $tsmmonitor->configarray["settings"]["path_php"]; } else if (!empty($which_php)) { $_SESSION["install"]["paths"]["path_php"]["default"] = $which_php; } else { $_SESSION["install"]["paths"]["path_php"]["default"] = "php"; } // Logfile path $_SESSION["install"]["paths"]["path_tmlog"]["name"] = "TSM Monitor Logfile Path"; $_SESSION["install"]["paths"]["path_tmlog"]["desc"] = "The path to the TSM Monitor log file."; if (isset($tsmmonitor->configarray["settings"]["paths"]["path_tmlog"])) { $_SESSION["install"]["paths"]["path_tmlog"]["default"] = $tsmmonitor->configarray["settings"]["path_tmlog"]; } else { $_SESSION["install"]["paths"]["path_tmlog"]["default"] = $config["base_path"] . "tsmmonitor.log"; } // PollD logfile path $_SESSION["install"]["paths"]["path_polldlog"]["name"] = "PollD Logfile Path"; $_SESSION["install"]["paths"]["path_polldlog"]["desc"] = "The path to the PollD log file."; if (isset($tsmmonitor->configarray["settings"]["paths"]["path_polldlog"])) { $_SESSION["install"]["paths"]["path_polldlog"]["default"] = $tsmmonitor->configarray["settings"]["path_polldlog"]; } else { $_SESSION["install"]["paths"]["path_polldlog"]["default"] = $config["base_path"] . "tsmmonitor.log"; } } } // Refresh of binary and logfile path page or server definition page elseif ($_REQUEST["step"] == "40") { if ($_POST["refresh"] == "Refresh") { $_REQUEST["step"] = "40"; } else { // Get server entries already in db $sql = "SELECT * FROM cfg_servers"; $srvres = $adodb->fetchArrayDB($sql); $_REQUEST["step"] = "50"; } foreach ($_SESSION["install"]["paths"] as $name => $array) { if (isset($_POST[$name])) { $_SESSION["install"]["paths"][$name]["default"] = $_POST[$name]; } } } // Refresh/add on server definition page or finish page elseif ($_REQUEST["step"] == "50") { // Get server entries already in db $sql = "SELECT * FROM cfg_servers"; $srvres = $adodb->fetchArrayDB($sql); if ($_POST["addsrv"] == "Add") { $_REQUEST["step"] = "50"; // Get (possibly) updated values from the forms if (isset($_POST)) { $tmp_err = ""; foreach ($_POST as $key => $val) { if (ereg("^srv_.*", $key)) { if (($key == "srv_description") || ($val != "")) { if ($key == "srv_servername") { $server[$key] = strtoupper($val); } else { $server[$key] = $val; } } else { $tmp_key = ereg_replace("^srv_(.*)", "\\1", $key); $tmp_err .= " ".(($tmp_key == "ip" ) ? strtoupper($tmp_key) : ucfirst($tmp_key)); } } } if ($tmp_err != "") { $input_err = "Missing parameter: ".$tmp_err; } } $sql = "SELECT * FROM cfg_servers WHERE servername='".$server['srv_servername']."'"; $srvadd = $adodb->fetchArrayDB($sql); if (isset($srvadd[0])) { $input_err = "Server already configured in database."; } if ($input_err == "") { $dsmadmc = $_SESSION["install"]["paths"]["path_dsmadmc"]["default"]; if (file_exists($dsmadmc) && is_executable($dsmadmc)) { $popen_flags = ($os == "win32") ? 'rb' : 'r'; $oh = popen($dsmadmc." -se=".$server['srv_servername']." -id=".$server['srv_username']." -password=".$server['srv_password']." -TCPServeraddress=".$server['srv_ip']." -COMMMethod=TCPIP -TCPPort=".$server['srv_port']." -dataonly=yes -TAB \"SELECT SERVER_HLA,SERVER_LLA FROM status\" ", "$popen_flags"); if ($oh != 0) { while (!feof($oh)) { $read = fgets($oh, 4096); if (ereg("^ANS.*", $read)) { $input_err .= "$read "; } } } else { $input_err = "Cannot open connection to the TSM server. Check the servername,
    username, password and the server entries in dsm.sys or dsm.opt."; } pclose($oh); } else { $input_err = "$dsmadmc not found or not executeable."; } if ($input_err == "") { $_SESSION["install"]["servers"][$server['srv_servername']] = $server; } } } elseif (!isset($_SESSION['install']['servers']) && !isset($srvres[0])) { $_REQUEST["step"] = "50"; } else { $_REQUEST["step"] = "80"; } } // Update page elseif ($_REQUEST["step"] == "60") { $_REQUEST["step"] = "80"; } // Refresh on php limits page or finish and flush data to db elseif ($_REQUEST["step"] == "80") { if ($_POST["refresh"] == "Refresh") { $_REQUEST["step"] = "80"; } else { $_REQUEST["step"] = "90"; } } } if ($_REQUEST["step"] == "90") { // Flush updated data to DB foreach ($_SESSION["install"]["paths"] as $name => $array) { $adodb->updateDB('cfg_config', array(confkey => "$name", confval => $array["default"], description => $array["name"]), 'confkey'); } if (isset($_SESSION["install"]["servers"])) { foreach ($_SESSION["install"]["servers"] as $name => $array) { $sqlcols = array(); $sqlvals = array(); foreach ($array as $col => $val) { $tmp_col = ereg_replace("^srv_(.*)", "\\1", $col); $tmp_col = "`".$tmp_col."`"; $tmp_val = "'".$val."'"; array_push($sqlcols, $tmp_col); array_push($sqlvals, $tmp_val); } $sql = "INSERT INTO cfg_servers (".(implode(",", $sqlcols)).") VALUES (".(implode(",", $sqlvals)).")"; $adodb->execDB($sql); } } $adodb->updateDB('cfg_users', array(username => 'admin', password => $_SESSION["install"]["adminpw"]), 'username'); // set new version, disable installer and redirect to login page $adodb->updateDB('cfg_config', array(confkey => 'version', confval => $config['tsm_monitor_version']), 'confkey'); $adodb->closeDB(); $_SESSION["stylesheet"] = ""; header("Location: index.php"); exit; } elseif (($_REQUEST["step"] == "60") && ($_REQUEST["install_type"] == "20")) { // If the version is not found, die if (!is_int($old_version_index)) { echo $error_head; echo "

    Invalid TSM Monitor version $old_tsm_monitor_version, cannot upgrade to ".$config["tsm_monitor_version"]."

    "; echo $page_foot; exit; } // Loop over all versions up to the current and perform incremental updates for ($i = ($old_version_index+1); $i < count($tsm_monitor_versions); $i++) { if ($tsm_monitor_versions[$i] == "0.0.1") { include "install/0_0_1_to_0_0_2.php"; upgrade_to_0_0_2(); } /* elseif ($tsm_monitor_versions[$i] == "0.0.2") { include "install/0_0_2_to_0_0_3.php"; upgrade_to_0_0_3(); } elseif ($tsm_monitor_versions[$i] == "0.0.3") { include "install/0_0_3_to_0_0_4.php"; upgrade_to_0_0_4(); } */ } } ?> TSM Monitor Installer
     

    Thank you for taking the time to download and install TSM Monitor.

    TSM Monitor is a web application written in PHP to help TSM administrators to quickly get reports and health status information of their TSM servers. It generates it's content dynamically so one can easily add or modify queries to adapt the application to one's own needs. Before you can start using TSM Monitor, there are a few configuration steps that need to be done.

    Make sure you have read and followed the required steps needed to install TSM Monitor before continuing. Install information can be found here http://www.tsm-monitor.org/wiki/doku.php

    TSM Monitor is licensed under the GNU General Public License, you must agree to its provisions before continuing:

    TSM Monitor is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

    TSM Monitor is distributed in the hope that it will be useful, 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.

    You should have received a copy of the GNU General Public License along with TSM Monitor. If not, see http://www.gnu.org/licenses/.

    Please select the type of installation

    The default administrative TSM Monitor user 'admin' needs a initial password. Please choose a password according to your password policies and enter it below. The default 'admin' user has full rights to the TSM Monitor application, which is why we recommend using a non-trivial and secure password. Additional users with less privileges can be created from within TSM Monitor after this install process is finished.

    ERROR: $input_err"; } ?>

    Password
    Password (repeat)

    Please check if the following values have been correctly determined for your system and correct if necessary.

    $array) { if (isset($_SESSION["install"]["paths"][$name])) { $file = $array["default"]; $resStr = ""; $capStr = ""; if (file_exists($file) && is_file($file)) { $resStr = "[FOUND] "; $capStr = "
    [OK: FILE FOUND]
    "; } else { $resStr = "[NOT FOUND] "; $capStr = "
    [ERROR: FILE NOT FOUND]
    "; } echo "

    " . $resStr . $array["name"]; if (!empty($array["name"])) { echo ": " . $array["desc"]; } else { echo $array["desc"] . ""; } echo "
    " . $capStr . "

    "; } } ?>

    Defined TSM servers in database:

    fetchArrayDB($sql); $th = ""; foreach ($srvresth as $col) { if ($col['Field'] != "id") { if ($col['Field'] == "ip") { if ((isset($srvres)) && (count($srvres) != 0)) $th .= ""; } else { if ((isset($srvres)) && (count($srvres) != 0)) $th .= ""; } $fields[$col['Field']]['type'] = ereg_replace("([a-z]+)\(.*", "\\1", $col['Type']); $fields[$col['Field']]['len'] = ereg_replace("[a-z]+\(([0-9]+)\)", "\\1", $col['Type']); } } $th .= ""; echo "$th"; if ((isset($srvres)) && (count($srvres) != 0)) { foreach ($srvres as $row) { echo ""; foreach ($row as $key => $val) { if ($key != "id") { if (($key == "libraryclient") || ($key == "default")) { if ($val == 0 ) { echo ""; } else { echo ""; } } else { echo ""; } } } echo ""; } } else { echo ""; } ?>
    ".strtoupper($col['Field'])."".ucfirst($col['Field'])."
    NoYes".$val."
    No TSM server configured in database.

    Defined TSM servers in the installer session cache:

    "; foreach ($row as $key => $val) { if ($key != "id") { if (($key == "srv_libraryclient") || ($key == "srv_default")) { if ($val == 0 ) { echo ""; } else { echo ""; } } else { echo ""; } } } echo ""; } } else { echo ""; } ?>
    NoYes".$val."
    No TSM server configured in session cache.


    Please define at least one TSM server to be monitored:

    ERROR: $input_err"; } ?>

    "; if ($col['Field'] == "ip") { echo ""; } else { echo ""; } if ($input_err != "") { $value = $_POST["srv_".$col['Field']]; } if ($col['Field'] == "password") { echo ""; } elseif (($col['Field'] == "libraryclient") || ($col['Field'] == "default")) { echo ""; } else { echo ""; } echo ""; } } ?>
    ".strtoupper($col['Field'])."".ucfirst($col['Field'])."

    Sorry, this is the initial TSM Monitor version, there are currently no updates from previous versions available. Please choose "New install" on the previous page.

    Default or configured PHP limits

    PHP memory_limit settings: "; if ($mem_cli_val < $mem_cli_recommend) { $mem_color = "#FF0000"; $mem_text = "Warning: at least"; } else { $mem_color = "#008000"; $mem_text = "OK:"; } echo " "; ?>
    Webserver: $mem_val $mem_unit [$mem_text $mem_recommend M recommended]
    Command line: $mem_cli_val $mem_cli_unit [$mem_text $mem_cli_recommend M recommended]

    NOTE: Depending on the volume of data gathered from your TSM servers by TSM Monitor, the PHP memory_limit settings shown above may not be sufficient. Please edit your php.ini configuration files to at least match the recommended values shown above and restart your webserver. This has to be done manually and is not part of the TSM Monitor configuration!

    NOTE: Once you click "Finish", the previous settings will be saved "as-is" to the TSM Monitor database. No further validation will be performed, so please make sure the above settings are correct! Any of the above settings can later on be changed with the TSM Monitor admin web interface.
    If you did choose to upgrade from a previous version of TSM Monitor, the database will also be upgraded by clicking "Finish".

     

    ">