From bf13a5080047c7796870db94b16867ad9b7263d1 Mon Sep 17 00:00:00 2001 From: David Hill Date: Thu, 20 Sep 2018 09:37:07 -0500 Subject: [PATCH] MCOL-520 - remove sudo work and cleanup --- build/nightly-mini-tester.sh | 2 - cpackEngineDEB.cmake | 6 +- dbcon/mysql/mysql-Calpont | 480 - oam/install_scripts/calpontAlias | 13 - oam/install_scripts/calpontInstall.sh | 167 - oam/install_scripts/calpontLogRotate | 35 - oam/install_scripts/calpontSyslog | 6 - oam/install_scripts/calpontSyslog-ng | 67 - oam/install_scripts/calpontSyslog7 | 7 - oam/install_scripts/calpontUninstall.sh | 118 - oam/install_scripts/configReport.sh | 82 - oam/install_scripts/infinidb | 178 - oam/install_scripts/infinidb.conf | 2 - oam/install_scripts/infinidb.def | 9 - oam/install_scripts/infinidb.upstart | 16 - oam/install_scripts/softwareReport.sh | 48 - oam/install_scripts/syslogSetup.sh | 2 +- oamapps/calpont-console/calpont-console.vpj | 228 - oamapps/calpont-console/calpontConsole.vpj | 224 - oamapps/calpontConsole/CMakeLists.txt | 48 - oamapps/calpontConsole/calpontConsole.cpp | 9389 ----------------- oamapps/calpontConsole/calpontConsole.h | 135 - oamapps/calpontConsole/tdriver.cpp | 380 - oamapps/calpontDB/CMakeLists.txt | 49 - oamapps/calpontDB/calpontDB.cpp | 162 - oamapps/calpontDB/calpontDBWrite.vpj | 216 - oamapps/calpontSupport/CMakeLists.txt | 57 - oamapps/calpontSupport/alarmReport.sh | 36 - oamapps/calpontSupport/analytics/create.sql | 26 - oamapps/calpontSupport/analytics/track.sh | 37 - oamapps/calpontSupport/approximateRowCount.sh | 62 - oamapps/calpontSupport/bulklogReport.sh | 38 - oamapps/calpontSupport/calpontSupport.bat | 227 - oamapps/calpontSupport/calpontSupport.cpp | 1102 -- oamapps/calpontSupport/configReport.sh | 64 - oamapps/calpontSupport/findStranded.sh | 40 - oamapps/calpontSupport/getMinMax.sh | 132 - oamapps/calpontSupport/hadoopReport.sh | 69 - oamapps/calpontSupport/hardwareReport.sh | 101 - oamapps/calpontSupport/logReport.sh | 27 - oamapps/calpontSupport/minMaxCheck.sh | 170 - oamapps/calpontSupport/resourceReport.sh | 74 - oamapps/calpontSupport/sqlLogs.sh | 225 - oamapps/columnstoreSupport/bulklogReport.sh | 9 +- oamapps/columnstoreSupport/calpontSupport.cpp | 1102 -- oamapps/columnstoreSupport/configReport.sh | 27 +- oamapps/columnstoreSupport/hadoopReport.sh | 17 +- oamapps/columnstoreSupport/hardwareReport.sh | 31 +- oamapps/columnstoreSupport/logReport.sh | 9 +- oamapps/columnstoreSupport/resourceReport.sh | 13 +- oamapps/columnstoreSupport/softwareReport.sh | 9 +- oamapps/postConfigure/installer.cpp | 2 +- .../clusterTester/columnstoreClusterTester.sh | 10 +- utils/udfsdk/README.txt | 4 +- 54 files changed, 38 insertions(+), 15751 deletions(-) delete mode 100755 dbcon/mysql/mysql-Calpont delete mode 100644 oam/install_scripts/calpontAlias delete mode 100755 oam/install_scripts/calpontInstall.sh delete mode 100644 oam/install_scripts/calpontLogRotate delete mode 100644 oam/install_scripts/calpontSyslog delete mode 100755 oam/install_scripts/calpontSyslog-ng delete mode 100644 oam/install_scripts/calpontSyslog7 delete mode 100755 oam/install_scripts/calpontUninstall.sh delete mode 100755 oam/install_scripts/configReport.sh delete mode 100644 oam/install_scripts/infinidb delete mode 100644 oam/install_scripts/infinidb.conf delete mode 100644 oam/install_scripts/infinidb.def delete mode 100644 oam/install_scripts/infinidb.upstart delete mode 100755 oam/install_scripts/softwareReport.sh delete mode 100644 oamapps/calpont-console/calpont-console.vpj delete mode 100644 oamapps/calpont-console/calpontConsole.vpj delete mode 100644 oamapps/calpontConsole/CMakeLists.txt delete mode 100644 oamapps/calpontConsole/calpontConsole.cpp delete mode 100644 oamapps/calpontConsole/calpontConsole.h delete mode 100644 oamapps/calpontConsole/tdriver.cpp delete mode 100644 oamapps/calpontDB/CMakeLists.txt delete mode 100644 oamapps/calpontDB/calpontDB.cpp delete mode 100644 oamapps/calpontDB/calpontDBWrite.vpj delete mode 100644 oamapps/calpontSupport/CMakeLists.txt delete mode 100755 oamapps/calpontSupport/alarmReport.sh delete mode 100644 oamapps/calpontSupport/analytics/create.sql delete mode 100755 oamapps/calpontSupport/analytics/track.sh delete mode 100755 oamapps/calpontSupport/approximateRowCount.sh delete mode 100755 oamapps/calpontSupport/bulklogReport.sh delete mode 100644 oamapps/calpontSupport/calpontSupport.bat delete mode 100644 oamapps/calpontSupport/calpontSupport.cpp delete mode 100755 oamapps/calpontSupport/configReport.sh delete mode 100755 oamapps/calpontSupport/findStranded.sh delete mode 100755 oamapps/calpontSupport/getMinMax.sh delete mode 100755 oamapps/calpontSupport/hadoopReport.sh delete mode 100755 oamapps/calpontSupport/hardwareReport.sh delete mode 100755 oamapps/calpontSupport/logReport.sh delete mode 100755 oamapps/calpontSupport/minMaxCheck.sh delete mode 100755 oamapps/calpontSupport/resourceReport.sh delete mode 100755 oamapps/calpontSupport/sqlLogs.sh delete mode 100644 oamapps/columnstoreSupport/calpontSupport.cpp diff --git a/build/nightly-mini-tester.sh b/build/nightly-mini-tester.sh index a9ae28d29..3eae93c6f 100755 --- a/build/nightly-mini-tester.sh +++ b/build/nightly-mini-tester.sh @@ -1,7 +1,5 @@ #!/bin/bash -NO_NONROOT_SUDO=yes -export NO_NONROOT_SUDO prefix=/usr/local builddir= for arg in "$@"; do diff --git a/cpackEngineDEB.cmake b/cpackEngineDEB.cmake index 5f8a83c42..83987af4a 100644 --- a/cpackEngineDEB.cmake +++ b/cpackEngineDEB.cmake @@ -65,11 +65,11 @@ if (EXISTS "/etc/debian_version") set(DEBIAN_VERSION_NUMBER "${CMAKE_MATCH_1}") endif () if ("${DEBIAN_VERSION_NUMBER}" EQUAL "8") - SET(CPACK_DEBIAN_PLATFORM_PACKAGE_DEPENDS "expect, perl, openssl, file, sudo, libdbi-perl, libreadline-dev, rsync, net-tools, libboost-all-dev, mariadb-columnstore-libs, mariadb-columnstore-server, libsnappy1") + SET(CPACK_DEBIAN_PLATFORM_PACKAGE_DEPENDS "expect, perl, openssl, file, libdbi-perl, libreadline-dev, rsync, net-tools, libboost-all-dev, mariadb-columnstore-libs, mariadb-columnstore-server, libsnappy1") elseif ("${DEBIAN_VERSION_NUMBER}" EQUAL "9") - SET(CPACK_DEBIAN_PLATFORM_PACKAGE_DEPENDS "expect, perl, openssl, file, sudo, libdbi-perl, libreadline-dev, rsync, net-tools, libboost-all-dev, mariadb-columnstore-libs, mariadb-columnstore-server, libsnappy1v5, libreadline5") + SET(CPACK_DEBIAN_PLATFORM_PACKAGE_DEPENDS "expect, perl, openssl, file, libdbi-perl, libreadline-dev, rsync, net-tools, libboost-all-dev, mariadb-columnstore-libs, mariadb-columnstore-server, libsnappy1v5, libreadline5") else() - SET(CPACK_DEBIAN_PLATFORM_PACKAGE_DEPENDS "expect, perl, openssl, file, sudo, libdbi-perl, libboost-all-dev, libreadline-dev, rsync, libsnappy1v5, net-tools") + SET(CPACK_DEBIAN_PLATFORM_PACKAGE_DEPENDS "expect, perl, openssl, file, libdbi-perl, libboost-all-dev, libreadline-dev, rsync, libsnappy1v5, net-tools") endif () SET(CPACK_DEBIAN_STORAGE-ENGINE_PACKAGE_DEPENDS "mariadb-columnstore-libs") diff --git a/dbcon/mysql/mysql-Calpont b/dbcon/mysql/mysql-Calpont deleted file mode 100755 index e32fb4a08..000000000 --- a/dbcon/mysql/mysql-Calpont +++ /dev/null @@ -1,480 +0,0 @@ -#!/bin/sh -# Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -# This file is public domain and comes with NO WARRANTY of any kind - -# MySQL daemon start/stop script. - -# Usually this is put in /etc/init.d (at least on machines SYSV R4 based -# systems) and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/K01mysql. -# When this is done the mysql server will be started when the machine is -# started and shut down when the systems goes down. - -# Comments to support chkconfig on RedHat Linux -# chkconfig: 2345 64 36 -# description: A very fast and reliable SQL database engine. - -# Comments to support LSB init script conventions -### BEGIN INIT INFO -# Provides: mysql -# Required-Start: $local_fs $network $remote_fs -# Should-Start: ypbind nscd ldap ntpd xntpd -# Required-Stop: $local_fs $network $remote_fs -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: start and stop MySQL -# Description: MySQL is a very fast and reliable SQL database engine. -### END INIT INFO - -# If you install MySQL on some other places than /usr/local/Calpont/mysql, then you -# have to do one of the following things for this script to work: -# -# - Run this script from within the MySQL installation directory -# - Create a /etc/my.cnf file with the following information: -# [mysqld] -# basedir= -# - Add the above to any other configuration file (for example ~/.my.ini) -# and copy my_print_defaults to /usr/bin -# - Add the path to the mysql-installation-directory to the basedir variable -# below. -# -# If you want to affect other MySQL variables, you should make your changes -# in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files. - -# If you change base dir, you must also change datadir. These may get -# overwritten by settings in the MySQL configuration files. - -basedir=/usr/local/Calpont/mysql -datadir=/usr/local/Calpont/mysql/db - -# Default value, in seconds, afterwhich the script should timeout waiting -# for server start. -# Value here is overriden by value in my.cnf. -# 0 means don't wait at all -# Negative numbers mean to wait indefinitely -service_startup_timeout=30 - -# Lock directory for RedHat / SuSE. -lockdir='/var/lock/subsys' -lock_file_path="$lockdir/mysql-Columnstore" - -# The following variables are only set for letting mysql.server find things. - -# Set some defaults -mysqld_pid_file_path= -if test -z "$basedir" -then - basedir=/usr/local/Calpont/mysql - bindir=/usr/local/bin - if test -z "$datadir" - then - datadir=/var/lib/mysql - fi - sbindir=/usr/local/sbin - libexecdir=/usr/local/sbin -else - bindir="$basedir/bin" - if test -z "$datadir" - then - datadir="$basedir/data" - fi - sbindir="$basedir/sbin" - if test -f "$basedir/sbin/mysqld" - then - libexecdir="$basedir/sbin" - else - libexecdir="$basedir/libexec" - fi -fi - -# datadir_set is used to determine if datadir was set (and so should be -# *not* set inside of the --basedir= handler.) -datadir_set= - -# -# Use LSB init script functions for printing messages, if possible -# -lsb_functions="/lib/lsb/init-functions" -if test -f $lsb_functions ; then - . $lsb_functions -else - # Include non-LSB RedHat init functions to make systemctl redirect work - init_functions="/etc/init.d/functions" - if test -f $init_functions; then - . $init_functions - fi - log_success_msg() - { - echo " SUCCESS! $@" - } - log_failure_msg() - { - echo " ERROR! $@" - } -fi - -PATH="/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin" -export PATH - -mode=$1 # start or stop - -[ $# -ge 1 ] && shift - -case `echo "testing\c"`,`echo -n testing` in - *c*,-n*) echo_n= echo_c= ;; - *c*,*) echo_n=-n echo_c= ;; - *) echo_n= echo_c='\c' ;; -esac - -parse_server_arguments() { - for arg do - case "$arg" in - --basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` - bindir="$basedir/bin" - if test -z "$datadir_set"; then - datadir="$basedir/data" - fi - sbindir="$basedir/sbin" - if test -f "$basedir/sbin/mysqld" - then - libexecdir="$basedir/sbin" - else - libexecdir="$basedir/libexec" - fi - #libexecdir="$basedir/libexec" - ;; - --datadir=*) datadir=`echo "$arg" | sed -e 's/^[^=]*=//'` - datadir_set=1 - ;; - --log-basename=*|--hostname=*|--loose-log-basename=*) - mysqld_pid_file_path=`echo "$arg.pid" | sed -e 's/^[^=]*=//'` - ;; - --pid-file=*) mysqld_pid_file_path=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; - --service-startup-timeout=*) service_startup_timeout=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; - esac - done -} - -# Get arguments from the my.cnf file, -# the only group, which is read from now on is [mysqld] -if test -x ./bin/my_print_defaults -then - print_defaults="./bin/my_print_defaults" -elif test -x $bindir/my_print_defaults -then - print_defaults="$bindir/my_print_defaults" -elif test -x $bindir/mysql_print_defaults -then - print_defaults="$bindir/mysql_print_defaults" -else - # Try to find basedir in /etc/my.cnf - conf=/etc/my.cnf - print_defaults= - if test -r $conf - then - subpat='^[^=]*basedir[^=]*=\(.*\)$' - dirs=`sed -e "/$subpat/!d" -e 's//\1/' $conf` - for d in $dirs - do - d=`echo $d | sed -e 's/[ ]//g'` - if test -x "$d/bin/my_print_defaults" - then - print_defaults="$d/bin/my_print_defaults" - break - fi - if test -x "$d/bin/mysql_print_defaults" - then - print_defaults="$d/bin/mysql_print_defaults" - break - fi - done - fi - - # Hope it's in the PATH ... but I doubt it - test -z "$print_defaults" && print_defaults="my_print_defaults" -fi - -# -# Read defaults file from 'basedir'. If there is no defaults file there -# check if it's in the old (depricated) place (datadir) and read it from there -# - -extra_args="" -if test -r "$basedir/my.cnf" -then - extra_args="-e $basedir/my.cnf" -else - if test -r "$datadir/my.cnf" - then - extra_args="-e $datadir/my.cnf" - fi -fi - -parse_server_arguments `$print_defaults $extra_args --mysqld mysql.server` -parse_server_arguments "$@" - -# wait for the pid file to disappear -wait_for_gone () { - pid="$1" # process ID of the program operating on the pid-file - pid_file_path="$2" # path to the PID file. - - i=0 - crash_protection="by checking again" - - while test $i -ne $service_startup_timeout ; do - - if kill -0 "$pid" 2>/dev/null; then - : # the server still runs - else - if test ! -s "$pid_file_path"; then - # no server process and no pid-file? great, we're done! - log_success_msg - return 0 - fi - - # pid-file exists, the server process doesn't. - # it must've crashed, and mysqld_safe will restart it - if test -n "$crash_protection"; then - crash_protection="" - sleep 5 - continue # Check again. - fi - - kill_by_pid - # Cannot help it - log_failure_msg "The server quit without updating PID file ($pid_file_path)." - return 1 # not waiting any more. - fi - - echo $echo_n ".$echo_c" - i=`expr $i + 1` - sleep 1 - - done - - log_failure_msg - return 1 -} - -wait_for_ready () { - - i=0 - while test $i -ne $service_startup_timeout ; do - - if $bindir/mysqladmin ping --socket=/usr/local/Calpont/mysql/lib/mysql/mysql.sock >/dev/null 2>&1; then - log_success_msg - return 0 - elif kill -0 $! 2>/dev/null ; then - : # mysqld_safe is still running - else - # mysqld_safe is no longer running, abort the wait loop - break - fi - - echo $echo_n ".$echo_c" - i=`expr $i + 1` - sleep 1 - - done - - log_failure_msg - return 1 -} -# -# Set pid file if not given -# -if test -z "$mysqld_pid_file_path" -then - mysqld_pid_file_path=$datadir/`hostname`.pid -else - case "$mysqld_pid_file_path" in - /* ) ;; - * ) mysqld_pid_file_path="$datadir/$mysqld_pid_file_path" ;; - esac -fi - -# source other config files -[ -f /etc/default/mysql ] && . /etc/default/mysql -[ -f /etc/sysconfig/mysql ] && . /etc/sysconfig/mysql -[ -f /etc/conf.d/mysql ] && . /etc/conf.d/mysql - -kill_by_pid() { - # let's see if we can kill the 2 mysql procs by hand - # get the our mysql from ps - eval $(ps -ef | grep "$COLUMNSTORE_INSTALL_DIR/mysql//sbin/mysqld" | grep -v grep | head -1 | awk '{printf "pid=%d\n", $2}') - - if [ -n "$pid" ]; then - ppid=$(ps -o ppid= -p $pid) - $SUDO kill -9 $ppid - kill -9 $ppid - sleep 1 - $SUDO kill -9 $pid - kill -9 $pid - echo $echo_n "Force shutting down (no/bad pid file)" - log_success_msg - exit 0 - fi - return -} - -case "$mode" in - 'start') - # Start daemon - - # Safeguard (relative paths, core dumps..) - cd $basedir - - echo $echo_n "Starting MySQL" - if test -x $bindir/mysqld_safe - then - # Give extra arguments to mysqld with the my.cnf file. This script - # may be overwritten at next upgrade. - $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" "--ledir=$libexecdir" "$@" >/dev/null 2>&1 & - wait_for_ready; return_value=$? - - # Make lock for RedHat / SuSE - if test -w "$lockdir" - then - touch "$lock_file_path" - fi - - exit $return_value - else - log_failure_msg "Couldn't find MySQL server ($bindir/mysqld_safe)" - fi - ;; - - 'stop') - # Stop daemon. We use a signal here to avoid having to know the - # root password. - - if test -s "$mysqld_pid_file_path" - then - mysqld_pid=`cat "$mysqld_pid_file_path"` - - if (kill -0 $mysqld_pid 2>/dev/null) - then - echo $echo_n "Shutting down MySQL" - kill $mysqld_pid - # mysqld should remove the pid file when it exits, so wait for it. - wait_for_gone $mysqld_pid "$mysqld_pid_file_path"; return_value=$? - else - log_failure_msg "MySQL server process #$mysqld_pid is not running!" - rm "$mysqld_pid_file_path" - fi - - # Delete lock for RedHat / SuSE - if test -f "$lock_file_path" - then - rm -f "$lock_file_path" - fi - exit $return_value - else - kill_by_pid - log_failure_msg "MySQL server PID file could not be found!" - fi - ;; - - 'restart') - # Stop the service and regardless of whether it was - # running or not, start it again. - if $0 stop "$@"; then - if ! $0 start "$@"; then - log_failure_msg "Failed to restart server." - exit 1 - fi - else - log_failure_msg "Failed to stop running server, so refusing to try to start." - exit 1 - fi - ;; - - 'reload'|'force-reload') - if test -s "$mysqld_pid_file_path" ; then - read mysqld_pid < "$mysqld_pid_file_path" - kill -HUP $mysqld_pid && log_success_msg "Reloading service MySQL" - touch "$mysqld_pid_file_path" - else - log_failure_msg "MySQL PID file could not be found!" - exit 1 - fi - ;; - 'status') - # First, check to see if pid file exists - if test -s "$mysqld_pid_file_path" ; then - read mysqld_pid < "$mysqld_pid_file_path" - if kill -0 $mysqld_pid 2>/dev/null ; then - log_success_msg "MySQL running ($mysqld_pid)" - exit 0 - else - log_failure_msg "MySQL is not running, but PID file exists" - exit 1 - fi - else - # Try to find appropriate mysqld process - mysqld_pid=`pidof $libexecdir/mysqld` - - # test if multiple pids exist - pid_count=`echo $mysqld_pid | wc -w` - if test $pid_count -gt 1 ; then - log_failure_msg "Multiple MySQL running but PID file could not be found ($mysqld_pid)" - exit 5 - elif test -z $mysqld_pid ; then - if test -f "$lock_file_path" ; then - log_failure_msg "MySQL is not running, but lock file ($lock_file_path) exists" - exit 2 - fi - log_failure_msg "MySQL is not running" - exit 3 - else - log_failure_msg "MySQL is running but PID file could not be found" - exit 4 - fi - fi - ;; - 'configtest') - # Safeguard (relative paths, core dumps..) - cd $basedir - echo $echo_n "Testing MySQL configuration syntax" - daemon=$bindir/mysqld - if test -x $libexecdir/mysqld - then - daemon=$libexecdir/mysqld - elif test -x $sbindir/mysqld - then - daemon=$sbindir/mysqld - elif test -x `which mysqld` - then - daemon=`which mysqld` - else - log_failure_msg "Unable to locate the mysqld binary!" - exit 1 - fi - help_out=`$daemon --help 2>&1`; r=$? - if test "$r" != 0 ; then - log_failure_msg "$help_out" - log_failure_msg "There are syntax errors in the server configuration. Please fix them!" - else - log_success_msg "Syntax OK" - fi - exit $r - ;; - 'bootstrap') - if test "$_use_systemctl" == 1 ; then - log_failure_msg "Please use galera_new_cluster to start the mariadb service with --wsrep-new-cluster" - exit 1 - fi - # Bootstrap the cluster, start the first node - # that initiate the cluster - echo $echo_n "Bootstrapping the cluster.. " - $0 start $other_args --wsrep-new-cluster - exit $? - ;; - *) - # usage - basename=`basename "$0"` - echo "Usage: $basename {start|stop|restart|reload|force-reload|status|configtest|bootstrap} [ MySQL server options ]" - exit 1 - ;; -esac - -exit 0 diff --git a/oam/install_scripts/calpontAlias b/oam/install_scripts/calpontAlias deleted file mode 100644 index ffc4a4756..000000000 --- a/oam/install_scripts/calpontAlias +++ /dev/null @@ -1,13 +0,0 @@ -# InfiniDB Alias Commands -# -alias mcsmysql='/usr/local/Calpont/mysql/bin/mysql --defaults-file=/usr/local/Calpont/mysql/my.cnf -u root' -alias ma=/usr/local/Calpont/bin/mcsadmin -alias mcsadmin=/usr/local/Calpont/bin/mcsadmin -alias home='cd /usr/local/mariadb/columnstore' -alias log='cd /var/log/mariadb/columnstore/' -alias core='cd /var/log/mariadb/columnstore/corefiles' -alias tmsg='tail -f /var/log/messages' -alias tdebug='tail -f /var/log/mariadb/columnstore/debug.log' -alias tinfo='tail -f /var/log/mariadb/columnstore/info.log' -alias dbrm='cd /usr/local/Calpont/data1/systemFiles/dbrm' -alias module='cat /usr/local/Calpont/local/module' diff --git a/oam/install_scripts/calpontInstall.sh b/oam/install_scripts/calpontInstall.sh deleted file mode 100755 index 0933b9009..000000000 --- a/oam/install_scripts/calpontInstall.sh +++ /dev/null @@ -1,167 +0,0 @@ -#!/usr/bin/expect -# -# $Id$ -# -# Install Package on system - -set timeout 30 -set USERNAME "root" -set RPMVERSION " " -set PASSWORD " " -set MYSQLPASSWORD dummymysqlpw -set PACKAGE " " -set CONFIGFILE " " -set DEBUG 0 -set NODEPS "-h" -set INSTALLDIR "/usr/local/mariadb/columnstore" - -spawn -noecho /bin/bash - -for {set i 0} {$i<[llength $argv]} {incr i} { - set arg($i) [lindex $argv $i] -} - -set i 0 -while true { - if { $i == [llength $argv] } { break } - if { $arg($i) == "-h" } { - send_user "\n" - send_user "'calpontInstaller.sh' performs a system install of the Calpont InfiniDB Packages\n" - send_user "from the /root/ directory. These Packages would have already been installed\n" - send_user "on the local Module.\n" - send_user "Usage: calpontInstaller.sh -v 'infinidb-version' -p 'password' -t 'package-type' -c 'config-file'-m 'mysql-password' -d\n" - send_user " infinidb-version - InfiniDB Version, i.e. 1.0.0-1\n" - send_user " password - root password on the servers being installed'\n" - send_user " package-type - Package Type being installed (rpm, deb, or binary)\n" - send_user " config-file - Optional: Columnstore.xml config file with directory location, i.e. /root/Columnstore.xml\n" - send_user " Default version is $INSTALLDIR/etc/Columnstore.xml.rpmsave\n" - send_user " mysql-password - MySQL password on the servers being installed'\n" - send_user " -d - Debug flag, output verbose information\n" - exit 0 - } elseif { $arg($i) == "-v" } { - incr i - set RPMVERSION $arg($i) - } elseif { $arg($i) == "-p" } { - incr i - set PASSWORD $arg($i) - } elseif { $arg($i) == "-t" } { - incr i - set PACKAGE $arg($i) - } elseif { $arg($i) == "-c" } { - incr i - set CONFIGFILE $arg($i) - } elseif { $arg($i) == "-d" } { - set DEBUG 1 - } elseif { $arg($i) == "-f" } { - set NODEPS "--nodeps" - } elseif { $arg($i) == "-m" } { - incr i - set MYSQLPASSWORD $arg($i) - } elseif { $arg($i) == "-i" } { - incr i - set INSTALLDIR $arg($i) - } elseif { $arg($i) == "-u" } { - incr i - set USERNAME $arg($i) - } - incr i -} - -log_user $DEBUG - -set timeout 2 -send "$INSTALLDIR/bin/infinidb status\n" -expect { - "is running" { puts "InfiniDB is running, can't run calpontInstall.sh while InfiniDB is running. Exiting..\n"; - exit 1 - } -} - -if { $CONFIGFILE == " " } { - set CONFIGFILE $INSTALLDIR/etc/Columnstore.xml.rpmsave -} - -if { [catch { open $CONFIGFILE "r"} handle ] } { - puts "Calpont Config file not found: $CONFIGFILE"; exit 1 -} - -exec rm -f $INSTALLDIR/etc/Columnstore.xml.new > /dev/null 2>&1 -exec mv -f $INSTALLDIR/etc/Columnstore.xml $INSTALLDIR/etc/Columnstore.xml.new > /dev/null 2>&1 -exec /bin/cp -f $CONFIGFILE $INSTALLDIR/etc/Columnstore.xml > /dev/null 2>&1 - -set timeout 2 -set INSTALL 2 -send "$INSTALLDIR/bin/getConfig DBRM_Controller NumWorkers\n" -expect { - 1 { set INSTALL 1 - set PASSWORD "dummy" - set RPMVERSION "rpm" } -} - - -if { $INSTALL == "2" && $PASSWORD == " "} {puts "please enter the remote server root password, enter ./calpontInstaller.sh -h for additional info"; exit 1} - -if { $INSTALL == "2" && $RPMVERSION == " " } {puts "please enter Package version, enter ./calpontInstaller.sh -h for additional info"; exit 1} - -send_user "\n" - -if { $INSTALL == "2" } { - if { $PACKAGE == "rpm" } { - set CALPONTPACKAGE1 /root/infinidb-libs-$RPMVERSION*.rpm - set CALPONTPACKAGE2 /root/infinidb-platform-$RPMVERSION*.rpm - set CALPONTPACKAGE3 /root/infinidb-enterprise-$RPMVERSION*.rpm - set CONNECTORPACKAGE1 /root/infinidb-mysql-$RPMVERSION*.rpm - set CONNECTORPACKAGE2 /root/infinidb-storage-engine-$RPMVERSION*.rpm - send_user "Installing InfiniDB Packages: $CALPONTPACKAGE1, $CALPONTPACKAGE2, $CALPONTPACKAGE3, $CONNECTORPACKAGE1, $CONNECTORPACKAGE2\n\n" - set EEPKG "rpm" - } elseif { $PACKAGE == "deb" } { - set CALPONTPACKAGE1 /root/infinidb-libs_$RPMVERSION*.deb - set CALPONTPACKAGE2 /root/infinidb-platform_$RPMVERSION*.deb - set CALPONTPACKAGE3 /root/infinidb-enterprise_$RPMVERSION*.deb - set CONNECTORPACKAGE1 /root/infinidb-mysql_$RPMVERSION*.deb - set CONNECTORPACKAGE2 /root/infinidb-storage-engine_$RPMVERSION*.deb - send_user "Installing InfiniDB Packages: $CALPONTPACKAGE1, $CALPONTPACKAGE2, $CALPONTPACKAGE3, $CONNECTORPACKAGE1, $CONNECTORPACKAGE2\n\n" - set EEPKG "deb" - } elseif { $PACKAGE == "binary" } { - set CALPONTPACKAGE /root/infinidb-ent-$RPMVERSION*bin.tar.gz - set CONNECTORPACKAGE1 "nopkg" - set CONNECTORPACKAGE2 "nopkg" - send_user "Installing InfiniDB Package: $CALPONTPACKAGE\n\n" - set EEPKG "binary" - } else { - puts "please enter Valid Package Type, enter ./calpontInstaller.sh -h for additional info"; exit 1 - } -} else { - set CALPONTPACKAGE1 "dummy.rpm" - set CALPONTPACKAGE2 "dummy.rpm" - set CALPONTPACKAGE3 "dummy.rpm" - set CONNECTORPACKAGE1 "dummy.rpm" - set CONNECTORPACKAGE2 "dummy.rpm" - set EEPKG "rpm" -} - -send_user "Performing InfiniDB System Install, please wait...\n" - -send "$INSTALLDIR/bin/setConfig -d Installation EEPackageType $EEPKG\n" -expect { - -re {[$#] } { } -} - -send_user "\n" -set timeout 600 -# -# Run installer -# -send "$INSTALLDIR/bin/installer $CALPONTPACKAGE1 $CALPONTPACKAGE2 $CALPONTPACKAGE3 $CONNECTORPACKAGE1 $CONNECTORPACKAGE2 initial $PASSWORD n $NODEPS $MYSQLPASSWORD $DEBUG\n" -expect { - "InfiniDB Install Successfully Completed" { } - "ERROR" { send_user "FAILED: error returned from installer, execute with debug mode on to determine error\n" ; exit 1 } - "Enter MySQL password" { send_user "FAILED: a MySQL password is set\n" ; exit 1 } - timeout { send_user "FAILED: Timeout while running installer, execute with debug mode on to determine error\n" ; exit 1 } -} - -send_user "\nCalpont Package System Install Completed\n\n" - -exit 0 -# vim:ts=4 sw=4: - diff --git a/oam/install_scripts/calpontLogRotate b/oam/install_scripts/calpontLogRotate deleted file mode 100644 index 39f51f770..000000000 --- a/oam/install_scripts/calpontLogRotate +++ /dev/null @@ -1,35 +0,0 @@ -# -# Calpont Log Rotate file that gets installed in /etc/logrotate.d -# as part of the RPM installation -# - -/var/log/mariadb/columnstore/*.log { - missingok - rotate 7 - daily - dateext - copytruncate - olddir /var/log/mariadb/columnstore/archive -} -/var/log/mariadb/columnstore/*.log1 { - missingok - rotate 7 - daily - nocreate - compress - olddir /var/log/mariadb/columnstore/archive -} -/usr/local/Calpont/etc/Columnstore.xml { - daily - dateext - copy - olddir /usr/local/Calpont/etc/ -} -/usr/local/Calpont/mysql/db/*.err { - missingok - rotate 7 - daily - dateext - copytruncate - olddir /usr/local/Calpont/mysql/db -} diff --git a/oam/install_scripts/calpontSyslog b/oam/install_scripts/calpontSyslog deleted file mode 100644 index 2b66e256a..000000000 --- a/oam/install_scripts/calpontSyslog +++ /dev/null @@ -1,6 +0,0 @@ -# Calpont Database Platform Logging -local1.=crit -/var/log/mariadb/columnstore/crit.log -local1.=err -/var/log/mariadb/columnstore/err.log -local1.=warning -/var/log/mariadb/columnstore/warning.log -local1.=info -/var/log/mariadb/columnstore/info.log -local1.=debug -/var/log/mariadb/columnstore/debug.log diff --git a/oam/install_scripts/calpontSyslog-ng b/oam/install_scripts/calpontSyslog-ng deleted file mode 100755 index beb9575af..000000000 --- a/oam/install_scripts/calpontSyslog-ng +++ /dev/null @@ -1,67 +0,0 @@ -# MariaDB Columnstore Database Platform Logging - -source s_columnstore { - # message generated by Syslog-NG - internal(); - # standard Linux log source (this is the default place for the syslog() - # function to send logs to) - unix-stream("/dev/log"); - # messages from the kernel - file("/proc/kmsg" log_prefix("kernel: ")); - # use the following line if you want to receive remote UDP logging messages - # (this is equivalent to the "-r" syslogd flag) - # udp(); -}; - -filter f_local1crit { facility(local1) and level(crit); }; -filter f_local1err { facility(local1) and level(err); }; -filter f_local1warning { facility(local1) and level(warning); }; -filter f_local1info { facility(local1) and level(info); }; -filter f_local1debug { facility(local1) and level(debug); }; - -destination d_crit{ - file("/var/log/mariadb/columnstore/crit.log"); -}; - -destination d_err{ - file("/var/log/mariadb/columnstore/err.log"); -}; - -destination d_warning{ - file("/var/log/mariadb/columnstore/warning.log"); -}; - -destination d_info{ - file("/var/log/mariadb/columnstore/info.log"); -}; - -destination d_debug{ - file("/var/log/mariadb/columnstore/debug.log"); -}; - -log{ - source(s_columnstore); - filter(f_local1crit); - destination(d_crit); -}; - -log{ - source(s_columnstore); - filter(f_local1err); - destination(d_err); -}; -log{ - source(s_columnstore); - filter(f_local1warning); - destination(d_warning); -}; -log{ - source(s_columnstore); - filter(f_local1info); - destination(d_info); -}; -log{ - source(s_columnstore); - filter(f_local1debug); - destination(d_debug); -}; diff --git a/oam/install_scripts/calpontSyslog7 b/oam/install_scripts/calpontSyslog7 deleted file mode 100644 index 0ed37f975..000000000 --- a/oam/install_scripts/calpontSyslog7 +++ /dev/null @@ -1,7 +0,0 @@ -# MariaDB Columnstore Database Platform Logging -local1.crit -/var/log/mariadb/columnstore/crit.log -local1.err -/var/log/mariadb/columnstore/err.log -local1.warning -/var/log/mariadb/columnstore/warning.log -local1.info -/var/log/mariadb/columnstore/info.log -local1.debug -/var/log/mariadb/columnstore/debug.log - diff --git a/oam/install_scripts/calpontUninstall.sh b/oam/install_scripts/calpontUninstall.sh deleted file mode 100755 index baee01463..000000000 --- a/oam/install_scripts/calpontUninstall.sh +++ /dev/null @@ -1,118 +0,0 @@ -#!/usr/bin/expect -# -# $Id$ -# -# Uninstall Package from system - -set COLUMNSTORE_INSTALL_DIR "/usr/local/mariadb/columnstore" -set env(COLUMNSTORE_INSTALL_DIR) $COLUMNSTORE_INSTALL_DIR - -set USERNAME $env(USER) -set PASSWORD " " -set DEBUG 0 - -set INFINIDBRPM1 "infinidb-libs" -set INFINIDBRPM2 "infinidb-platform" -set INFINIDBRPM3 "infinidb-enterprise" -set CONNECTORRPM1 "infinidb-mysql" -set CONNECTORRPM2 "infinidb-storage-engine" - -spawn -noecho /bin/bash - -for {set i 0} {$i<[llength $argv]} {incr i} { - set arg($i) [lindex $argv $i] -} - -set i 0 -while true { - if { $i == [llength $argv] } { break } - if { $arg($i) == "-h" } { - send_user "\n" - send_user "'calpontUninstall.sh' performs a system uninstall of the Calpont InfiniDB Packages.\n" - send_user "It will perform a shutdown of the InfiniDB software and the \n" - send_user "remove the Packages from all configured servers of the InfiniDB System.\n" - send_user "\n" - send_user "Usage: calpontUninstall.sh -p 'password' -d\n" - send_user " password - root password of the remote servers being un-installed'\n" - send_user " -d - Debug flag, output verbose information\n" - exit - } elseif { $arg($i) == "-p" } { - incr i - set PASSWORD $arg($i) - } elseif { $arg($i) == "-d" } { - set DEBUG 1 - } elseif { $arg($i) == "-i" } { - incr i - set INSTALLDIR $arg($i) - } elseif { $arg($i) == "-u" } { - incr i - set USERNAME $arg($i) - } - incr i -} - -log_user $DEBUG - -set timeout 2 -set INSTALL 2 -send "$COLUMNSTORE_INSTALL_DIR/bin/getConfig DBRM_Controller NumWorkers\n" -expect { - 1 { set INSTALL 1 } -} - -set PACKAGE "rpm" -send "$COLUMNSTORE_INSTALL_DIR/bin/getConfig Installation EEPackageType\n" -expect { - rpm { set PACKAGE rpm } - deb { set PACKAGE deb } - binary { set PACKAGE binary } -} - -set timeout 60 -log_user $DEBUG -if { $INSTALL == "2" && $PASSWORD == " "} {puts "please enter the remote server root password, enter ./calpontUninstall.sh -h for additional info"; exit -1} - -send_user "\nPerforming InfiniDB System Uninstall\n\n" - -# -# shutdownSystem -# -send_user "Shutdown InfiniDB System " -expect -re {[$#] } -send "$COLUMNSTORE_INSTALL_DIR/bin/mcsadmin shutdownsystem y\n" -expect { - "shutdownSystem " { send_user "DONE" } -} -send_user "\n" - - -if { $INSTALL == "2"} { - set timeout 600 - # - # Run installer - # - send_user "Run System Uninstaller " - send "$COLUMNSTORE_INSTALL_DIR/bin/installer $INFINIDBRPM1 $INFINIDBRPM2 $INFINIDBRPM3 $CONNECTORRPM1 $CONNECTORRPM2 uninstall $PASSWORD n --nodeps dummymysqlpw $DEBUG\n" - expect { - "uninstall request successful" { send_user "DONE" } - "ERROR" { send_user "FAILED" ; exit -1 } - } - send_user "\n" -} - -if { $PACKAGE == "binary" } { - send "$COLUMNSTORE_INSTALL_DIR/bin/pre-uninstall\n" - expect { - -re {[$#] } { } - } - - send_user "\n" - - send_user "\nCalpont Package System Uninstall Completed\n\n" - - exit 0 -} - -send_user "\nCalpont Package System Uninstall Completed\n\n" - -exit 0 diff --git a/oam/install_scripts/configReport.sh b/oam/install_scripts/configReport.sh deleted file mode 100755 index 975ea4797..000000000 --- a/oam/install_scripts/configReport.sh +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/bash -# -# $Id: hardwareReport.sh 421 2007-04-05 15:46:55Z dhill $ -# -if [ $1 ] ; then - MODULE=$1 -else - MODULE="pm1" -fi - -if [ $2 ] ; then - INSTALLDIR=$2 -else - INSTALLDIR="/usr/local/mariadb/columnstore" -fi - -USER=`whoami 2>/dev/null` - -if [ $USER = "root" ]; then - SUDO=" " -else - SUDO="sudo" -fi - -$SUDO rm -f /tmp/${MODULE}_configReport.txt - -{ -echo " " -echo "******************** Configuration/Status Report for ${MODULE} ********************" -echo " " - -systemctl=`which systemctl 2>/dev/null` -if [ -n "$systemctl" ]; then - echo "-- systemctl configuration --" - echo " " - echo "################# systemctl list-unit-files --type=service | grep columnstore #################" - echo " " - $SUDO systemctl list-unit-files --type=service | grep columnstore 2>/dev/null -else - chkconfig=`which chkconfig 2>/dev/null` - if [ -n "$chkconfig" ]; then - echo "-- chkconfig configuration --" - echo " " - echo "################# chkconfig --list | grep columnstore #################" - echo " " - $SUDO chkconfig --list | grep columnstore 2>/dev/null - else - updaterc=`which update-rc.d 2>/dev/null` - if [ -n "$updaterc" ]; then - echo "-- services configuration --" - echo " " - echo "################# service --status-all | grep columnstore #################" - echo " " - $SUDO service --status-all | grep columnstore 2>/dev/null - fi - fi -fi - -echo " " -echo "-- fstab Configuration --" -echo " " -echo "################# cat /etc/fstab #################" -echo " " -$SUDO cat /etc/fstab 2>/dev/null - -echo " " -echo "-- Server Processes --" -echo " " -echo "################# ps axu #################" -echo " " -$SUDO ps axu - -echo " " -echo "-- Server Processes with resource usage --" -echo " " -echo "################# top -b -n 1 #################" -echo " " -$SUDO top -b -n 1 - -} > /tmp/${MODULE}_configReport.txt - -exit 0 diff --git a/oam/install_scripts/infinidb b/oam/install_scripts/infinidb deleted file mode 100644 index fb1f952e3..000000000 --- a/oam/install_scripts/infinidb +++ /dev/null @@ -1,178 +0,0 @@ -#!/bin/bash -# -# $Id: infinidb 3704 2013-08-07 03:33:20Z bwilkinson $ -# -# infinidb Starts Calpont InfiniDB database platform -# -# -# chkconfig: 2345 99 99 -# description: Calpont InfiniDB is a database platform that utilizes Mysql -# -### BEGIN INIT INFO -# Provides: infinidb -# Required-Start: $local_fs $remote_fs $network $syslog $all -# Required-Stop: $local_fs $remote_fs $network $syslog -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Start/stop InfiniDB DW DBMS -### END INIT INFO - -# Source function library. -if [ -f /etc/init.d/functions ]; then - . /etc/init.d/functions -fi - -if [ -z "$COLUMNSTORE_INSTALL_DIR" ]; then - test -f /etc/default/infinidb && . /etc/default/infinidb -fi - -if [ -z "$COLUMNSTORE_INSTALL_DIR" ]; then - COLUMNSTORE_INSTALL_DIR=/usr/local/Calpont -fi - -export COLUMNSTORE_INSTALL_DIR=$COLUMNSTORE_INSTALL_DIR - -InstallDir=$COLUMNSTORE_INSTALL_DIR - -if [ $InstallDir != "/usr/local/Calpont" ]; then - export PATH=$InstallDir/bin:$InstallDir/mysql/bin:/bin:/usr/bin - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$InstallDir/lib:$InstallDir/mysql/lib/mysql -fi - -#hadoop -plugin=`$COLUMNSTORE_INSTALL_DIR/bin/getConfig SystemConfig DataFilePlugin` -if [ -n "$plugin" ]; then - setenv=`$InstallDir/bin/getConfig SystemConfig DataFileEnvFile` - . $InstallDir/bin/$setenv >/dev/null 2>&1 -fi - -test -f $InstallDir/post/functions && . $InstallDir/post/functions - -mt=`module_type` -mid=`module_id` - -has_um=`$InstallDir/bin/getConfig SystemModuleConfig ModuleCount2` -if [ "x$has_um" = x ]; then - has_um=0 -fi - -user=$USER -if [ -z "$user" ]; then - user=root -fi - -checkInstallSetup() { - InitialInstallFlag=`$InstallDir/bin/getConfig -c $InstallDir/etc/Columnstore.xml Installation InitialInstallFlag` - if [ $InitialInstallFlag != "y" ]; then - echo "Please run the postConfigure install script, check the Installation Guide" - echo "for additional details" - rm -f /var/lock/subsys/infinidb - exit 1 - fi -} - -[ -f $InstallDir/bin/ProcMon ] || exit 0 - -start() { - if [ -f /var/lock/subsys/infinidb ]; then - echo "InfiniDB Database Platform already running" - exit 0 - fi - - (mkdir -p /var/lock/subsys && touch /var/lock/subsys/infinidb) >/dev/null 2>&1 - - if [ -x $InstallDir/bin/infinidb.pre-start ]; then - $InstallDir/bin/infinidb.pre-start - if [ $? -ne 0 ]; then - echo "Error running InfiniDB pre-start script, not starting InfiniDB" - rm -f /var/lock/subsys/infinidb - exit 1 - fi - fi - checkInstallSetup - - CoreFileFlag=`$InstallDir/bin/getConfig -c $InstallDir/etc/Columnstore.xml Installation CoreFileFlag` - if [ $CoreFileFlag = "y" ]; then - SUDO= - if [ "$user" != "root" ]; then - SUDO="sudo" - fi - - #infinidb core files - $SUDO ulimit -c unlimited > /dev/null 2>&1 - $SUDO sysctl -q -w kernel.core_uses_pid=1 > /dev/null 2>&1 - $SUDO sysctl -q -w kernel.core_pattern=/var/log/mariadb/columnstore/corefiles/core.%e.%p > /dev/null 2>&1 - fi - - RETVAL=0 - echo "Starting InfiniDB Database Platform" - rm -f /tmp/StopCalpont - exec $InstallDir/bin/run.sh $InstallDir/bin/ProcMon > /dev/null 2>&1 & - - return $RETVAL -} -stop() { - echo "Shutting down InfiniDB Database Platform" - touch /tmp/StopCalpont - pkill -9 ProcMon - pkill -9 ProcMgr - pkill -9 snmptrapd - sleep 1 - $InstallDir/bin/clearShm - RETVAL=$? - rm -f /var/lock/subsys/infinidb - fuser -k 8604/tcp > /dev/null 2>&1 - test -f $InstallDir/mysql/mysql-Columnstore || return $RETVAL - $InstallDir/mysql/mysql-Columnstore stop > /dev/null 2>&1 - if [ -x $InstallDir/bin/infinidb.post-stop ]; then - $InstallDir/bin/infinidb.post-stop - fi - return $RETVAL -} -restart() { - stop - start -} -status() { - isrunning=0 - if [ $EUID -eq 0 ]; then - if [ -f /var/lock/subsys/infinidb ]; then - isrunning=1 - fi - else - pgrep ProcMon >/dev/null 2>&1 - if [ $? -eq 0 ]; then - isrunning=1 - fi - fi - if [ $isrunning -ne 0 ]; then - echo "InfiniDB is running" - else - echo "InfiniDB is not running" - exit 3 - fi -} - -case "$1" in -start) - start - ;; -stop) - stop - ;; -restart) - restart - ;; -condrestart) - [ -f /var/lock/subsys/infinidb ] && restart || : - ;; -status) - status - ;; -*) - echo $"Usage: $0 {start|stop|restart|condrestart|status}" - exit 1 -esac - -exit $? - diff --git a/oam/install_scripts/infinidb.conf b/oam/install_scripts/infinidb.conf deleted file mode 100644 index abb2e8fd4..000000000 --- a/oam/install_scripts/infinidb.conf +++ /dev/null @@ -1,2 +0,0 @@ -/usr/local/Calpont/lib - diff --git a/oam/install_scripts/infinidb.def b/oam/install_scripts/infinidb.def deleted file mode 100644 index 675522a0d..000000000 --- a/oam/install_scripts/infinidb.def +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -# Copy this file to /etc/default and rename it to 'infinidb'. - -# Change this line to your InfiniDB installation directory -COLUMNSTORE_INSTALL_DIR=/usr/local/Calpont - -LD_LIBRARY_PATH=$COLUMNSTORE_INSTALL_DIR/lib:$COLUMNSTORE_INSTALL_DIR/mysql/lib/mysql -export COLUMNSTORE_INSTALL_DIR=$COLUMNSTORE_INSTALL_DIR -export LD_LIBRARY_PATH=$LD_LIBRARY_PATH diff --git a/oam/install_scripts/infinidb.upstart b/oam/install_scripts/infinidb.upstart deleted file mode 100644 index bb53d6901..000000000 --- a/oam/install_scripts/infinidb.upstart +++ /dev/null @@ -1,16 +0,0 @@ -# $Id$ - -description "Starts the InfiniDB Enterprise Process Monitor" - -start on runlevel 2 -start on runlevel 3 - -stop on runlevel 0 -stop on runlevel 1 -stop on runlevel 4 -stop on runlevel 5 -stop on runlevel 6 - -respawn -exec /usr/local/Calpont/bin/ProcMon - diff --git a/oam/install_scripts/softwareReport.sh b/oam/install_scripts/softwareReport.sh deleted file mode 100755 index 09fcb4db6..000000000 --- a/oam/install_scripts/softwareReport.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# -# $Id: hardwareReport.sh 421 2007-04-05 15:46:55Z dhill $ -# -if [ $1 ] ; then - MODULE=$1 -else - MODULE="pm1" -fi - -if [ $2 ] ; then - INSTALLDIR=$2 -else - INSTALLDIR="/usr/local/mariadb/columnstore" -fi - -USER=`whoami 2>/dev/null` - -if [ $USER = "root" ]; then - SUDO=" " -else - SUDO="sudo" -fi - -$SUDO rm -f /tmp/${MODULE}_softwareReport.txt - -{ -echo " " -echo "******************** Software Report for ${MODULE} ********************" -echo " " - -echo " " -echo "-- Columnstore Package Details --" -echo " " -echo "################# mcsadmin getcolumnstoresoftwareinfo #################" -echo " " -$INSTALLDIR/bin/mcsadmin getsoftwareinfo - -echo " " -echo "-- Columnstore Storage Configuration --" -echo " " -echo "################# mcsadmin getStorageConfig #################" -echo " " -$INSTALLDIR/bin/mcsadmin getStorageConfig - -} > /tmp/${MODULE}_softwareReport.txt - -exit 0 diff --git a/oam/install_scripts/syslogSetup.sh b/oam/install_scripts/syslogSetup.sh index 0d8c3550a..dbc868d42 100755 --- a/oam/install_scripts/syslogSetup.sh +++ b/oam/install_scripts/syslogSetup.sh @@ -186,7 +186,7 @@ if [ ! -z "$syslog_conf" ] ; then fi //set permissions - $SUDO chown $user:$group -R /var/log/mariadb > /dev/null 2>&1 + chown $user:$group -R /var/log/mariadb > /dev/null 2>&1 if [ $rsyslog7 == 1 ]; then rm -f /etc/rsyslog.d/49-columnstore.conf diff --git a/oamapps/calpont-console/calpont-console.vpj b/oamapps/calpont-console/calpont-console.vpj deleted file mode 100644 index 3d9826aab..000000000 --- a/oamapps/calpont-console/calpont-console.vpj +++ /dev/null @@ -1,228 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/oamapps/calpont-console/calpontConsole.vpj b/oamapps/calpont-console/calpontConsole.vpj deleted file mode 100644 index 4cb8b0e2b..000000000 --- a/oamapps/calpont-console/calpontConsole.vpj +++ /dev/null @@ -1,224 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/oamapps/calpontConsole/CMakeLists.txt b/oamapps/calpontConsole/CMakeLists.txt deleted file mode 100644 index 6566529cc..000000000 --- a/oamapps/calpontConsole/CMakeLists.txt +++ /dev/null @@ -1,48 +0,0 @@ - -# -# Not used -# -# - - -#original Makefile.am contents follow: - -## Copyright (C) 2014 InfiniDB, Inc. -## -## This program 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; version 2 of -## the License. -## -## This program 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 this program; if not, write to the Free Software -## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -## MA 02110-1301, USA. -# -## $Id: Makefile.am 333 2009-04-03 20:35:04Z rdempsey $ -### Process this file with automake to produce Makefile.in -# -#AM_CPPFLAGS = $(idb_cppflags) -#AM_CFLAGS = $(idb_cflags) -#AM_CXXFLAGS = $(idb_cxxflags) -#AM_LDFLAGS = $(idb_ldflags) -#bin_PROGRAMS = calpontConsole -#calpontConsole_SOURCES = calpontConsole.cpp -#calpontConsole_CPPFLAGS = $(idb_common_includes) $(AM_CPPFLAGS) -#calpontConsole_LDFLAGS = $(idb_common_ldflags) $(idb_common_libs) $(idb_oam_libs) $(idb_exec_libs) -lreadline -lncurses $(AM_LDFLAGS) -# -#test: -# -#coverage: -# -#leakcheck: -# -#docs: -# -#bootstrap: install-data-am -# diff --git a/oamapps/calpontConsole/calpontConsole.cpp b/oamapps/calpontConsole/calpontConsole.cpp deleted file mode 100644 index ac4d06b5b..000000000 --- a/oamapps/calpontConsole/calpontConsole.cpp +++ /dev/null @@ -1,9389 +0,0 @@ -/* Copyright (C) 2014 InfiniDB, Inc. - - This program 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; version 2 of - the License. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - MA 02110-1301, USA. */ - - -/****************************************************************************************** - * $Id: calpontConsole.cpp 3110 2013-06-20 18:09:12Z dhill $ - * - ******************************************************************************************/ - -#include -#include -extern int h_errno; - -#include "columnstoreversion.h" -#include "calpontConsole.h" -#include "boost/filesystem/operations.hpp" -#include "boost/filesystem/path.hpp" -#include "boost/tokenizer.hpp" -#include "sessionmanager.h" -#include "dbrm.h" -namespace fs = boost::filesystem; - -using namespace alarmmanager; -using namespace std; -using namespace oam; -using namespace config; - -#include "installdir.h" - -// Variables shared in both main and functions - -Config* fConfig = 0; -string Section; -int CmdID = 0; -string CmdList[cmdNum]; -int CmdListID[cmdNum]; -string cmdName; -const string SECTION_NAME = "Cmd"; -int serverInstallType; -string systemName; -string parentOAMModule; -string localModule; -bool rootUser = true; -string HOME = "/root"; - -bool repeatStop; - -static void checkPromptThread(); - -bool waitForActive() -{ - Oam oam; - SystemStatus systemstatus; - SystemProcessStatus systemprocessstatus; - bool bfirst = true; - - for (int i = 0 ; i < 1200 ; i ++) - { - sleep (3); - - try - { - oam.getSystemStatus(systemstatus); - - if (systemstatus.SystemOpState == ACTIVE) - { - return true; - } - - if (systemstatus.SystemOpState == FAILED) - { - return false; - } - - if (systemstatus.SystemOpState == MAN_OFFLINE) - { - return false; - } - - cout << "." << flush; - - // Check DMLProc for a switch to BUSY_INIT. - // In such a case, we need to print a message that rollbacks - // are occurring and will take some time. - if (bfirst) // Once we've printed our message, no need to waste cpu looking - { - oam.getProcessStatus(systemprocessstatus); - - for (unsigned int i = 0 ; i < systemprocessstatus.processstatus.size(); i++) - { - if (systemprocessstatus.processstatus[i].ProcessName == "DMLProc") - { - if (systemprocessstatus.processstatus[i].ProcessOpState == oam::ROLLBACK_INIT) - { - cout << endl << endl << " System Not Ready, DMLProc is checking/processing rollback of abandoned transactions. Processing could take some time, please wait..." << flush; - bfirst = false; - } - - // At this point, we've found our DMLProc, so there's no need to spin the for loop - // any further. - break; - } - } - } - } - catch (...) - { - // At some point, we need to give up, ProcMgr just isn't going to respond. - if (i > 60) // 3 minutes - { - cout << "ProcMgr not responding while waiting for system to start"; - break; - } - } - } - - return false; -} - -bool waitForStop() -{ - Oam oam; - SystemStatus systemstatus; - SystemProcessStatus systemprocessstatus; - - for (int i = 0 ; i < 1200 ; i ++) - { - sleep (3); - - try - { - oam.getSystemStatus(systemstatus); - - if (systemstatus.SystemOpState == MAN_OFFLINE) - { - return true; - } - - if (systemstatus.SystemOpState == FAILED) - { - return false; - } - - cout << "." << flush; - } - catch (...) - { - // At some point, we need to give up, ProcMgr just isn't going to respond. - if (i > 60) // 3 minutes - { - cout << "ProcMgr not responding while waiting for system to start"; - break; - } - } - } - - return false; -} - -//------------------------------------------------------------------------------ -// Signal handler to catch SIGTERM signal to terminate the process -//------------------------------------------------------------------------------ -void handleSigTerm(int i) -{ - std::cout << "Received SIGTERM to terminate Calpont Console..." << std::endl; - -} - -//------------------------------------------------------------------------------ -// Signal handler to catch Control-C signal to terminate the process -//------------------------------------------------------------------------------ -void handleControlC(int i) -{ - std::cout << "Received Control-C to terminate the console..." << std::endl; - exit(0); -} - -//------------------------------------------------------------------------------ -// Initialize signal handling -//------------------------------------------------------------------------------ -void setupSignalHandlers() -{ -#ifdef _MSC_VER - //FIXME -#else - // Control-C signal to terminate a command - struct sigaction act; - memset(&act, 0, sizeof(act)); - act.sa_handler = handleControlC; - sigaction(SIGINT, &act, 0); - - // catch SIGTERM signal to terminate the program -// memset(&act, 0, sizeof(act)); -// act.sa_handler = handleSigTerm; -// sigaction(SIGTERM, &act, 0); -#endif -} - -int main(int argc, char* argv[]) -{ -#ifndef _MSC_VER - setuid(0); // set effective ID to root; ignore return status -#endif - setlocale(LC_ALL, ""); - - Oam oam; - char* pcommand = 0; - string arguments[ArgNum]; - - const char* p = getenv("HOME"); - - if (!p) - p = ""; - else - HOME = p; - - string ccHistoryFile = HOME + "/.cc_history"; - - string cf = startup::StartUp::installDir() + "/etc/" + ConsoleCmdsFile; - fConfig = Config::makeConfig(cf); - -// setupSignalHandlers(); - - // Get System Name - try - { - oam.getSystemConfig("SystemName", systemName); - } - catch (...) - { - cout << endl << "**** Failed : Failed to read systemName Name" << endl; - exit(-1); - } - - //get parentModule Name - parentOAMModule = getParentOAMModule(); - - // get Local Module Name and Single Server Install Indicator - oamModuleInfo_t st; - - try - { - st = oam.getModuleInfo(); - localModule = boost::get<0>(st); - serverInstallType = boost::get<5>(st); - } - catch (...) - { - cout << endl << "**** Failed : Failed to read Local Module Name" << endl; - exit(-1); - } - - //check if root-user - int user; - user = getuid(); - - if (user != 0) - rootUser = false; - - // create/open command log file if not created - - logFile.open(DEFAULT_LOG_FILE.c_str(), ios::app); - - if (geteuid() == 0 && !logFile) - { - cerr << "UI Command log file cannot be opened" << endl; - } - - writeLog("Start of a command session!!!"); - - // get and sort command list for future help display - - for (int i = 0; i < cmdNum ; i++) - { - // get cmd name - - Section = SECTION_NAME + oam.itoa(i); - - cmdName = fConfig->getConfig(Section, "Name"); - - if (cmdName.empty()) - // no command skip - continue; - - CmdList[i] = cmdName; - CmdListID[i] = i; - - // sort - - for (int j = 0; j < i ; j++) - { - if ( CmdList[i] < CmdList[j] ) - { - cmdName = CmdList[i]; - CmdList[i] = CmdList[j]; - CmdList[j] = cmdName; - CmdID = CmdListID[i]; - CmdListID[i] = CmdListID[j]; - CmdListID[j] = CmdID; - } - } - } - - if ( localModule != parentOAMModule ) - { - // issue message informing user they aren't logged into Active OAm Parent - cout << endl; - cout << "WARNING: running on non Parent OAM Module, can't make configuration changes in this session." << endl; - cout << " Access Console from '" << parentOAMModule << "' if you need to make changes." << endl << endl; - } - - // check for arguments passed in as a request - - if (argc > 1) - { - int j = 0; - string command; - - for (; argc > 1; j++, argc--) - { - arguments[j] = argv[j + 1]; - command.append(arguments[j]); - command.append(" "); - } - - // add to history and UI command log file - read_history(ccHistoryFile.c_str()); - add_history (command.c_str()); - writeLog(command.c_str()); - write_history(ccHistoryFile.c_str()); - - checkRepeat(arguments, j); - } - else - { - cout << endl << "Calpont InfiniDB Command Console" << endl; - cout << " enter 'help' for list of commands" << endl; - cout << " enter 'exit' to exit the Calpont InfiniDB Command Console" << endl; - cout << " use up/down arrows to recall commands" << endl << endl; - - // output current active alarm stats - printAlarmSummary(); - printCriticalAlarms(); - - //read readline history file - read_history(ccHistoryFile.c_str()); - - while (true) - { - //get parentModule Name - parentOAMModule = getParentOAMModule(); - - // flush agument list - for (int j = 0; j < ArgNum; j++) - { - arguments[j].clear(); - } - - // read input - pcommand = readline("InfiniDB> "); - - if (!pcommand) // user hit -D - pcommand = strdup("exit"); - - else if (!*pcommand) - { - // just an enter-key was entered, ignore and reprompt - continue; - } - - // add to history and UI command log file - add_history (pcommand); - writeLog(pcommand); - write_history(ccHistoryFile.c_str()); - - string command = pcommand; - - //check if a argument was entered as a set of char with quotes around them - int commandLoc = 0; - int numberArgs = 0; - bool validCMD = true; - - for (int i = 0; i < ArgNum; i++) - { - string::size_type pos = command.find(" ", commandLoc); - string::size_type pos1 = command.find("\"", commandLoc); - string::size_type pos3 = command.find("\'", commandLoc); - - if ( (pos == string::npos && pos1 == string::npos) || - (pos == string::npos && pos3 == string::npos) ) - { - //end of the command - string argtemp = command.substr(commandLoc, 80); - - if ( argtemp != "" ) - { - arguments[numberArgs] = argtemp; - numberArgs++; - } - - break; - } - - if (pos < pos1 && pos < pos3) - { - // hit ' ' first - string argtemp = command.substr(commandLoc, pos - commandLoc); - - if ( argtemp != "" ) - { - arguments[numberArgs] = argtemp; - numberArgs++; - } - - commandLoc = pos + 1; - } - else - { - if ( pos >= pos1 ) - { - //hit " first - string::size_type pos2 = command.find("\"", pos1 + 1); - - if (pos2 != string::npos) - { - arguments[numberArgs] = command.substr(pos1 + 1, pos2 - pos1 - 1); - numberArgs++; - commandLoc = pos2 + 1; - } - else - { - cout << "Invalid Command, mismatching use of quotes" << endl; - validCMD = false; - break; - } - } - else - { - //hit ' first - string::size_type pos2 = command.find("\'", pos3 + 1); - - if (pos2 != string::npos) - { - arguments[numberArgs] = command.substr(pos3 + 1, pos2 - pos3 - 1); - numberArgs++; - commandLoc = pos2 + 1; - } - else - { - cout << "Invalid Command, mismatching use of quotes" << endl; - validCMD = false; - break; - } - } - } - } - - if (validCMD) - checkRepeat(arguments, numberArgs); - - free (pcommand); - } - } -} - -void checkRepeat(string* arguments, int argNumber) -{ - Oam oam; - bool repeat = false; - int repeatCount = 5; - - for ( int i = 0; i < argNumber ; i++) - { - if ( arguments[i].find("-r") == 0) - { - // entered - if ( arguments[i] != "-r") - { - //strip report count off - repeatCount = atoi(arguments[i].substr(2, 10).c_str()); - - if ( repeatCount < 1 || repeatCount > 60 ) - { - cout << "Failed: incorrect repeat count entered, valid range is 1-60, set to default of 5" << endl; - repeatCount = 5; - } - } - - repeat = true; - arguments[i].clear(); - cout << "repeating the command '" << arguments[0] << "' every " << repeatCount << " seconds, enter CTRL-D to stop" << endl; - sleep(5); - break; - } - } - - bool threadCreate = false; - - if (repeat) - { - while (true) - { - system("clear"); - - if ( processCommand(arguments) ) - return; - else - { - if ( !threadCreate ) - { - threadCreate = true; - repeatStop = false; - pthread_t PromptThread; - pthread_create (&PromptThread, NULL, (void* (*)(void*)) &checkPromptThread, NULL); - } - - for ( int i = 0 ; i < repeatCount ; i ++ ) - { - if (repeatStop) - break; - - sleep(1); - } - - if (repeatStop) - break; - } - } - } - else - processCommand(arguments); -} - -int processCommand(string* arguments) -{ - Oam oam; - // Possible command line arguments - GRACEFUL_FLAG gracefulTemp = GRACEFUL; - ACK_FLAG ackTemp = ACK_YES; - CC_SUSPEND_ANSWER suspendAnswer = CANCEL; - bool bNeedsConfirm = true; - string password; - - // get command info from Command config file - CmdID = -1; - - // put inputted command into lowercase - string inputCmd = arguments[0]; - transform (inputCmd.begin(), inputCmd.end(), inputCmd.begin(), to_lower()); - - for (int i = 0; i < cmdNum; i++) - { - // put table command into lowercase - string cmdName_LC = CmdList[i]; - transform (cmdName_LC.begin(), cmdName_LC.end(), cmdName_LC.begin(), to_lower()); - - if (cmdName_LC.find(inputCmd) == 0) - { - // command found, ECHO command - cout << cmdName_LC << " " << oam.getCurrentTime() << endl; - CmdID = CmdListID[i]; - break; - } - } - - if (CmdID == -1) - { - // get is command in the Support Command list - for (int i = 0;; i++) - { - if (supportCmds[i] == "") - // end of list - break; - - if (supportCmds[i].find(inputCmd) == 0) - { - // match found, go process it - cout << supportCmds[i] << " " << oam.getCurrentTime() << endl; - int status = ProcessSupportCommand(i, arguments); - - if ( status == -1 ) - // didn't process it for some reason - break; - - return 1; - } - } - - // command not valid - cout << arguments[0] << ": Unknown Command, type help for list of commands" << endl << endl; - return 1; - } - - switch ( CmdID ) - { - case 0: // help - case 1: // ? - { - const string DESC_NAME = "Desc"; - string desc; - string descName; - const string ARG_NAME = "Arg"; - string arg; - string argName; - - string argument1_LC = arguments[1]; - transform (argument1_LC.begin(), argument1_LC.end(), argument1_LC.begin(), to_lower()); - - if (argument1_LC.find("-a") == 0 || argument1_LC == "") - { - // list commands and brief description (Desc1) - cout << endl << "List of commands:" << endl; - cout << "Note: the command must be the first entry entered on the command line" << endl << endl; - cout.setf(ios::left); - cout.width(34); - cout << "Command" << "Description" << endl; - cout.setf(ios::left); - cout.width(34); - cout << "------------------------------" << "--------------------------------------------------------" << endl; - - for (int i = 0; i < cmdNum ; i++) - { - // get cmd name - - Section = SECTION_NAME + oam.itoa(CmdListID[i]); - - cmdName = fConfig->getConfig(Section, "Name"); - - if (cmdName.empty() || cmdName == "AVAILABLE") - // no command skip - continue; - - cout.setf(ios::left); - cout.width(34); - cout << cmdName << fConfig->getConfig(Section, "Desc1") << endl; - } - - cout << endl << "For help on a command, enter 'help' followed by command name" << endl; - } - else - { - if (argument1_LC.find("-v") == 0) - { - // list of commands with their descriptions - cout << endl << "List of commands and descriptions:" << endl << endl; - - for (int k = 0 ; k < cmdNum ; k++) - { - Section = SECTION_NAME + oam.itoa(CmdListID[k]); - cmdName = fConfig->getConfig(Section, "Name"); - - if (cmdName.empty() || cmdName == "AVAILABLE") - //no command skip - continue; - - cout << "Command: " << cmdName << endl << endl; - int i = 2; - cout << " Description: " << fConfig->getConfig(Section, "Desc1") << endl; - - while (true) - { - desc = DESC_NAME + oam.itoa(i); - descName = fConfig->getConfig(Section, desc); - - if (descName.empty()) - //end of Desc list - break; - - cout << " " << descName << endl; - i++; - } - - i = 2; - cout << endl << " Arguments: " << fConfig->getConfig(Section, "Arg1") << endl; - - while (true) - { - arg = ARG_NAME + oam.itoa(i); - argName = fConfig->getConfig(Section, arg); - - if (argName.empty()) - //end of arg list - break; - - cout << " " << argName << endl; - i++; - } - - cout << endl; - } - } - else - { - // description for a single command - int j = 0; - - for (j = 0; j < cmdNum; j++) - { - // get cmd description - - Section = SECTION_NAME + oam.itoa(j); - - cmdName = fConfig->getConfig(Section, "Name"); - - string cmdName_LC = cmdName; - transform (cmdName_LC.begin(), cmdName_LC.end(), cmdName_LC.begin(), to_lower()); - - if (cmdName_LC == argument1_LC) - { - // command found, output description - cout << endl << " Command: " << cmdName << endl << endl; - int i = 2; - cout << " Description: " << fConfig->getConfig(Section, "Desc1") << endl; - - while (true) - { - desc = DESC_NAME + oam.itoa(i); - descName = fConfig->getConfig(Section, desc); - - if (descName.empty()) - //end of Desc list - break; - - cout << " " << descName << endl; - i++; - } - - i = 2; - cout << endl << " Arguments: " << fConfig->getConfig(Section, "Arg1") << endl; - - while (true) - { - arg = ARG_NAME + oam.itoa(i); - argName = fConfig->getConfig(Section, arg); - - if (argName.empty()) - //end of arg list - break; - - cout << " " << argName << endl; - i++; - } - - break; - } - } - - if (j == cmdNum) - { - // command not valid - cout << arguments[1] << ": Unknown Command, type help for list of commands" << endl << endl; - break; - } - } - } - - cout << endl; - } - break; - - case 2: // exit - case 3: // quit - { - // close the log file - writeLog("End of a command session!!!"); - logFile.close(); - cout << "Exiting the Calpont Command Console" << endl; - - exit (0); - } - break; - - case 4: // getSystemConfig - { - SystemConfig systemconfig; - string returnValue; - - if (arguments[1] == "all" || arguments[1] == "") - { - - // get and all display System config parameters - - try - { - oam.getSystemConfig(systemconfig); - - cout << endl << "System Configuration" << endl << endl; - - cout << "SystemName = " << systemconfig.SystemName << endl; - cout << "SoftwareVersion = " << columnstore_version << endl; - cout << "SoftwareRelease = " << columnstore_release << endl; - - cout << "ParentOAMModuleName = " << systemconfig.ParentOAMModule << endl; - cout << "StandbyOAMModuleName = " << systemconfig.StandbyOAMModule << endl; - cout << "NMSIPAddr = " << systemconfig.NMSIPAddr << endl; - cout << "ModuleHeartbeatPeriod = " << systemconfig.ModuleHeartbeatPeriod << endl; - cout << "ModuleHeartbeatCount = " << systemconfig.ModuleHeartbeatCount << endl; -// cout << "ProcessHeartbeatPeriod = " << systemconfig.ProcessHeartbeatPeriod << endl; - cout << "DBRootCount = " << systemconfig.DBRootCount << endl; - - std::vector::iterator pt = systemconfig.DBRoot.begin(); - int id = 1; - - for ( ; pt != systemconfig.DBRoot.end() ; pt++) - { - string dbroot = *pt; - cout << "DBRoot" + oam.itoa(id) + " = " + dbroot << endl; - ++id; - } - - cout << "DBRMRoot = " << systemconfig.DBRMRoot << endl; - cout << "ExternalCriticalThreshold = " << systemconfig.ExternalCriticalThreshold << endl; - cout << "ExternalMajorThreshold = " << systemconfig.ExternalMajorThreshold << endl; - cout << "ExternalMinorThreshold = " << systemconfig.ExternalMinorThreshold << endl; - cout << "MaxConcurrentTransactions = " << systemconfig.MaxConcurrentTransactions << endl; - cout << "SharedMemoryTmpFile = " << systemconfig.SharedMemoryTmpFile << endl; - cout << "NumVersionBufferFiles = " << systemconfig.NumVersionBufferFiles << endl; - cout << "VersionBufferFileSize = " << systemconfig.VersionBufferFileSize << endl; - cout << "OIDBitmapFile = " << systemconfig.OIDBitmapFile << endl; - cout << "FirstOID = " << systemconfig.FirstOID << endl; - cout << "TransactionArchivePeriod = " << systemconfig.TransactionArchivePeriod << endl; - - } - catch (exception& e) - { - cout << endl << "**** getSystemConfig Failed : " << e.what() << endl; - } - } - else - { - // get a single parameter - - try - { - oam.getSystemConfig(arguments[1], returnValue); - cout << endl << " " << arguments[1] << " = " << returnValue << endl << endl; - } - catch (exception& e) - { - cout << endl << "**** getSystemConfig Failed : " << e.what() << endl; - } - } - } - break; - - case 5: // setSystemConfig - parameters: Module name, Parameter name and value - { - parentOAMModule = getParentOAMModule(); - - if ( localModule != parentOAMModule ) - { - // exit out since not on Parent OAM Module - cout << endl << "**** setSystemConfig Failed : only should be run on the Parent OAM Module, which is '" << parentOAMModule << "'" << endl; - break; - } - - if (arguments[2] == "") - { - // need 2 arguments - cout << endl << "**** setSystemConfig Failed : Missing a required Parameter, enter 'help' for additional information" << endl; - break; - } - - try - { - if ( arguments[2] == "=" ) - { - cout << endl << "**** setSystemConfig Failed : Invalid Value of '=', please re-enter" << endl; - break; - } - - oam.setSystemConfig(arguments[1], arguments[2]); - cout << endl << " Successfully set " << arguments[1] << " = " << arguments[2] << endl << endl; - } - catch (exception& e) - { - cout << endl << "**** setSystemConfig Failed : " << e.what() << endl; - } - } - break; - - case 6: // getModuleTypeConfig - { - SystemModuleTypeConfig systemmoduletypeconfig; - ModuleTypeConfig moduletypeconfig; - ModuleConfig moduleconfig; - systemmoduletypeconfig.moduletypeconfig.clear(); - string returnValue; - string Argument; - - if (arguments[1] == "all" || arguments[1] == "") - { - - // get and all display Module config parameters - - try - { - oam.getSystemConfig(systemmoduletypeconfig); - - cout << endl << "Module Type Configuration" << endl << endl; - - for ( unsigned int i = 0 ; i < systemmoduletypeconfig.moduletypeconfig.size(); i++) - { - if ( systemmoduletypeconfig.moduletypeconfig[i].ModuleType.empty() ) - // end of list - break; - - int moduleCount = systemmoduletypeconfig.moduletypeconfig[i].ModuleCount; - - if ( moduleCount < 1 ) - continue; - - string moduletype = systemmoduletypeconfig.moduletypeconfig[i].ModuleType; - cout << "ModuleType '" << moduletype << "' Configuration information" << endl << endl; - - cout << "ModuleDesc = " << systemmoduletypeconfig.moduletypeconfig[i].ModuleDesc << endl; - cout << "RunType = " << systemmoduletypeconfig.moduletypeconfig[i].RunType << endl; - cout << "ModuleCount = " << moduleCount << endl; - - if ( moduleCount > 0 ) - { - DeviceNetworkList::iterator pt = systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.begin(); - - for ( ; pt != systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.end() ; pt++) - { - string modulename = (*pt).DeviceName; - HostConfigList::iterator pt1 = (*pt).hostConfigList.begin(); - - for ( ; pt1 != (*pt).hostConfigList.end() ; pt1++) - { - string ipAddr = (*pt1).IPAddr; - string servername = (*pt1).HostName; - cout << "ModuleHostName and ModuleIPAddr for NIC ID " + oam.itoa((*pt1).NicID) + " on module '" << modulename << "' = " << servername << " , " << ipAddr << endl; - } - } - } - - DeviceDBRootList::iterator pt = systemmoduletypeconfig.moduletypeconfig[i].ModuleDBRootList.begin(); - - for ( ; pt != systemmoduletypeconfig.moduletypeconfig[i].ModuleDBRootList.end() ; pt++) - { - if ( (*pt).dbrootConfigList.size() > 0 ) - { - cout << "DBRootIDs assigned to module 'pm" << (*pt).DeviceID << "' = "; - DBRootConfigList::iterator pt1 = (*pt).dbrootConfigList.begin(); - - for ( ; pt1 != (*pt).dbrootConfigList.end() ; ) - { - cout << *pt1; - pt1++; - - if (pt1 != (*pt).dbrootConfigList.end()) - cout << ", "; - } - } - - cout << endl; - } - - cout << "ModuleCPUCriticalThreshold % = " << systemmoduletypeconfig.moduletypeconfig[i].ModuleCPUCriticalThreshold << endl; - cout << "ModuleCPUMajorThreshold % = " << systemmoduletypeconfig.moduletypeconfig[i].ModuleCPUMajorThreshold << endl; - cout << "ModuleCPUMinorThreshold % = " << systemmoduletypeconfig.moduletypeconfig[i].ModuleCPUMinorThreshold << endl; - cout << "ModuleCPUMinorClearThreshold % = " << systemmoduletypeconfig.moduletypeconfig[i].ModuleCPUMinorClearThreshold << endl; - cout << "ModuleDiskCriticalThreshold % = " << systemmoduletypeconfig.moduletypeconfig[i].ModuleDiskCriticalThreshold << endl; - cout << "ModuleDiskMajorThreshold % = " << systemmoduletypeconfig.moduletypeconfig[i].ModuleDiskMajorThreshold << endl; - cout << "ModuleDiskMinorThreshold % = " << systemmoduletypeconfig.moduletypeconfig[i].ModuleDiskMinorThreshold << endl; - cout << "ModuleMemCriticalThreshold % = " << systemmoduletypeconfig.moduletypeconfig[i].ModuleMemCriticalThreshold << endl; - cout << "ModuleMemMajorThreshold % = " << systemmoduletypeconfig.moduletypeconfig[i].ModuleMemMajorThreshold << endl; - cout << "ModuleMemMinorThreshold % = " << systemmoduletypeconfig.moduletypeconfig[i].ModuleMemMinorThreshold << endl; - cout << "ModuleSwapCriticalThreshold % = " << systemmoduletypeconfig.moduletypeconfig[i].ModuleSwapCriticalThreshold << endl; - cout << "ModuleSwapMajorThreshold % = " << systemmoduletypeconfig.moduletypeconfig[i].ModuleSwapMajorThreshold << endl; - cout << "ModuleSwapMinorThreshold % = " << systemmoduletypeconfig.moduletypeconfig[i].ModuleSwapMinorThreshold << endl; - - DiskMonitorFileSystems::iterator pt2 = systemmoduletypeconfig.moduletypeconfig[i].FileSystems.begin(); - int id = 1; - - for ( ; pt2 != systemmoduletypeconfig.moduletypeconfig[i].FileSystems.end() ; pt2++) - { - string fs = *pt2; - cout << "ModuleDiskMonitorFileSystem#" << id << " = " << fs << endl; - ++id; - } - - cout << endl; - } - } - catch (exception& e) - { - cout << endl << "**** getModuleTypeConfig Failed = " << e.what() << endl; - } - } - else - { - // get a single module type config - if (arguments[2] == "") - { - try - { - oam.getSystemConfig(arguments[1], moduletypeconfig); - - cout << endl << "Module Type Configuration for " << arguments[1] << endl << endl; - - int moduleCount = moduletypeconfig.ModuleCount; - string moduletype = moduletypeconfig.ModuleType; - - cout << "ModuleDesc = " << moduletypeconfig.ModuleDesc << endl; - cout << "ModuleCount = " << moduleCount << endl; - cout << "RunType = " << moduletypeconfig.RunType << endl; - - if ( moduleCount > 0 ) - { - DeviceNetworkList::iterator pt = moduletypeconfig.ModuleNetworkList.begin(); - - for ( ; pt != moduletypeconfig.ModuleNetworkList.end() ; pt++) - { - string modulename = (*pt).DeviceName; - HostConfigList::iterator pt1 = (*pt).hostConfigList.begin(); - - for ( ; pt1 != (*pt).hostConfigList.end() ; pt1++) - { - string ipAddr = (*pt1).IPAddr; - string servername = (*pt1).HostName; - cout << "ModuleHostName and ModuleIPAddr for NIC ID " + oam.itoa((*pt1).NicID) + " on module " << modulename << " = " << servername << " , " << ipAddr << endl; - } - } - } - - int dbrootCount = moduletypeconfig.ModuleDBRootList.size(); - - cout << "DBRootCount = " << dbrootCount << endl; - - if ( dbrootCount > 0 ) - { - DeviceDBRootList::iterator pt = moduletypeconfig.ModuleDBRootList.begin(); - - for ( ; pt != moduletypeconfig.ModuleDBRootList.end() ; pt++) - { - cout << "DBRoot IDs assigned to 'pm" + oam.itoa((*pt).DeviceID) + "' = "; - - DBRootConfigList::iterator pt1 = (*pt).dbrootConfigList.begin(); - - for ( ; pt1 != (*pt).dbrootConfigList.end() ; ) - { - cout << *pt1; - pt1++; - - if (pt1 != (*pt).dbrootConfigList.end()) - cout << ", "; - } - - cout << endl; - } - } - - cout << "ModuleCPUCriticalThreshold % = " << moduletypeconfig.ModuleCPUCriticalThreshold << endl; - cout << "ModuleCPUMajorThreshold % = " << moduletypeconfig.ModuleCPUMajorThreshold << endl; - cout << "ModuleCPUMinorThreshold % = " << moduletypeconfig.ModuleCPUMinorThreshold << endl; - cout << "ModuleCPUMinorClearThreshold % = " << moduletypeconfig.ModuleCPUMinorClearThreshold << endl; - cout << "ModuleDiskCriticalThreshold % = " << moduletypeconfig.ModuleDiskCriticalThreshold << endl; - cout << "ModuleDiskMajorThreshold % = " << moduletypeconfig.ModuleDiskMajorThreshold << endl; - cout << "ModuleDiskMinorThreshold % = " << moduletypeconfig.ModuleDiskMinorThreshold << endl; - cout << "ModuleMemCriticalThreshold % = " << moduletypeconfig.ModuleMemCriticalThreshold << endl; - cout << "ModuleMemMajorThreshold % = " << moduletypeconfig.ModuleMemMajorThreshold << endl; - cout << "ModuleMemMinorThreshold % = " << moduletypeconfig.ModuleMemMinorThreshold << endl; - cout << "ModuleSwapCriticalThreshold % = " << moduletypeconfig.ModuleSwapCriticalThreshold << endl; - cout << "ModuleSwapMajorThreshold % = " << moduletypeconfig.ModuleSwapMajorThreshold << endl; - cout << "ModuleSwapMinorThreshold % = " << moduletypeconfig.ModuleSwapMinorThreshold << endl; - - DiskMonitorFileSystems::iterator pt = moduletypeconfig.FileSystems.begin(); - int id = 1; - - for ( ; pt != moduletypeconfig.FileSystems.end() ; pt++) - { - string fs = *pt; - cout << "ModuleDiskMonitorFileSystem#" << id << " = " << fs << endl; - ++id; - } - - cout << endl; - } - catch (exception& e) - { - cout << endl << "**** getModuleTypeConfig Failed = " << e.what() << endl; - } - } - else - { - // get a parameter for a module type - try - { - oam.getSystemConfig(systemmoduletypeconfig); - } - catch (...) - {} - - unsigned int i = 0; - - for ( i = 0 ; i < systemmoduletypeconfig.moduletypeconfig.size(); i++) - { - if (systemmoduletypeconfig.moduletypeconfig[i].ModuleType == arguments[1]) - { - string argument2 = arguments[2]; - string::size_type pos = arguments[2].rfind("#", 200); - - if (pos != string::npos) - { - string ID = arguments[2].substr(pos + 1, 5); - arguments[2] = arguments[2].substr(0, pos); - arguments[2] = arguments[2] + ID + "-"; - } - - Argument = arguments[2] + oam.itoa(i + 1); - - try - { - oam.getSystemConfig(Argument, returnValue); - cout << endl << " " << argument2 << " = " << returnValue << endl << endl; - break; - } - catch (exception& e) - { - cout << endl << "**** getModuleTypeConfig Failed = " << e.what() << endl; - break; - } - } - } - - if ( i == systemmoduletypeconfig.moduletypeconfig.size() ) - { - // module type not found - cout << endl << "**** getModuleTypeConfig Failed : Invalid Module Type" << endl; - break; - } - } - } - } - break; - - case 7: // setModuleTypeConfig - parameters: Module type, Parameter name and value - { - SystemModuleTypeConfig systemmoduletypeconfig; - ModuleTypeConfig moduletypeconfig; - string Argument; - - parentOAMModule = getParentOAMModule(); - - if ( localModule != parentOAMModule ) - { - // exit out since not on Parent OAM Module - cout << endl << "**** setModuleTypeConfig Failed : only should be run on the Parent OAM Module, which is '" << parentOAMModule << "'" << endl; - break; - } - - if (arguments[3] == "") - { - // need 3 arguments - cout << endl << "**** setModuleTypeConfig Failed : Missing a required Parameter, enter 'help' for additional information" << endl; - break; - } - - if ( arguments[3] == "=" ) - { - cout << endl << "**** setModuleTypeConfig Failed : Invalid Value of '=', please re-enter" << endl; - break; - } - - try - { - oam.getSystemConfig(systemmoduletypeconfig); - } - catch (...) - {} - - unsigned int i = 0; - - for ( i = 0 ; i < systemmoduletypeconfig.moduletypeconfig.size(); i++) - { - if (systemmoduletypeconfig.moduletypeconfig[i].ModuleType == arguments[1]) - { - string argument2 = arguments[2]; - string::size_type pos = arguments[2].rfind("#", 200); - - if (pos != string::npos) - { - string ID = arguments[2].substr(pos + 1, 5); - arguments[2] = arguments[2].substr(0, pos); - arguments[2] = arguments[2] + ID + "-"; - } - - Argument = arguments[2] + oam.itoa(i + 1); - - try - { - oam.setSystemConfig(Argument, arguments[3]); - cout << endl << " Successfully set " << argument2 << " = " << arguments[3] << endl << endl; - break; - } - catch (exception& e) - { - cout << endl << "**** setModuleTypeConfig Failed = " << e.what() << endl; - break; - } - } - } - - if ( i == systemmoduletypeconfig.moduletypeconfig.size() ) - { - // module type not found - cout << endl << "**** setModuleTypeConfig Failed : Invalid Module Type" << endl; - break; - } - } - break; - - case 8: // getProcessConfig - { - SystemProcessConfig systemprocessconfig; - ProcessConfig processconfig; - string returnValue; - - if (arguments[1] == "all" || arguments[1] == "") - { - // get and all display Process config parameters - - try - { - oam.getProcessConfig(systemprocessconfig); - - cout << endl << "Process Configuration" << endl << endl; - - for ( unsigned int i = 0 ; i < systemprocessconfig.processconfig.size(); i++) - { - cout << "Process #" << i + 1 << " Configuration information" << endl; - - cout << "ProcessName = " << systemprocessconfig.processconfig[i].ProcessName << endl; - cout << "ModuleType = " << systemprocessconfig.processconfig[i].ModuleType << endl; - cout << "ProcessLocation = " << systemprocessconfig.processconfig[i].ProcessLocation << endl; - - for ( int j = 0 ; j < oam::MAX_ARGUMENTS; j++) - { - if (systemprocessconfig.processconfig[i].ProcessArgs[j].empty()) - break; - - cout << "ProcessArg" << j + 1 << " = " << systemprocessconfig.processconfig[i].ProcessArgs[j] << endl; - } - - cout << "BootLaunch = " << systemprocessconfig.processconfig[i].BootLaunch << endl; - cout << "LaunchID = " << systemprocessconfig.processconfig[i].LaunchID << endl; - - for ( int j = 0 ; j < MAX_DEPENDANCY; j++) - { - if (systemprocessconfig.processconfig[i].DepProcessName[j].empty()) - break; - - cout << "DepModuleName" << j + 1 << " = " << systemprocessconfig.processconfig[i].DepModuleName[j] << endl; - cout << "DepProcessName" << j + 1 << " = " << systemprocessconfig.processconfig[i].DepProcessName[j] << endl; - } - - // display Process Group variables, if they exist - - cout << "RunType = " << systemprocessconfig.processconfig[i].RunType << endl; - cout << "LogFile = " << systemprocessconfig.processconfig[i].LogFile << endl; - - cout << endl; - } - } - catch (exception& e) - { - cout << endl << "**** getProcessConfig Failed = " << e.what() << endl; - } - } - else - { - // get a single process info - parameters: module-name, process-name - if (arguments[2] == "") - { - cout << endl << "**** getProcessConfig Failed : Missing a required Parameter, enter 'help' for additional information" << endl; - break; - } - - if (arguments[3] == "") - { - //**** Add API to get single process info - try - { - oam.getProcessConfig(arguments[1], arguments[2], processconfig); - - cout << endl << "Process Configuration for " << arguments[1] << " on module " << arguments[2] << endl << endl; - - cout << "ProcessName = " << processconfig.ProcessName << endl; - cout << "ModuleType = " << processconfig.ModuleType << endl; - cout << "ProcessLocation = " << processconfig.ProcessLocation << endl; - - for ( int j = 0 ; j < oam::MAX_ARGUMENTS; j++) - { - if (processconfig.ProcessArgs[j].empty()) - break; - - cout << "ProcessArg" << j + 1 << " = " << processconfig.ProcessArgs[j] << endl; - } - - cout << "BootLaunch = " << processconfig.BootLaunch << endl; - cout << "LaunchID = " << processconfig.LaunchID << endl; - - for ( int j = 0 ; j < MAX_DEPENDANCY; j++) - { - if (processconfig.DepProcessName[j].empty()) - break; - - cout << "DepProcessName" << j + 1 << " = " << processconfig.DepProcessName[j] << endl; - cout << "DepModuleName" << j + 1 << " = " << processconfig.DepModuleName[j] << endl; - } - - cout << "RunType = " << processconfig.RunType << endl; - cout << "LogFile = " << processconfig.LogFile << endl; - - cout << endl; - } - catch (exception& e) - { - cout << endl << "**** getProcessConfig Failed = " << e.what() << endl; - } - } - else - { - // get a parameter for a process - parameters: module-name, process-name, - // parameter-name - // get module ID from module name entered, then get parameter - try - { - oam.getProcessConfig(arguments[1], arguments[2], arguments[3], returnValue); - cout << endl << " " << arguments[3] << " = " << returnValue << endl << endl; - break; - } - catch (exception& e) - { - cout << endl << "**** getProcessConfig Failed = " << e.what() << endl; - break; - } - } - } - } - break; - - case 9: // setProcessConfig - parameters: Module name, Process Name, Parameter name and value - { - parentOAMModule = getParentOAMModule(); - - if ( localModule != parentOAMModule ) - { - // exit out since not on Parent OAM Module - cout << endl << "**** setProcessConfig Failed : only should be run on the Parent OAM Module, which is '" << parentOAMModule << "'" << endl; - break; - } - - if (arguments[4] == "") - { - cout << endl << "**** setProcessConfig Failed : Missing a required Parameter, enter 'help' for additional information" << endl; - break; - } - - try - { - if ( arguments[4] == "=" ) - { - cout << endl << "**** setProcessConfig Failed : Invalid Value of '=', please re-enter" << endl; - break; - } - - oam.setProcessConfig(arguments[1], arguments[2], arguments[3], arguments[4]); - cout << endl << " Successfully set " << arguments[3] << " = " << arguments[4] << endl << endl; - break; - } - catch (exception& e) - { - cout << endl << "**** setProcessConfig Failed = " << e.what() << endl; - break; - } - } - break; - - case 10: // getAlarmConfig- parameters: all or AlarmID - { - AlarmConfig alarmconfig; - - if (arguments[1] == "all" || arguments[1] == "") - { - - // get and all display Alarm config parameters - - cout << endl << "Alarm Configuration" << endl << endl; - - for ( int alarmID = 1 ; alarmID < MAX_ALARM_ID; alarmID++) - { - try - { - oam.getAlarmConfig(alarmID, alarmconfig); - - cout << "Alarm ID #" << alarmID << " Configuration information" << endl; - - cout << "BriefDesc = " << alarmconfig.BriefDesc << endl; - cout << "DetailedDesc = " << alarmconfig.DetailedDesc << endl; - - // cout << "EmailAddr = " << alarmconfig.EmailAddr << endl; - // cout << "PagerNum = " << alarmconfig.PagerNum << endl; - - switch (alarmconfig.Severity) - { - case CRITICAL: - cout << "Severity = CRITICAL" << endl; - break; - - case MAJOR: - cout << "Severity = MAJOR" << endl; - break; - - case MINOR: - cout << "Severity = MINOR" << endl; - break; - - case WARNING: - cout << "Severity = WARNING" << endl; - break; - - default: - cout << "Severity = INFORMATIONAL" << endl; - break; - } - - cout << "Threshold = " << alarmconfig.Threshold << endl; - // cout << "Occurrences = " << alarmconfig.Occurrences << endl; - // cout << "LastIssueTime = " << alarmconfig.LastIssueTime << endl << endl; - cout << endl; - } - catch (exception& e) - { - cout << endl << "**** getAlarmConfig Failed = " << e.what() << endl; - break; - } - } - - break; - } - else - { - // get a single Alarm info - try - { - oam.getAlarmConfig(atoi(arguments[1].c_str()), alarmconfig); - - cout << endl << "Alarm ID #" << arguments[1] << " Configuration information" << endl; - - cout << "BriefDesc = " << alarmconfig.BriefDesc << endl; - cout << "DetailedDesc = " << alarmconfig.DetailedDesc << endl; - - // cout << "EmailAddr = " << alarmconfig.EmailAddr << endl; - // cout << "PagerNum = " << alarmconfig.PagerNum << endl; - - switch (alarmconfig.Severity) - { - case CRITICAL: - cout << "Severity = CRITICAL" << endl; - break; - - case MAJOR: - cout << "Severity = MAJOR" << endl; - break; - - case MINOR: - cout << "Severity = MINOR" << endl; - break; - - case WARNING: - cout << "Severity = WARNING" << endl; - break; - - default: - cout << "Severity = INFORMATIONAL" << endl; - break; - } - - cout << "Threshold = " << alarmconfig.Threshold << endl; - // cout << "Occurrences = " << alarmconfig.Occurrences << endl; - // cout << "LastIssueTime = " << alarmconfig.LastIssueTime << endl << endl; - cout << endl; - break; - } - catch (exception& e) - { - cout << endl << "**** getAlarmConfig Failed = " << e.what() << endl; - break; - } - } - } - break; - - case 11: // setAlarmConfig - parameters: AlarmID, Parameter name and value - { - parentOAMModule = getParentOAMModule(); - - if ( localModule != parentOAMModule ) - { - // exit out since not on Parent OAM Module - cout << endl << "**** setAlarmConfig Failed : only should be run on the Parent OAM Module, which is '" << parentOAMModule << "'" << endl; - break; - } - - if (arguments[3] == "") - { - // need 3 arguments - cout << endl << "**** setAlarmConfig Failed : Missing a required Parameter, enter 'help' for additional information" << endl; - break; - } - - try - { - if ( arguments[3] == "=" ) - { - cout << endl << "**** setAlarmConfig Failed : Invalid Value of '=', please re-enter" << endl; - break; - } - - if ( arguments[2] == "Threshold" && arguments[3] != "0" && atoi(arguments[3].c_str()) == 0 ) - { - cout << endl << "**** setAlarmConfig Failed : New value must be a number" << endl; - break; - } - - oam.setAlarmConfig(atoi(arguments[1].c_str()), arguments[2], atoi(arguments[3].c_str())); - cout << endl << " Successfully set " << arguments[2] << " = " << arguments[3] << endl << endl; - break; - } - catch (exception& e) - { - cout << endl << "**** setAlarmConfig Failed = " << e.what() << endl; - break; - } - } - break; - - case 12: // getActiveAlarms - parameters: none - { - AlarmList alarmList; - - try - { - oam.getActiveAlarms(alarmList); - } - catch (...) - { - // need arguments - cout << endl << "**** getActiveAlarms Failed : Error in oam.getActiveAlarms" << endl; - break; - } - - cout << endl << "Active Alarm List:" << endl << endl; - - AlarmList :: iterator i; - - for (i = alarmList.begin(); i != alarmList.end(); ++i) - { - cout << "AlarmID = " << i->second.getAlarmID() << endl; - cout << "Brief Description = " << i->second.getDesc() << endl; - cout << "Alarm Severity = "; - - switch (i->second.getSeverity()) - { - case CRITICAL: - cout << "CRITICAL" << endl; - break; - - case MAJOR: - cout << "MAJOR" << endl; - break; - - case MINOR: - cout << "MINOR" << endl; - break; - - case WARNING: - cout << "WARNING" << endl; - break; - - case INFORMATIONAL: - cout << "INFORMATIONAL" << endl; - break; - } - - cout << "Time Issued = " << i->second.getTimestamp() << endl; - cout << "Reporting Module = " << i->second.getSname() << endl; - cout << "Reporting Process = " << i->second.getPname() << endl; - cout << "Reported Device = " << i->second.getComponentID() << endl << endl; - } - } - break; - - case 13: // getStorageConfig - { - try - { - systemStorageInfo_t t; - t = oam.getStorageConfig(); - - string cloud; - - try - { - oam.getSystemConfig("Cloud", cloud); - } - catch (...) {} - - string::size_type pos = cloud.find("amazon", 0); - - if (pos != string::npos) - cloud = "amazon"; - - cout << endl << "System Storage Configuration" << endl << endl; - - cout << "Performance Module (DBRoot) Storage Type = " << boost::get<0>(t) << endl; - - if ( cloud == "amazon" ) - cout << "User Module Storage Type = " << boost::get<3>(t) << endl; - - cout << "System Assigned DBRoot Count = " << boost::get<1>(t) << endl; - - DeviceDBRootList moduledbrootlist = boost::get<2>(t); - - typedef std::vector dbrootList; - dbrootList dbrootlist; - - DeviceDBRootList::iterator pt = moduledbrootlist.begin(); - - for ( ; pt != moduledbrootlist.end() ; pt++) - { - cout << "DBRoot IDs assigned to 'pm" + oam.itoa((*pt).DeviceID) + "' = "; - DBRootConfigList::iterator pt1 = (*pt).dbrootConfigList.begin(); - - for ( ; pt1 != (*pt).dbrootConfigList.end() ;) - { - cout << *pt1; - dbrootlist.push_back(*pt1); - pt1++; - - if (pt1 != (*pt).dbrootConfigList.end()) - cout << ", "; - } - - cout << endl; - } - - //get any unassigned DBRoots - DBRootConfigList undbrootlist; - - try - { - oam.getUnassignedDbroot(undbrootlist); - } - catch (...) {} - - if ( !undbrootlist.empty() ) - { - cout << endl << "DBRoot IDs unassigned = "; - DBRootConfigList::iterator pt1 = undbrootlist.begin(); - - for ( ; pt1 != undbrootlist.end() ;) - { - cout << *pt1; - pt1++; - - if (pt1 != undbrootlist.end()) - cout << ", "; - } - - cout << endl; - } - - cout << endl; - - // um volumes - if (cloud == "amazon" && boost::get<3>(t) == "external") - { - ModuleTypeConfig moduletypeconfig; - oam.getSystemConfig("um", moduletypeconfig); - - for ( int id = 1; id < moduletypeconfig.ModuleCount + 1 ; id++) - { - string volumeNameID = "UMVolumeName" + oam.itoa(id); - string volumeName = oam::UnassignedName; - string deviceNameID = "UMVolumeDeviceName" + oam.itoa(id); - string deviceName = oam::UnassignedName; - - try - { - oam.getSystemConfig( volumeNameID, volumeName); - oam.getSystemConfig( deviceNameID, deviceName); - } - catch (...) - {} - - cout << "Amazon EC2 Volume Name/Device Name for 'um" << id << "': " << volumeName << ", " << deviceName << endl; - } - } - - // pm volumes - if (cloud == "amazon" && boost::get<0>(t) == "external") - { - cout << endl; - - DBRootConfigList dbrootConfigList; - - try - { - oam.getSystemDbrootConfig(dbrootConfigList); - - DBRootConfigList::iterator pt = dbrootConfigList.begin(); - - for ( ; pt != dbrootConfigList.end() ; pt++) - { - string volumeNameID = "PMVolumeName" + oam.itoa(*pt); - string volumeName = oam::UnassignedName; - string deviceNameID = "PMVolumeDeviceName" + oam.itoa(*pt); - string deviceName = oam::UnassignedName; - string amazonDeviceNameID = "PMVolumeAmazonDeviceName" + oam.itoa(*pt); - string amazondeviceName = oam::UnassignedName; - - try - { - oam.getSystemConfig( volumeNameID, volumeName); - oam.getSystemConfig( deviceNameID, deviceName); - oam.getSystemConfig( amazonDeviceNameID, amazondeviceName); - } - catch (...) - { - continue; - } - - cout << "Amazon EC2 Volume Name/Device Name/Amazon Device Name for DBRoot" << oam.itoa(*pt) << ": " << volumeName << ", " << deviceName << ", " << amazondeviceName << endl; - } - } - catch (exception& e) - { - cout << endl << "**** getSystemDbrootConfig Failed : " << e.what() << endl; - } - - // print un-assigned dbroots - DBRootConfigList::iterator pt1 = undbrootlist.begin(); - - for ( ; pt1 != undbrootlist.end() ; pt1++) - { - string volumeNameID = "PMVolumeName" + oam.itoa(*pt1); - string volumeName = oam::UnassignedName; - string deviceNameID = "PMVolumeDeviceName" + oam.itoa(*pt1); - string deviceName = oam::UnassignedName; - string amazonDeviceNameID = "PMVolumeAmazonDeviceName" + oam.itoa(*pt1); - string amazondeviceName = oam::UnassignedName; - - try - { - oam.getSystemConfig( volumeNameID, volumeName); - oam.getSystemConfig( deviceNameID, deviceName); - oam.getSystemConfig( amazonDeviceNameID, amazondeviceName); - } - catch (...) - { - continue; - } - - cout << "Amazon EC2 Volume Name/Device Name/Amazon Device Name for DBRoot" << oam.itoa(*pt1) << ": " << volumeName << ", " << deviceName << ", " << amazondeviceName << endl; - } - } - - string GlusterConfig; - string GlusterCopies; - string GlusterStorageType; - - try - { - oam.getSystemConfig("GlusterConfig", GlusterConfig); - oam.getSystemConfig("GlusterCopies", GlusterCopies); - oam.getSystemConfig("GlusterStorageType", GlusterStorageType); - } - catch (...) {} - - if ( GlusterConfig == "y" ) - { - cout << endl << "Data Redundant Configuration" << endl << endl; - cout << "Copies Per DBroot = " << GlusterCopies << endl; - cout << "Storage Type = " << GlusterStorageType << endl; - - oamModuleInfo_t st; - string moduleType; - - try - { - st = oam.getModuleInfo(); - moduleType = boost::get<1>(st); - } - catch (...) {} - - if ( moduleType != "pm") - break; - - try - { - DBRootConfigList dbrootConfigList; - oam.getSystemDbrootConfig(dbrootConfigList); - - DBRootConfigList::iterator pt = dbrootConfigList.begin(); - - for ( ; pt != dbrootConfigList.end() ; pt++) - { - cout << "DBRoot #" << oam.itoa(*pt) << " has copies on PMs = "; - - string pmList = ""; - - try - { - string errmsg; - oam.glusterctl(oam::GLUSTER_WHOHAS, oam.itoa(*pt), pmList, errmsg); - } - catch (...) - {} - - boost::char_separator sep(" "); - boost::tokenizer< boost::char_separator > tokens(pmList, sep); - - for ( boost::tokenizer< boost::char_separator >::iterator it = tokens.begin(); - it != tokens.end(); - ++it) - { - cout << *it << " "; - } - - cout << endl; - } - - cout << endl; - } - catch (exception& e) - { - cout << endl << "**** getSystemDbrootConfig Failed : " << e.what() << endl; - } - } - } - catch (exception& e) - { - cout << endl << "**** getStorageConfig Failed : " << e.what() << endl; - } - - cout << endl; - - break; - } - - case 14: // addDbroot parameters: dbroot-number - { - string GlusterConfig = "n"; - - try - { - oam.getSystemConfig( "GlusterConfig", GlusterConfig); - } - catch (...) - {} - - if (GlusterConfig == "y") - { - cout << endl << "**** addDbroot Not Supported on Data Redundancy Configured System, use addModule command to expand your capacity" << endl; - break; - } - - if ( localModule != parentOAMModule ) - { - // exit out since not on active module - cout << endl << "**** addDbroot Failed : Can only run command on Active OAM Parent Module (" << parentOAMModule << ")." << endl; - break; - } - - string cloud; - bool amazon = false; - - try - { - oam.getSystemConfig("Cloud", cloud); - } - catch (...) {} - - string::size_type pos = cloud.find("amazon", 0); - - if (pos != string::npos) - amazon = true; - - if (arguments[1] == "") - { - // need atleast 1 arguments - cout << endl << "**** addDbroot Failed : Missing a required Parameter, enter 'help' for additional information" << endl; - break; - } - - int dbrootNumber = atoi(arguments[1].c_str()); - - string DBRootStorageType; - - try - { - oam.getSystemConfig( "DBRootStorageType", DBRootStorageType); - } - catch (...) {} - - string EBSsize = oam::UnassignedName; - - if (amazon && DBRootStorageType == "external" ) - { - if ( arguments[2] != "") - EBSsize = arguments[2]; - else - { - cout << endl; - oam.getSystemConfig("PMVolumeSize", EBSsize); - - string prompt = "Enter EBS storage size in GB, current setting is " + EBSsize + " : "; - EBSsize = dataPrompt(prompt); - } - } - - //get dbroots ids for reside PM - try - { - DBRootConfigList dbrootlist; - oam.addDbroot(dbrootNumber, dbrootlist, EBSsize); - - cout << endl << " New DBRoot IDs added = "; - - DBRootConfigList::iterator pt = dbrootlist.begin(); - - for ( ; pt != dbrootlist.end() ;) - { - cout << oam.itoa(*pt); - pt++; - - if (pt != dbrootlist.end()) - cout << ", "; - } - - cout << endl; - } - catch (exception& e) - { - cout << endl << "**** addDbroot Failed: " << e.what() << endl; - break; - } - - cout << endl; - } - break; - - case 15: // removeDbroot parameters: dbroot-list - { - string GlusterConfig = "n"; - - try - { - oam.getSystemConfig( "GlusterConfig", GlusterConfig); - } - catch (...) - {} - - if ( localModule != parentOAMModule ) - { - // exit out since not on active module - cout << endl << "**** removeDbroot Failed : Can only run command on Active OAM Parent Module (" << parentOAMModule << ")." << endl; - break; - } - - if (arguments[1] == "") - { - // need atleast 1 arguments - cout << endl << "**** removeDbroot Failed : Missing a required Parameter, enter 'help' for additional information" << endl; - break; - } - - SystemStatus systemstatus; - - try - { - oam.getSystemStatus(systemstatus); - - if (systemstatus.SystemOpState != oam::ACTIVE ) - { - cout << endl << "**** removeDbroot Failed, System has to be in a ACTIVE state" << endl; - break; - } - } - catch (exception& e) - { - cout << endl << "**** removeDbroot Failed : " << e.what() << endl; - break; - } - catch (...) - { - cout << endl << "**** removeDbroot Failed, Failed return from getSystemStatus API" << endl; - break; - } - - systemStorageInfo_t t; - - try - { - t = oam.getStorageConfig(); - } - catch (...) {} - - string dbrootIDs = arguments[1]; - - DBRootConfigList dbrootlist; - - bool assign = false; - boost::char_separator sep(", "); - boost::tokenizer< boost::char_separator > tokens(dbrootIDs, sep); - - for ( boost::tokenizer< boost::char_separator >::iterator it = tokens.begin(); - it != tokens.end(); - ++it) - { - //check if dbroot is assigned to a pm - DeviceDBRootList moduledbrootlist = boost::get<2>(t); - - DeviceDBRootList::iterator pt = moduledbrootlist.begin(); - - for ( ; pt != moduledbrootlist.end() ; pt++) - { - DBRootConfigList::iterator pt1 = (*pt).dbrootConfigList.begin(); - - for ( ; pt1 != (*pt).dbrootConfigList.end() ; pt1++) - { - if ( atoi((*it).c_str()) == *pt1 ) - { - cout << endl << "**** removeDbroot Failed, dbroot " << *it << " is assigned to a module, unassign first before removing" << endl; - assign = true; - break; - } - } - } - - if (assign) - break; - - dbrootlist.push_back(atoi((*it).c_str())); - } - - if (assign) - break; - - cout << endl; - - try - { - oam.removeDbroot(dbrootlist); - - cout << endl << " Successful Removal of DBRoots " << endl << endl; - } - catch (exception& e) - { - cout << endl << "**** removeDbroot Failed: " << e.what() << endl; - break; - } - } - break; - - case 16: // stopSystem - parameters: graceful flag, Ack flag - { - BRM::DBRM dbrm; - bool bDBRMReady = dbrm.isDBRMReady(); - getFlags(arguments, gracefulTemp, ackTemp, suspendAnswer, bNeedsConfirm); - - if ( gracefulTemp == INSTALL ) - { - cout << endl << "Invalid Parameter, INSTALL option not supported. Please use shutdownSystem Command" << endl << endl; - break; - } - - cout << endl << "This command stops the processing of applications on all Modules within the Calpont System" << endl; - - try - { - cout << endl << " Checking for active transactions" << endl; - - if (gracefulTemp != GRACEFUL || - !bDBRMReady || - dbrm.isReadWrite()) - { - suspendAnswer = FORCE; - } - - if (suspendAnswer == CANCEL) // We don't have an answer from the command line or some other state. - { - // If there are bulkloads, ddl or dml happening, Ask what to do. - bool bIsDbrmUp = true; - execplan::SessionManager sessionManager; - BRM::SIDTIDEntry blockingsid; - std::vector tableLocks = dbrm.getAllTableLocks(); - bool bActiveTransactions = false; - - if (!tableLocks.empty()) - { - oam.DisplayLockedTables(tableLocks, &dbrm); - bActiveTransactions = true; - } - - if (sessionManager.checkActiveTransaction(0, bIsDbrmUp, blockingsid)) - { - cout << endl << "There are active transactions being processed" << endl; - bActiveTransactions = true; - } - - if (bActiveTransactions) - { - suspendAnswer = AskSuspendQuestion(CmdID); - // if (suspendAnswer == FORCE) - // { - // if (confirmPrompt("Force may cause data problems and should only be used in extreme circumstances")) - // { - // break; - // } - // } - bNeedsConfirm = false; - } - else - { - suspendAnswer = FORCE; - } - } - - if (suspendAnswer == CANCEL) - { - // We're outa here. - break; - } - - if (bNeedsConfirm) - { - if (confirmPrompt("")) - break; - } - - switch (suspendAnswer) - { - case WAIT: - cout << endl << " Waiting for all transactions to complete" << flush; - dbrm.setSystemShutdownPending(true, false, false); - gracefulTemp = GRACEFUL_WAIT; // Causes procmgr to wait for all table locks to free and all transactions to finish before shutdown - break; - - case ROLLBACK: - cout << endl << " Rollback of all transactions" << flush; - dbrm.setSystemShutdownPending(true, true, false); - gracefulTemp = GRACEFUL_WAIT; // Causes procmgr to wait for all table locks to free and all transactions to finish before shutdown - break; - - case FORCE: - cout << endl << " System being stopped now..." << flush; - - if (bDBRMReady) - { - dbrm.setSystemShutdownPending(true, false, true); - } - - break; - - case CANCEL: - break; - } - - oam.stopSystem(gracefulTemp, ackTemp); - - if ( waitForStop() ) - cout << endl << " Successful stop of System " << endl << endl; - else - cout << endl << "**** stopSystem Failed : check log files" << endl; - - checkForDisabledModules(); - } - catch (exception& e) - { - string Failed = e.what(); - - if (Failed.find("Connection refused") != string::npos) - { - cout << endl << "**** stopSystem Failure : ProcessManager not Active" << endl; - cout << "Retry or Run 'shutdownSystem FORCEFUL' command" << endl << endl; - } - else - { - cout << endl << "**** stopSystem Failure : " << e.what() << endl; - cout << "Retry or Run 'shutdownSystem FORCEFUL' command" << endl << endl; - } - } - } - break; - - case 17: // shutdownSystem - parameters: graceful flag, Ack flag, suspendAnswer - { - BRM::DBRM dbrm; - bool bDBRMReady = dbrm.isDBRMReady(); - getFlags(arguments, gracefulTemp, ackTemp, suspendAnswer, bNeedsConfirm); - - cout << endl << "This command stops the processing of applications on all Modules within the Calpont System" << endl; - - try - { - cout << endl << " Checking for active transactions" << endl; - - if (gracefulTemp != GRACEFUL || - !bDBRMReady || - dbrm.isReadWrite()) - { - suspendAnswer = FORCE; - } - - if (suspendAnswer == CANCEL) // We don't have an answer from the command line. - { - // If there are bulkloads, ddl or dml happening, Ask what to do. - bool bIsDbrmUp = true; - execplan::SessionManager sessionManager; - BRM::SIDTIDEntry blockingsid; - std::vector tableLocks = dbrm.getAllTableLocks(); - bool bActiveTransactions = false; - - if (!tableLocks.empty()) - { - oam.DisplayLockedTables(tableLocks, &dbrm); - bActiveTransactions = true; - } - - if (sessionManager.checkActiveTransaction(0, bIsDbrmUp, blockingsid)) - { - cout << endl << " There are active transactions being processed" << endl; - bActiveTransactions = true; - } - - if (bActiveTransactions) - { - suspendAnswer = AskSuspendQuestion(CmdID); - bNeedsConfirm = false; - } - else - { - suspendAnswer = FORCE; - } - } - - if (suspendAnswer == CANCEL) - { - // We're outa here. - break; - } - - if (bNeedsConfirm) - { - if (confirmPrompt("")) - break; - } - - switch (suspendAnswer) - { - case WAIT: - cout << endl << " Waiting for all transactions to complete" << flush; - dbrm.setSystemShutdownPending(true, false, false); - gracefulTemp = GRACEFUL_WAIT; // Causes procmgr to wait for all table locks to free and all transactions to finish before shutdown - break; - - case ROLLBACK: - cout << endl << " Rollback of all transactions" << flush; - dbrm.setSystemShutdownPending(true, true, false); - gracefulTemp = GRACEFUL_WAIT; // Causes procmgr to wait for all table locks to free and all transactions to finish before shutdown - break; - - case FORCE: - cout << endl << " Stopping System..." << flush; - - if (bDBRMReady) - { - dbrm.setSystemShutdownPending(true, false, true); - } - - break; - - case CANCEL: - break; - } - - // This won't return until the system is shutdown. It might take a while to finish what we're working on first. - - oam.stopSystem(gracefulTemp, ackTemp); - - if ( waitForStop() ) - cout << endl << " Successful stop of System " << endl; - else - cout << endl << "**** stopSystem Failed : check log files" << endl; - - cout << endl << " Shutting Down System..." << flush; - - oam.shutdownSystem(gracefulTemp, ackTemp); - - //hdfs / hadoop config - string DBRootStorageType; - - try - { - oam.getSystemConfig( "DBRootStorageType", DBRootStorageType); - } - catch (...) {} - - if ( DBRootStorageType == "hdfs") - { - string cmd = "pdsh -a '/" + startup::StartUp::installDir() + "/bin/infinidb stop' > /tmp/cc-stop.pdsh 2>&1"; - system(cmd.c_str()); - - if (oam.checkLogStatus("/tmp/cc-stop.pdsh", "exit") ) - { - cout << endl << "ERROR: Stopping InfiniDB Service failure, check /tmp/cc-stop.pdsh. exit..." << endl; - } - } - else - { - string cmd = startup::StartUp::installDir() + "/bin/infinidb stop > /tmp/status.log"; - system(cmd.c_str()); - } - } - catch (exception& e) - { - string Failed = e.what(); - - if ( gracefulTemp == FORCEFUL ) - { - string cmd = startup::StartUp::installDir() + "/bin/infinidb stop > /tmp/status.log"; - system(cmd.c_str()); - cout << endl << " Successful shutdown of System (stopped local infinidb service) " << endl << endl; - } - - if (Failed.find("Connection refused") != string::npos) - { - cout << endl << "**** shutdownSystem Error : ProcessManager not Active, stopping infinidb service" << endl; - string cmd = startup::StartUp::installDir() + "/bin/infinidb stop > /tmp/status.log"; - system(cmd.c_str()); - cout << endl << " Successful stop of local infinidb service " << endl << endl; - } - else - { - cout << endl << "**** shutdownSystem Failure : " << e.what() << endl; - cout << "Retry using FORCEFUL option" << endl << endl; - } - - //hdfs / hadoop config - string DBRootStorageType; - - try - { - oam.getSystemConfig( "DBRootStorageType", DBRootStorageType); - } - catch (...) {} - - if ( DBRootStorageType == "hdfs") - { - string cmd = "pdsh -a '" + startup::StartUp::installDir() + "/bin/infinidb stop' > /tmp/cc-stop.pdsh 2>&1"; - system(cmd.c_str()); - - if (oam.checkLogStatus("/tmp/cc-stop.pdsh", "exit") ) - { - cout << endl << "ERROR: Stopping InfiniDB Service failure, check /tmp/cc-stop.pdsh. exit..." << endl; - break; - } - } - } - - sleep(10); - } - break; - - case 18: // startSystem - parameters: Ack flag - { - // startSystem Command - - //don't start if a disable module has a dbroot assigned to it - if (!checkForDisabledModules()) - { - cout << endl << "Error: startSystem command can't be performed: disabled module has a dbroot assigned to it" << endl; - break; - } - - // if infinidb service is down, then start system by starting all of the infinidb services - // this would be used after a shutdownSystem command - // if infinidb service is up, send message to ProcMgr to start system (which starts all processes) - - string cmd = startup::StartUp::installDir() + "/bin/infinidb status > /tmp/status.log"; - system(cmd.c_str()); - - if (!oam.checkLogStatus("/tmp/status.log", "InfiniDB is running") ) - { - cout << "startSystem command, 'infinidb' service is down, sending command to" << endl; - cout << "start the 'infinidb' service on all modules" << endl << endl; - - SystemModuleTypeConfig systemmoduletypeconfig; - ModuleTypeConfig moduletypeconfig; - ModuleConfig moduleconfig; - systemmoduletypeconfig.moduletypeconfig.clear(); - int systemModuleNumber = 0; - - try - { - oam.getSystemConfig(systemmoduletypeconfig); - - for ( unsigned int i = 0 ; i < systemmoduletypeconfig.moduletypeconfig.size(); i++) - { - if ( systemmoduletypeconfig.moduletypeconfig[i].ModuleType.empty() ) - // end of list - break; - - systemModuleNumber = systemModuleNumber + systemmoduletypeconfig.moduletypeconfig[i].ModuleCount; - } - } - catch (exception& e) - { - cout << endl << "**** startSystem Failed = " << e.what() << endl; - break; - } - - if ( systemModuleNumber > 1 ) - { - if (arguments[1] != "") - password = arguments[1]; - else - password = "ssh"; - - // - // perform start of InfiniDB of other servers in the system - // - - DeviceNetworkList::iterator pt; - string modulename; - - for ( unsigned int i = 0 ; i < systemmoduletypeconfig.moduletypeconfig.size(); i++) - { - for (pt = systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.begin(); - pt != systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.end(); - ++pt) - { - modulename = (*pt).DeviceName; - - if ( (*pt).DisableState == oam::MANDISABLEDSTATE || - (*pt).DisableState == oam::AUTODISABLEDSTATE ) - { - cout << " Module '" << modulename << "' is disabled and will not be started" << endl; - } - } - } - - cout << endl << " System being started, please wait..."; - cout.flush(); - bool FAILED = false; - - //hdfs / hadoop config - string DBRootStorageType; - - try - { - oam.getSystemConfig( "DBRootStorageType", DBRootStorageType); - } - catch (...) {} - - if ( DBRootStorageType == "hdfs") - { - string cmd = "pdsh -a '" + startup::StartUp::installDir() + "/bin/infinidb restart' > /tmp/cc-restart.pdsh 2>&1"; - system(cmd.c_str()); - - if (oam.checkLogStatus("/tmp/cc-restart.pdsh", "exit") ) - { - cout << endl << "ERROR: Restart InfiniDB Service failure, check /tmp/cc-restart.pdsh. exit..." << endl; - break; - } - } - else - { - for ( unsigned int i = 0 ; i < systemmoduletypeconfig.moduletypeconfig.size(); i++) - { - if ( systemmoduletypeconfig.moduletypeconfig[i].ModuleType.empty() ) - // end of list - break; - - int moduleCount = systemmoduletypeconfig.moduletypeconfig[i].ModuleCount; - - if ( moduleCount == 0 ) - // skip if no modules - continue; - - for (pt = systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.begin(); - pt != systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.end(); - ++pt) - { - modulename = (*pt).DeviceName; - - if ( (*pt).DisableState == oam::MANDISABLEDSTATE || - (*pt).DisableState == oam::AUTODISABLEDSTATE ) - { - continue; - } - - if ( modulename == localModule ) - { - cmd = startup::StartUp::installDir() + "/bin/infinidb restart > /tmp/start.log 2>&1"; - int rtnCode = system(cmd.c_str()); - - if (geteuid() == 0 && WEXITSTATUS(rtnCode) != 0) - { - cout << endl << "error with running 'infinidb restart' on local module " << endl; - cout << endl << "**** startSystem Failed" << endl; - break; - } - - continue; - } - - HostConfigList::iterator pt1 = (*pt).hostConfigList.begin(); - - for ( ; pt1 != (*pt).hostConfigList.end() ; pt1++) - { - //run remote command script - cmd = startup::StartUp::installDir() + "/bin/remote_command.sh " + (*pt1).IPAddr + " " + password + " '" + startup::StartUp::installDir() + "/bin/infinidb restart' 0"; - int rtnCode = system(cmd.c_str()); - - if (WEXITSTATUS(rtnCode) < 0) - { - cout << endl << "error with running 'infinidb start' on module " + modulename << endl; - cout << endl << "**** startSystem Failed" << endl; - - // stop local infinidb service - cmd = startup::StartUp::installDir() + "/bin/infinidb stop > /tmp/stop.log 2>&1"; - system(cmd.c_str()); - - FAILED = true; - break; - } - else - { - if (rtnCode > 0) - { - cout << endl << "Invalid Password when running 'infinidb start' on module " + modulename << ", can retry by providing password as the second argument" << endl; - cout << endl << "**** startSystem Failed" << endl; - - // stop local infinidb service - cmd = startup::StartUp::installDir() + "/bin/infinidb stop > /tmp/stop.log 2>&1"; - system(cmd.c_str()); - - FAILED = true; - break; - } - } - } - - if (FAILED) - break; - } - } - - if (FAILED) - break; - } - - if (FAILED) - break; - } - else - { - //just kick off local server - cout << " System being started, please wait..."; - cout.flush(); - cmd = startup::StartUp::installDir() + "/bin/infinidb restart > /tmp/start.log 2>&1"; - int rtnCode = system(cmd.c_str()); - - if (geteuid() == 0 && WEXITSTATUS(rtnCode) != 0) - { - cout << endl << "error with running 'infinidb restart' on local module " << endl; - cout << endl << "**** startSystem Failed" << endl; - break; - } - } - - if ( waitForActive() ) - cout << endl << " Successful start of System " << endl << endl; - else - cout << endl << "**** startSystem Failed : check log files" << endl; - } - else - { - getFlags(arguments, gracefulTemp, ackTemp, suspendAnswer, bNeedsConfirm); - - try - { - cout << " System being started, please wait..."; - cout.flush(); - oam.startSystem(ackTemp); - - if ( waitForActive() ) - cout << endl << " Successful start of System " << endl << endl; - else - cout << endl << "**** startSystem Failed : check log files" << endl; - } - catch (exception& e) - { - cout << endl << "**** startSystem Failed : " << e.what() << endl; - string Failed = e.what(); - - if (Failed.find("Database Test Error") != string::npos) - cout << "Database Test Error occurred, check Alarm and Logs for addition Information" << endl; - } - } - } - break; - - case 19: // restartSystem - parameters: graceful flag, Ack flag - { - getFlags(arguments, gracefulTemp, ackTemp, suspendAnswer, bNeedsConfirm, &password); - - //don't start if a disable module has a dbroot assigned to it - if (!checkForDisabledModules()) - { - cout << endl << "Error: restartSystem command can't be performed: disabled module has a dbroot assigned to it" << endl; - break; - } - - // if infinidb service is down, then start system by starting all of the infinidb services - // this would be used after a shutdownSystem command - // if infinidb service is up, send message to ProcMgr to start system (which starts all processes) - - string cmd = startup::StartUp::installDir() + "/bin/infinidb status > /tmp/status.log"; - system(cmd.c_str()); - - if (!oam.checkLogStatus("/tmp/status.log", "InfiniDB is running") ) - { - if (bNeedsConfirm) - { - if (confirmPrompt("")) // returns true if user wants to quit. - break; - } - - cout << "restartSystem command, 'infinidb' service is down, sending command to" << endl; - cout << "start the 'infinidb' service on all modules" << endl << endl; - - SystemModuleTypeConfig systemmoduletypeconfig; - ModuleTypeConfig moduletypeconfig; - ModuleConfig moduleconfig; - systemmoduletypeconfig.moduletypeconfig.clear(); - int systemModuleNumber = 0; - - try - { - oam.getSystemConfig(systemmoduletypeconfig); - - for ( unsigned int i = 0 ; i < systemmoduletypeconfig.moduletypeconfig.size(); i++) - { - if ( systemmoduletypeconfig.moduletypeconfig[i].ModuleType.empty() ) - // end of list - break; - - systemModuleNumber = systemModuleNumber + systemmoduletypeconfig.moduletypeconfig[i].ModuleCount; - } - } - catch (exception& e) - { - cout << endl << "**** restartSystem Failed = " << e.what() << endl; - break; - } - - if ( systemModuleNumber > 1 ) - { - if (password.empty()) - password = "ssh"; - - // - // perform start of InfiniDB of other servers in the system - // - - DeviceNetworkList::iterator pt; - string modulename; - - for ( unsigned int i = 0 ; i < systemmoduletypeconfig.moduletypeconfig.size(); i++) - { - for (pt = systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.begin(); - pt != systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.end(); - ++pt) - { - modulename = (*pt).DeviceName; - - if ( (*pt).DisableState == oam::MANDISABLEDSTATE || - (*pt).DisableState == oam::AUTODISABLEDSTATE ) - { - cout << " Module '" << modulename << "' is disabled and will not be started" << endl; - } - } - } - - cout << endl << " System being started, please wait..."; - cout.flush(); - bool FAILED = false; - - //hdfs / hadoop config - string DBRootStorageType; - - try - { - oam.getSystemConfig( "DBRootStorageType", DBRootStorageType); - } - catch (...) {} - - if ( DBRootStorageType == "hdfs") - { - string cmd = "pdsh -a '" + startup::StartUp::installDir() + "/bin/infinidb restart' > /tmp/cc-restart.pdsh 2>&1"; - system(cmd.c_str()); - - if (oam.checkLogStatus("/tmp/cc-restart.pdsh", "exit") ) - { - cout << endl << "ERROR: Restart InfiniDB Service failue, check /tmp/cc-restart.pdsh. exit..." << endl; - break; - } - } - else - { - for ( unsigned int i = 0 ; i < systemmoduletypeconfig.moduletypeconfig.size(); i++) - { - if ( systemmoduletypeconfig.moduletypeconfig[i].ModuleType.empty() ) - // end of list - break; - - int moduleCount = systemmoduletypeconfig.moduletypeconfig[i].ModuleCount; - - if ( moduleCount == 0 ) - // skip if no modules - continue; - - for (pt = systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.begin(); - pt != systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.end(); - ++pt) - { - modulename = (*pt).DeviceName; - - if ( (*pt).DisableState == oam::MANDISABLEDSTATE || - (*pt).DisableState == oam::AUTODISABLEDSTATE ) - { - continue; - } - - if ( modulename == localModule ) - continue; // do last - - HostConfigList::iterator pt1 = (*pt).hostConfigList.begin(); - - for ( ; pt1 != (*pt).hostConfigList.end() ; pt1++) - { - //run remote command script - cmd = startup::StartUp::installDir() + "/bin/remote_command.sh " + (*pt1).IPAddr + " " + password + " '" + startup::StartUp::installDir() + "/bin/infinidb restart' 0"; - - int rtnCode = system(cmd.c_str()); - - if (WEXITSTATUS(rtnCode) < 0) - { - cout << endl << "error with running 'infinidb start' on module " + modulename << endl; - cout << endl << "**** restartSystem Failed" << endl; - - // stop local infinidb service - cmd = startup::StartUp::installDir() + "/bin/infinidb stop > /tmp/stop.log 2>&1"; - system(cmd.c_str()); - - FAILED = true; - break; - } - else - { - if (rtnCode > 0) - { - cout << endl << "Invalid Password when running 'infinidb start' on module " + modulename << ", can retry by providing password as the second argument" << endl; - cout << endl << "**** restartSystem Failed" << endl; - FAILED = true; - - // stop local infinidb service - cmd = startup::StartUp::installDir() + "/bin/infinidb stop > /tmp/stop.log 2>&1"; - system(cmd.c_str()); - - break; - } - } - } - - if (FAILED) - break; - } - - if (FAILED) - break; - - //RESTART LOCAL HOST - cmd = startup::StartUp::installDir() + "/bin/infinidb restart > /tmp/start.log 2>&1"; - int rtnCode = system(cmd.c_str()); - - if (geteuid() == 0 && WEXITSTATUS(rtnCode) != 0) - { - cout << endl << "error with running 'infinidb restart' on local module " << endl; - cout << endl << "**** restartSystem Failed" << endl; - break; - } - } - - if (FAILED) - break; - } - } - else - { - //just kick off local server - cout << " System being restarted, please wait..."; - cout.flush(); - string cmd = startup::StartUp::installDir() + "/bin/infinidb restart > /tmp/start.log 2>&1"; - int rtnCode = system(cmd.c_str()); - - if (WEXITSTATUS(rtnCode) != 0) - { - cout << endl << "error with running 'infinidb start' on local module " << endl; - cout << endl << "**** restartSystem Failed" << endl; - break; - } - } - - if ( waitForActive() ) - cout << endl << " Successful restart of System " << endl << endl; - else - cout << endl << "**** restartSystem Failed : check log files" << endl; - } - else - { - BRM::DBRM dbrm; - bool bDBRMReady = dbrm.isDBRMReady(); - - try - { - if (gracefulTemp != GRACEFUL || - !bDBRMReady || - dbrm.isReadWrite()) - { - suspendAnswer = FORCE; - } - - if (suspendAnswer == CANCEL) // We don't have an answer from the command line. - { - // If there are bulkloads, ddl or dml happening, Ask what to do. - bool bIsDbrmUp = true; - execplan::SessionManager sessionManager; - BRM::SIDTIDEntry blockingsid; - std::vector tableLocks = dbrm.getAllTableLocks(); - bool bActiveTransactions = false; - - if (!tableLocks.empty()) - { - oam.DisplayLockedTables(tableLocks, &dbrm); - bActiveTransactions = true; - } - - if (sessionManager.checkActiveTransaction(0, bIsDbrmUp, blockingsid)) - { - cout << endl << "There are active transactions being processed" << endl; - bActiveTransactions = true; - } - - if (bActiveTransactions) - { - suspendAnswer = AskSuspendQuestion(CmdID); - // if (suspendAnswer == FORCE) - // { - // if (confirmPrompt("Force may cause data problems and should only be used in extreme circumstances")) - // { - // break; - // } - // } - bNeedsConfirm = false; - } - else - { - suspendAnswer = FORCE; - } - } - - if (suspendAnswer == CANCEL) - { - // We're outa here. - break; - } - - if (bNeedsConfirm) - { - if (confirmPrompt("")) - break; - } - - switch (suspendAnswer) - { - case WAIT: - cout << endl << " Waiting for all transactions to complete" << flush; - dbrm.setSystemShutdownPending(true, false, false); - gracefulTemp = GRACEFUL_WAIT; // Causes procmgr to wait for all table locks to free and all transactions to finish before shutdown - break; - - case ROLLBACK: - cout << endl << " Rollback of all transactions" << flush; - dbrm.setSystemShutdownPending(true, true, false); - gracefulTemp = GRACEFUL_WAIT; // Causes procmgr to wait for all table locks to free and all transactions to finish before shutdown - break; - - case FORCE: - cout << endl << " System being restarted now ..." << flush; - - if (bDBRMReady) - { - dbrm.setSystemShutdownPending(true, false, true); - } - - break; - - case CANCEL: - break; - } - - int returnStatus = oam.restartSystem(gracefulTemp, ackTemp); - - switch (returnStatus) - { - case API_SUCCESS: - if ( waitForActive() ) - cout << endl << " Successful restart of System " << endl << endl; - else - cout << endl << "**** restartSystem Failed : check log files" << endl; - - break; - - case API_CANCELLED: - cout << endl << " Restart of System canceled" << endl << endl; - break; - - default: - cout << endl << "**** restartSystem Failed : Check system logs" << endl; - break; - } - } - catch (exception& e) - { - cout << endl << "**** restartSystem Failed : " << e.what() << endl; - string Failed = e.what(); - - if (Failed.find("Database Test Error") != string::npos) - cout << "Database Test Error occurred, check Alarm and Logs for additional Information" << endl; - } - } - } - break; - - case 20: // getSystemStatus - parameters: NONE - { - try - { - printSystemStatus(); - } - catch (...) - { - break; - } - - } - break; - - case 21: // getProcessStatus - parameters: NONE - { - try - { - printProcessStatus(); - } - catch (...) - { - break; - } - } - break; - - case 22: // system - UNIX system command - { - if (arguments[1] == "") - { - // need arguments - cout << endl << "**** system Failed : Missing a required Parameter, enter 'help' for additional information" << endl; - break; - } - - for (int j = 2; j < ArgNum; j++) - { - arguments[1].append(" "); - arguments[1].append(arguments[j]); - } - - system (arguments[1].c_str()); - } - break; - - case 23: // getAlarmHistory - { - if (arguments[1] == "") - { - // need arguments - cout << endl << "**** getAlarmHistory Failed : Missing a required Parameter, enter 'help' for additional information" << endl; - break; - } - - if ( arguments[1].size() != 8 ) - { - cout << "date not in correct format, enter MM/DD/YY" << endl; - break; - } - - if ( !(arguments[1].substr(2, 1) == "/" && arguments[1].substr(5, 1) == "/") ) - { - cout << "date not in correct format, enter MM/DD/YY" << endl; - break; - } - - AlarmList alarmList; - - try - { - oam.getAlarms(arguments[1], alarmList); - } - catch (exception& e) - { - cout << endl << "**** getAlarms Failed = " << e.what() << endl; - break; - } - - cout << endl << "Historical Alarm List for " + arguments[1] + " :" << endl << endl; - - AlarmList :: iterator i; - int counter = 0; - - for (i = alarmList.begin(); i != alarmList.end(); ++i) - { - switch (i->second.getState()) - { - case SET: - cout << "SET" << endl; - break; - - case CLEAR: - cout << "CLEAR" << endl; - break; - } - - cout << "AlarmID = " << i->second.getAlarmID() << endl; - cout << "Brief Description = " << i->second.getDesc() << endl; - cout << "Alarm Severity = "; - - switch (i->second.getSeverity()) - { - case CRITICAL: - cout << "CRITICAL" << endl; - break; - - case MAJOR: - cout << "MAJOR" << endl; - break; - - case MINOR: - cout << "MINOR" << endl; - break; - - case WARNING: - cout << "WARNING" << endl; - break; - - case INFORMATIONAL: - cout << "INFORMATIONAL" << endl; - break; - } - - cout << "Time Issued = " << i->second.getTimestamp() << endl; - cout << "Reporting Module = " << i->second.getSname() << endl; - cout << "Reporting Process = " << i->second.getPname() << endl; - cout << "Reported Device = " << i->second.getComponentID() << endl << endl; - - counter++; - - if ( counter > 4 ) - { - // continue prompt - if (confirmPrompt("Displaying Alarm History")) - break; - - counter = 0; - } - } - } - break; - - case 24: // monitorAlarms - { - cout << endl << "Monitor for System Alarms" << endl; - cout << " Enter control-C to return to command line" << endl << endl; - - string cmd = "tail -n 0 -f " + snmpmanager::ALARM_FILE; - system(cmd.c_str()); - } - break; - - case 25: // resetAlarm - { - if (arguments[1] == "") - { - // need 3 arguments - cout << endl << "**** resetAlarm Failed : Missing a required Parameter, enter 'help' for additional information" << endl; - break; - } - - try - { - // check if requested alarm is Active - AlarmList alarmList; - Oam oam; - - try - { - oam.getActiveAlarms(alarmList); - } - catch (exception& e) - { - cout << endl << "**** getActiveAlarm Failed = " << e.what() << endl; - break; - } - - bool found = false; - AlarmList::iterator i; - - for (i = alarmList.begin(); i != alarmList.end(); ++i) - { - // check if matching ID - if ( arguments[1] != "ALL" ) - { - if (atoi(arguments[1].c_str()) != (i->second).getAlarmID() ) - continue; - - if ( arguments[2] != "ALL") - { - if (arguments[2].compare((i->second).getSname()) != 0) - continue; - - if ( arguments[3] != "ALL") - { - if (arguments[3].compare((i->second).getComponentID()) != 0 ) - continue; - } - } - } - - ALARMManager aManager; - aManager.sendAlarmReport((i->second).getComponentID().c_str(), - (i->second).getAlarmID(), - CLEAR, - (i->second).getSname(), - "calpontConsole"); - - cout << endl << " Alarm Successfully Reset: "; - cout << "ID = " << oam.itoa((i->second).getAlarmID()); - cout << " / Module = " << (i->second).getSname(); - cout << " / Device = " << (i->second).getComponentID() << endl; - found = true; - } - - // check is a SET alarm was found, if not return - if (!found) - { - cout << endl << "**** resetAlarm Failed : Requested Alarm is not Set" << endl; - break; - } - } - catch (exception& e) - { - cout << endl << "**** resetAlarm Failed = " << e.what() << endl; - break; - } - } - break; - - case 26: // enableLog - { - if (arguments[2] == "") - { - // need 2 arguments - cout << endl << "**** Failed : enableLog Missing a required Parameter, enter 'help' for additional information" << endl; - break; - } - - // covert second argument (level) into lowercase - transform (arguments[2].begin(), arguments[2].end(), arguments[2].begin(), to_lower()); - - try - { - oam.updateLog(ENABLEDSTATE, arguments[1], arguments[2]); - cout << endl << " Successful Enabling of Logging " << endl << endl; - } - catch (exception& e) - { - cout << endl << "**** enableLog Failed : " << e.what() << endl; - } - } - break; - - case 27: // disableLog - { - if (arguments[2] == "") - { - // need 2 arguments - cout << endl << "**** disableLog Failed : Missing a required Parameter, enter 'help' for additional information" << endl; - break; - } - - // covert second argument (level) into lowercase - transform (arguments[2].begin(), arguments[2].end(), arguments[2].begin(), to_lower()); - - try - { - oam.updateLog(MANDISABLEDSTATE, arguments[1], arguments[2]); - cout << endl << " Successful Disabling of Logging " << endl << endl; - } - catch (exception& e) - { - cout << endl << "**** disableLog Failed : " << e.what() << endl; - } - } - break; - - case 28: // switchParentOAMModule - { - BRM::DBRM dbrm; - bool bDBRMReady = dbrm.isDBRMReady(); - string module; - bool bUseHotStandby = true; - SystemStatus systemstatus; - Oam oam; - - //first check that the system is in a ACTIVE OR MAN_OFFLINE STATE - try - { - oam.getSystemStatus(systemstatus); - - if (systemstatus.SystemOpState == ACTIVE || - systemstatus.SystemOpState == MAN_OFFLINE) - { - module = ""; - } - else - { - cout << endl << "**** switchParentOAMModule Failed : System Status needs to be ACTIVE or MAN_OFFLINE" << endl; - break; - } - } - catch (...) - {} - - // First get the values for the standard arguments - getFlags(arguments, gracefulTemp, ackTemp, suspendAnswer, bNeedsConfirm); - - // Now check for arguments unique to this command. In this case, a valid - // module name. - for (int i = 1; i < ArgNum; i++) - { - if (arguments[i].size() > 0) - { - if (oam.validateModule(arguments[i]) == API_SUCCESS) - { - module = arguments[i]; - bUseHotStandby = false; - break; - } - } - } - - //check if there are more than 1 pm modules to start with - ModuleTypeConfig moduletypeconfig; - oam.getSystemConfig("pm", moduletypeconfig); - - if ( moduletypeconfig.ModuleCount < 2 ) - { - cout << endl << "**** switchParentOAMModule Failed : Command only support on systems with Multiple Performance Modules" << endl; -// break; - } - - string DBRootStorageType; - - try - { - oam.getSystemConfig("DBRootStorageType", DBRootStorageType); - } - catch (...) {} - - string GlusterConfig = "n"; - - try - { - oam.getSystemConfig( "GlusterConfig", GlusterConfig); - } - catch (...) - {} - - if (DBRootStorageType == "internal" && GlusterConfig == "n") - { - cout << endl << "**** switchParentOAMModule Failed : DBRoot Storage type = internal/non-data-replication" << endl; - break; - } - - string ParentOAMModuleName; - - try - { - oam.getSystemConfig("ParentOAMModuleName", ParentOAMModuleName); - } - catch (...) {} - - if (bUseHotStandby) - { - oam.getSystemConfig("StandbyOAMModuleName", module); - - if ( module.empty() || module == oam::UnassignedName ) - { - cout << endl << "**** switchParentOAMModule Failed : There's no hot standby defined" << endl << " enter a Performance Module" << endl; - break; - } - - cout << endl << "Switching to the Hot-Standby Parent OAM Module '" << module << "'" << endl; - } - else - { - parentOAMModule = getParentOAMModule(); - - if ( module == parentOAMModule ) - { - cout << endl << "**** switchParentOAMModule Failed : " << module << " is already the Active Parent OAM Module" << endl; - break; - } - - cout << endl << "Switching to the Performance Module '" << module << "'" << endl; - } - - //check for gluster system is do-able - if (GlusterConfig == "y") - { - // get to-module assigned DBRoots and see if current active PM - // has a copy - - DBRootConfigList toPMbrootConfigList; - - try - { - string moduleID = module.substr(MAX_MODULE_TYPE_SIZE, MAX_MODULE_ID_SIZE); - oam.getPmDbrootConfig(atoi(moduleID.c_str()), toPMbrootConfigList); - - bool match = false; - DBRootConfigList::iterator pt = toPMbrootConfigList.begin(); - - for ( ; pt != toPMbrootConfigList.end() ; pt++) - { - // check if ACTIVE PM has a copy of Dbroot - string pmList = ""; - - try - { - string errmsg; - int ret = oam.glusterctl(oam::GLUSTER_WHOHAS, oam.itoa(*pt), pmList, errmsg); - - if ( ret != 0 ) - { - cout << endl << "**** switchParentOAMModule Failed : " << module << " glusterctl error" << endl; - break; - } - } - catch (...) - { - cout << endl << "**** switchParentOAMModule Failed : " << module << " glusterctl error" << endl; - break; - } - - boost::char_separator sep(" "); - boost::tokenizer< boost::char_separator > tokens(pmList, sep); - - for ( boost::tokenizer< boost::char_separator >::iterator it1 = tokens.begin(); - it1 != tokens.end(); - ++it1) - { - string pmModule = "pm" + *it1; - - if ( pmModule == ParentOAMModuleName ) - { - match = true; - break; - } - } - } - - if (!match) - { - cout << endl << "**** switchParentOAMModule Failed : The Current Active PM doesn't have a copy of any DBROOTs that reside on the Siwtching PM " << endl; - break; - } - - //check if switching to PM has DBROOT 1 - string pmList = ""; - - try - { - string errmsg; - int ret = oam.glusterctl(oam::GLUSTER_WHOHAS, "1", pmList, errmsg); - - if ( ret != 0 ) - { - cout << endl << "**** switchParentOAMModule Failed : " << module << " glusterctl error" << endl; - break; - } - } - catch (...) - { - cout << endl << "**** switchParentOAMModule Failed : " << module << " glusterctl error" << endl; - break; - } - - match = false; - boost::char_separator sep(" "); - boost::tokenizer< boost::char_separator > tokens(pmList, sep); - - for ( boost::tokenizer< boost::char_separator >::iterator it1 = tokens.begin(); - it1 != tokens.end(); - ++it1) - { - string pmModule = "pm" + *it1; - - if ( pmModule == module ) - { - match = true; - break; - } - } - - if (!match) - { - cout << endl << "**** switchParentOAMModule Failed : The Switching to PM doesn't have a copy of the DBROOT #1" << endl; - break; - } - } - catch (exception& e) - { - cout << endl << "**** getPmDbrootConfig Failed for '" << module << "' : " << e.what() << endl; - break; - } - } - - - if (bNeedsConfirm) - { - // confirm request - if (confirmPrompt("This command switches the Active Parent OAM Module and should only be executed on an idle system.")) - break; - } - - string MySQLRep; - string MySQLPasswordConfig; - - try - { - oam.getSystemConfig("MySQLRep", MySQLRep); - oam.getSystemConfig("MySQLPasswordConfig", MySQLPasswordConfig); - } - catch (...) {} - - if ( MySQLRep == "y" && MySQLPasswordConfig == oam::UnassignedName ) - { - cout << endl; - string prompt = "MySQL Replication is enabled, is there a 'MySQL' Password configured in " + HOME + "/.my.cnf (y,n): "; - MySQLPasswordConfig = dataPrompt(prompt); - } - - if ( MySQLPasswordConfig != "y" ) - MySQLPasswordConfig = "n"; - - try - { - oam.setSystemConfig("MySQLPasswordConfig", MySQLPasswordConfig); - } - catch (...) {} - - try - { - cout << endl << " Check for active transactions" << endl; - - if (!bDBRMReady || - dbrm.isReadWrite() != 0) - { - suspendAnswer = FORCE; - } - - if (suspendAnswer == CANCEL) // We don't have an answer from the command line. - { - // If there are bulkloads, ddl or dml happening, Ask what to do. - bool bIsDbrmUp = true; - execplan::SessionManager sessionManager; - BRM::SIDTIDEntry blockingsid; - std::vector tableLocks = dbrm.getAllTableLocks(); - bool bActiveTransactions = false; - - if (!tableLocks.empty()) - { - oam.DisplayLockedTables(tableLocks, &dbrm); - bActiveTransactions = true; - } - - if (sessionManager.checkActiveTransaction(0, bIsDbrmUp, blockingsid)) - { - cout << endl << "There are active transactions being processed" << endl; - bActiveTransactions = true; - } - - if (bActiveTransactions) - { - suspendAnswer = AskSuspendQuestion(CmdID); - // if (suspendAnswer == FORCE) - // { - // if (confirmPrompt("Force may cause data problems and should only be used in extreme circumstances")) - // { - // break; - // } - // } - } - else - { - suspendAnswer = FORCE; - } - } - - if (suspendAnswer == CANCEL) - { - // We're outa here. - break; - } - - switch (suspendAnswer) - { - case WAIT: - cout << endl << " Waiting for all transactions to complete" << flush; - dbrm.setSystemShutdownPending(true, false, false); - gracefulTemp = GRACEFUL_WAIT; // Causes procmgr to wait for all table locks to free and all transactions to finish before shutdown - break; - - case ROLLBACK: - cout << endl << " Rollback of all transactions" << flush; - dbrm.setSystemShutdownPending(true, true, false); - gracefulTemp = GRACEFUL_WAIT; // Causes procmgr to wait for all table locks to free and all transactions to finish before shutdown - break; - - case FORCE: - cout << endl << " Switch Active Parent OAM Module starting..." << endl; - - if (bDBRMReady) - { - dbrm.setSystemShutdownPending(true, false, true); - } - - break; - - case CANCEL: - break; - } - - if (oam.switchParentOAMModule(module, gracefulTemp)) - { - if (waitForActive()) - { - // give time for new ProcMgr to go active - sleep (10); - cout << endl << " Successful Switch Active Parent OAM Module" << endl << endl; - } - else - cout << endl << "**** Switch Active Parent OAM Module failed : check log files" << endl; - } - else - { - // give time for new ProcMgr to go active - sleep (10); - cout << endl << " Successful Switch Active Parent OAM Module" << endl << endl; - } - } - catch (exception& e) - { - cout << endl << "**** switchParentOAMModule Failed : " << e.what() << endl; - break; - } - } - break; - - case 29: // getStorageStatus - { - SystemStatus systemstatus; - Oam oam; - - cout << "System External DBRoot Storage Statuses" << endl << endl; - cout << "Component Status Last Status Change" << endl; - cout << "------------ -------------------------- ------------------------" << endl; - - try - { - oam.getSystemStatus(systemstatus, false); - - if ( systemstatus.systemdbrootstatus.dbrootstatus.size() == 0 ) - { - cout << " No External DBRoot Storage Configured" << endl; - break; - } - - for ( unsigned int i = 0 ; i < systemstatus.systemdbrootstatus.dbrootstatus.size(); i++) - { - if ( systemstatus.systemdbrootstatus.dbrootstatus[i].Name.empty() ) - // end of list - break; - - cout << "DBRoot #"; - cout.setf(ios::left); - cout.width(6); - cout << systemstatus.systemdbrootstatus.dbrootstatus[i].Name; - cout.width(29); - int state = systemstatus.systemdbrootstatus.dbrootstatus[i].OpState; - printState(state, " "); - cout.width(24); - string stime = systemstatus.systemdbrootstatus.dbrootstatus[i].StateChangeDate ; - stime = stime.substr (0, 24); - cout << stime << endl; - } - - cout << endl; - } - catch (exception& e) - { - cout << endl << "**** getSystemStatus Failed = " << e.what() << endl; - } - } - break; - - case 30: // getLogConfig - { - try - { - SystemLogConfigData systemconfigdata; - LogConfigData logconfigdata; - - oam.getLogConfig(systemconfigdata); - - string configFileName; - oam.getSystemConfig("SystemLogConfigFile", configFileName); - - cout << endl << "Calpont System Log Configuration Data" << endl << endl; - - cout << "System Logging Configuration File being used: " << configFileName << endl << endl; - - cout << "Module Configured Log Levels" << endl; - cout << "------ ---------------------------------------" << endl; - - SystemLogConfigData::iterator pt = systemconfigdata.begin(); - - for (; pt != systemconfigdata.end() ; pt++) - { - logconfigdata = *pt; - string module = logconfigdata.moduleName; - int data = logconfigdata.configData; - - if ( data < API_MAX ) - { - // failure API status returned - cout.setf(ios::left); - cout.width(10); - cout << logconfigdata.moduleName; - cout << "getLogConfig Failed - Error : " << data << endl; - } - else - { - cout.setf(ios::left); - cout.width(10); - cout << logconfigdata.moduleName; - - data = data - API_MAX; - - if ( data == 0 ) - // no level configured - cout << "None Configured" << endl; - else - { - if ( ((data & LEVEL_CRITICAL) ? 1 : 0) == 1 ) - cout << "Critical "; - - if ( ((data & LEVEL_ERROR) ? 1 : 0) == 1 ) - cout << "Error "; - - if ( ((data & LEVEL_WARNING) ? 1 : 0) == 1 ) - cout << "Warning "; - - if ( ((data & LEVEL_INFO) ? 1 : 0) == 1 ) - cout << "Info "; - - if ( ((data & LEVEL_DEBUG) ? 1 : 0) == 1 ) - cout << "Debug "; - - if ( ((data & LEVEL_DATA) ? 1 : 0) == 1 ) - cout << "Data"; - - cout << endl; - } - } - } - } - catch (exception& e) - { - cout << endl << "**** getLogConfig Failed : " << e.what() << endl; - break; - } - - } - break; - - case 31: // movePmDbrootConfig parameters: pm-reside dbroot-list pm-to - { - if ( localModule != parentOAMModule ) - { - // exit out since not on active module - cout << endl << "**** movePmDbrootConfig Failed : Can only run command on Active OAM Parent Module (" << parentOAMModule << ")." << endl; - break; - } - - //check the system status / service status and only allow command when System is MAN_OFFLINE - string cmd = startup::StartUp::installDir() + "/bin/infinidb status > /tmp/status.log"; - system(cmd.c_str()); - - if (oam.checkLogStatus("/tmp/status.log", "InfiniDB is running") ) - { - SystemStatus systemstatus; - - try - { - oam.getSystemStatus(systemstatus); - - if (systemstatus.SystemOpState != oam::MAN_OFFLINE ) - { - cout << endl << "**** movePmDbrootConfig Failed, System has to be in a MAN_OFFLINE state, stop system first" << endl; - break; - } - } - catch (exception& e) - { - cout << endl << "**** movePmDbrootConfig Failed : " << e.what() << endl; - break; - } - catch (...) - { - cout << endl << "**** movePmDbrootConfig Failed, Failed return from getSystemStatus API" << endl; - break; - } - } - - if (arguments[3] == "") - { - // need arguments - cout << endl << "**** movePmDbrootConfig Failed : Missing a required Parameter, enter 'help' for additional information" << endl; - break; - } - - string residePM = arguments[1]; - string dbrootIDs = arguments[2]; - string toPM = arguments[3]; - - string residePMID = residePM.substr(MAX_MODULE_TYPE_SIZE, MAX_MODULE_ID_SIZE);; - string toPMID = toPM.substr(MAX_MODULE_TYPE_SIZE, MAX_MODULE_ID_SIZE);; - - // check module status - try - { - bool degraded; - int opState; - oam.getModuleStatus(toPM, opState, degraded); - - if (opState == oam::AUTO_DISABLED || - opState == oam::MAN_DISABLED) - { - cout << "**** movePmDbrootConfig Failed: " << toPM << " is DISABLED." << endl; - cout << "Run alterSystem-EnableModule to enable module" << endl; - break; - } - - if (opState == oam::FAILED) - { - cout << "**** movePmDbrootConfig Failed: " << toPM << " is in a FAILED state." << endl; - break; - } - } - catch (exception& ex) - {} - - bool moveDBRoot1 = false; - bool found = false; - boost::char_separator sep(", "); - boost::tokenizer< boost::char_separator > tokens(dbrootIDs, sep); - - for ( boost::tokenizer< boost::char_separator >::iterator it = tokens.begin(); - it != tokens.end(); - ++it) - { - if (*it == "1" ) - { - moveDBRoot1 = true; - break; - } - - //if gluster, check if toPM is has a copy - string GlusterConfig; - - try - { - oam.getSystemConfig("GlusterConfig", GlusterConfig); - } - catch (...) {} - - if ( GlusterConfig == "y" ) - { - string pmList = ""; - - try - { - string errmsg; - oam.glusterctl(oam::GLUSTER_WHOHAS, *it, pmList, errmsg); - } - catch (...) - {} - - boost::char_separator sep(" "); - boost::tokenizer< boost::char_separator > tokens(pmList, sep); - - for ( boost::tokenizer< boost::char_separator >::iterator it1 = tokens.begin(); - it1 != tokens.end(); - ++it1) - { - if ( *it1 == toPMID ) - { - found = true; - break; - } - } - - if (!found) - { - cout << endl << "**** movePmDbrootConfig Failed : Data Redundancy Configured, DBRoot #" << *it << " doesn't have a copy on " << toPM << endl; - cout << "Run getStorageConfig to get copy information" << endl << endl; - break; - } - } - else - found = true; - } - - if (moveDBRoot1) - { - cout << endl << "**** movePmDbrootConfig Failed : Can't move dbroot #1" << endl << endl; - break; - } - - if (!found) - { - break; - } - - - if (residePM.find("pm") == string::npos ) - { - cout << endl << "**** movePmDbrootConfig Failed : Parmameter 1 is not a Performance Module name, enter 'help' for additional information" << endl; - break; - } - - if (toPM.find("pm") == string::npos ) - { - cout << endl << "**** movePmDbrootConfig Failed : Parmameter 3 is not a Performance Module name, enter 'help' for additional information" << endl; - break; - } - - if (residePM == toPM ) - { - cout << endl << "**** movePmDbrootConfig Failed : Reside and To Performance Modules are the same" << endl; - break; - } - - //get dbroots ids for reside PM - DBRootConfigList residedbrootConfigList; - - try - { - oam.getPmDbrootConfig(atoi(residePMID.c_str()), residedbrootConfigList); - - cout << endl << "DBRoot IDs currently assigned to '" + residePM + "' = "; - - DBRootConfigList::iterator pt = residedbrootConfigList.begin(); - - for ( ; pt != residedbrootConfigList.end() ;) - { - cout << oam.itoa(*pt); - pt++; - - if (pt != residedbrootConfigList.end()) - cout << ", "; - } - - cout << endl; - } - catch (exception& e) - { - cout << endl << "**** getPmDbrootConfig Failed for '" << residePM << "' : " << e.what() << endl; - break; - } - - //get dbroots ids for reside PM - DBRootConfigList todbrootConfigList; - - try - { - oam.getPmDbrootConfig(atoi(toPMID.c_str()), todbrootConfigList); - - cout << "DBRoot IDs currently assigned to '" + toPM + "' = "; - - DBRootConfigList::iterator pt = todbrootConfigList.begin(); - - for ( ; pt != todbrootConfigList.end() ;) - { - cout << oam.itoa(*pt); - pt++; - - if (pt != todbrootConfigList.end()) - cout << ", "; - } - - cout << endl; - } - catch (exception& e) - { - cout << endl << "**** getPmDbrootConfig Failed for '" << toPM << "' : " << e.what() << endl; - break; - } - - cout << endl << "DBroot IDs being moved, please wait..." << endl << endl; - - try - { - oam.manualMovePmDbroot(residePM, dbrootIDs, toPM); - } - catch (...) - { - cout << endl << "**** manualMovePmDbroot Failed : API Failure" << endl; - break; - } - - //get dbroots ids for reside PM - try - { - residedbrootConfigList.clear(); - oam.getPmDbrootConfig(atoi(residePMID.c_str()), residedbrootConfigList); - - cout << "DBRoot IDs newly assigned to '" + residePM + "' = "; - - DBRootConfigList::iterator pt = residedbrootConfigList.begin(); - - for ( ; pt != residedbrootConfigList.end() ;) - { - cout << oam.itoa(*pt); - pt++; - - if (pt != residedbrootConfigList.end()) - cout << ", "; - } - - cout << endl; - } - catch (exception& e) - { - cout << endl << "**** getPmDbrootConfig Failed for '" << toPM << "' : " << e.what() << endl; - break; - } - - try - { - todbrootConfigList.clear(); - oam.getPmDbrootConfig(atoi(toPMID.c_str()), todbrootConfigList); - - cout << "DBRoot IDs newly assigned to '" + toPM + "' = "; - - DBRootConfigList::iterator pt = todbrootConfigList.begin(); - - for ( ; pt != todbrootConfigList.end() ;) - { - cout << oam.itoa(*pt); - pt++; - - if (pt != todbrootConfigList.end()) - cout << ", "; - } - - cout << endl; - } - catch (exception& e) - { - cout << endl << "**** getPmDbrootConfig Failed for '" << toPM << "' : " << e.what() << endl; - break; - } - - } - break; - - case 32: // suspendDatabaseWrites - { - BRM::DBRM dbrm; - getFlags(arguments, gracefulTemp, ackTemp, suspendAnswer, bNeedsConfirm); - - cout << endl << "This command suspends the DDL/DML writes to the Calpont Database" << endl; - - try - { - - if (!dbrm.isDBRMReady()) - { - cout << endl << " The Controller Node is not responding.\n The system can't be set into write suspend mode" << endl << flush; - break; - } - else if (dbrm.isReadWrite() != 0) - { - suspendAnswer = FORCE; - } - - // If there are bulkloads, ddl or dml happening, refuse the request - if (suspendAnswer == CANCEL) // We don't have an answer from the command line. - { - // If there are bulkloads, ddl or dml happening, Ask what to do. - bool bIsDbrmUp = true; - execplan::SessionManager sessionManager; - BRM::SIDTIDEntry blockingsid; - std::vector tableLocks = dbrm.getAllTableLocks(); - bool bActiveTransactions = false; - - if (!tableLocks.empty()) - { - oam.DisplayLockedTables(tableLocks, &dbrm); - bActiveTransactions = true; - } - - if (sessionManager.checkActiveTransaction(0, bIsDbrmUp, blockingsid)) - { - cout << endl << "There are active transactions being processed" << endl; - bActiveTransactions = true; - } - - if (bActiveTransactions) - { - suspendAnswer = AskSuspendQuestion(CmdID); - // if (suspendAnswer == FORCE) - // { - // if (confirmPrompt("Force may cause data problems and should only be used in extreme circumstances")) - // { - // break; - // } - // } - bNeedsConfirm = false; - } - else - { - suspendAnswer = FORCE; - } - } - - if (suspendAnswer == CANCEL) - { - // We're outa here. - break; - } - - if (bNeedsConfirm) - { - if (confirmPrompt("")) - break; - } - - switch (suspendAnswer) - { - case WAIT: - cout << endl << " Waiting for all transactions to complete" << flush; - dbrm.setSystemSuspendPending(true, false); - gracefulTemp = GRACEFUL_WAIT; // Causes procmgr to wait for all table locks to free and all transactions to finish before shutdown - break; - - case ROLLBACK: - cout << endl << " Rollback of all transactions" << flush; - dbrm.setSystemSuspendPending(true, true); - gracefulTemp = GRACEFUL_WAIT; // Causes procmgr to wait for all table locks to free and all transactions to finish before shutdown - break; - - case FORCE: - case CANCEL: - default: - gracefulTemp = FORCEFUL; - break; - } - - // stop writes to Calpont Database - oam.SuspendWrites(gracefulTemp, ackTemp); - } - catch (exception& e) - { - cout << endl << "**** stopDatabaseWrites Failed: " << e.what() << endl; - } - catch (...) - { - cout << endl << "**** stopDatabaseWrites Failed" << endl; - break; - } - - break; - } - - case 33: // resumeDatabaseWrites - { - if ( arguments[1] != "y" ) - { - if (confirmPrompt("This command resumes the DDL/DML writes to the Calpont Database")) - break; - } - - // resume writes to Calpont Database - - try - { - SystemProcessStatus systemprocessstatus; - BRM::DBRM dbrm; - - dbrm.setSystemSuspended(false); - - oam.getProcessStatus(systemprocessstatus); - - for ( unsigned int i = 0 ; i < systemprocessstatus.processstatus.size(); i++) - { - if (systemprocessstatus.processstatus[i].ProcessName == "DMLProc") - { - oam.setProcessStatus(systemprocessstatus.processstatus[i].ProcessName, systemprocessstatus.processstatus[i].Module, ACTIVE, 1); - } - - if (systemprocessstatus.processstatus[i].ProcessName == "DDLProc") - { - oam.setProcessStatus(systemprocessstatus.processstatus[i].ProcessName, systemprocessstatus.processstatus[i].Module, ACTIVE, 1); - } - - if (systemprocessstatus.processstatus[i].ProcessName == "WriteEngineServer") - { - oam.setProcessStatus(systemprocessstatus.processstatus[i].ProcessName, systemprocessstatus.processstatus[i].Module, ACTIVE, 1); - } - } - - oam.setSystemStatus(ACTIVE); - cout << endl << "Resume Calpont Database Writes Request successfully completed" << endl; - } - catch (exception& e) - { - cout << endl << "**** resumeDatabaseWrites Failed: " << e.what() << endl; - } - catch (...) - { - cout << endl << "**** resumeDatabaseWrites Failed" << endl; - break; - } - - break; - } - - case 34: // unassignDbrootPmConfig parameters: dbroot-list reside-pm - { - if ( localModule != parentOAMModule ) - { - // exit out since not on active module - cout << endl << "**** unassignDbrootPmConfig Failed : Can only run command on Active OAM Parent Module (" << parentOAMModule << ")." << endl; - break; - } - - - if (arguments[2] == "") - { - // need atleast 2 arguments - cout << endl << "**** unassignDbrootPmConfig Failed : Missing a required Parameter, enter 'help' for additional information" << endl; - break; - } - - string dbrootIDs = arguments[1]; - string residePM = arguments[2]; - - if (arguments[2].find("pm") == string::npos ) - { - cout << endl << "**** unassignDbrootPmConfig Failed : Parmameter 2 is not a Performance Module name, enter 'help' for additional information" << endl; - break; - } - - // check module status - try - { - bool degraded; - int opState; - oam.getModuleStatus(residePM, opState, degraded); - - if (opState != oam::MAN_OFFLINE) - { - cout << endl << "**** unassignDbrootPmConfig Failed, " + residePM + " has to be in a MAN_OFFLINE state" << endl; - break; - } - - } - catch (exception& ex) - {} - - DBRootConfigList dbrootlist; - - boost::char_separator sep(", "); - boost::tokenizer< boost::char_separator > tokens(dbrootIDs, sep); - - for ( boost::tokenizer< boost::char_separator >::iterator it = tokens.begin(); - it != tokens.end(); - ++it) - { - dbrootlist.push_back(atoi((*it).c_str())); - } - - cout << endl; - - //get dbroots ids for reside PM - try - { - oam.unassignDbroot(residePM, dbrootlist); - - cout << endl << " Successfully Unassigned DBRoots " << endl << endl; - - } - catch (exception& e) - { - cout << endl << "**** Failed Unassign of DBRoots: " << e.what() << endl; - break; - } - } - break; - - case 35: // assignDbrootPmConfig parameters: pm dbroot-list - { - if ( localModule != parentOAMModule ) - { - // exit out since not on active module - cout << endl << "**** assignDbrootPmConfig Failed : Can only run command on Active OAM Parent Module (" << parentOAMModule << ")." << endl; - break; - } - - //check the system status / service status and only allow command when System is MAN_OFFLINE - string cmd = startup::StartUp::installDir() + "/bin/infinidb status > /tmp/status.log"; - system(cmd.c_str()); - - if (!oam.checkLogStatus("/tmp/status.log", "InfiniDB is running") ) - { - cout << endl << "**** assignDbrootPmConfig Failed, System is down. Needs to be running" << endl; - break; - } - - if (arguments[2] == "") - { - // need atleast 2 arguments - cout << endl << "**** assignDbrootPmConfig Failed : Missing a required Parameter, enter 'help' for additional information" << endl; - break; - } - - string dbrootIDs = arguments[1]; - string toPM = arguments[2]; - - if (arguments[2].find("pm") == string::npos ) - { - cout << endl << "**** assignDbrootPmConfig Failed : Parmameter 2 is not a Performance Module name, enter 'help' for additional information" << endl; - break; - } - - // check module status - try - { - bool degraded; - int opState; - oam.getModuleStatus(toPM, opState, degraded); - - if (opState == oam::AUTO_DISABLED || - opState == oam::MAN_DISABLED) - { - cout << "**** assignDbrootPmConfig Failed: " << toPM << " is DISABLED." << endl; - cout << "Run alterSystem-EnableModule to enable module" << endl; - break; - } - - if (!opState == oam::MAN_OFFLINE) - { - cout << "**** assignDbrootPmConfig Failed: " << toPM << " needs to be MAN_OFFLINE." << endl; - break; - } - } - catch (exception& ex) - {} - - DBRootConfigList dbrootlist; - - boost::char_separator sep(", "); - boost::tokenizer< boost::char_separator > tokens(dbrootIDs, sep); - - for ( boost::tokenizer< boost::char_separator >::iterator it = tokens.begin(); - it != tokens.end(); - ++it) - { - dbrootlist.push_back(atoi((*it).c_str())); - } - - cout << endl; - - //get dbroots ids for reside PM - try - { - oam.assignDbroot(toPM, dbrootlist); - - cout << endl << " Successfully Assigned DBRoots " << endl << endl; - - try - { - string DBRootStorageType; - oam.getSystemConfig("DBRootStorageType", DBRootStorageType); - - if (DBRootStorageType == "external" ) - { - string GlusterConfig = "n"; - string cloud = oam::UnassignedName; - - try - { - oam.getSystemConfig("Cloud", cloud); - oam.getSystemConfig( "GlusterConfig", GlusterConfig); - } - catch (...) - {} - - if ( GlusterConfig == "n" && cloud == oam::UnassignedName) - cout << " REMINDER: Update the /etc/fstab on " << toPM << " to include these dbroot mounts" << endl << endl; - - break; - - } - } - catch (...) {} - - } - catch (exception& e) - { - cout << endl << "**** Failed Assign of DBRoots: " << e.what() << endl; - break; - } - } - break; - - case 36: // getAlarmSummary - { - printAlarmSummary(); - } - break; - - case 37: // getSystemInfo - { - try - { - printSystemStatus(); - } - catch (...) - { - break; - } - - try - { - printProcessStatus(); - } - catch (...) - { - break; - } - - printAlarmSummary(); - } - break; - - case 38: // getModuleConfig - { - SystemModuleTypeConfig systemmoduletypeconfig; - ModuleTypeConfig moduletypeconfig; - ModuleConfig moduleconfig; - systemmoduletypeconfig.moduletypeconfig.clear(); - string returnValue; - string Argument; - - if (arguments[1] == "all" || arguments[1] == "") - { - - // get and all display Module Name config parameters - - try - { - oam.getSystemConfig(systemmoduletypeconfig); - - cout << endl << "Module Name Configuration" << endl; - - for ( unsigned int i = 0 ; i < systemmoduletypeconfig.moduletypeconfig.size(); i++) - { - if ( systemmoduletypeconfig.moduletypeconfig[i].ModuleType.empty() ) - // end of list - break; - - int moduleCount = systemmoduletypeconfig.moduletypeconfig[i].ModuleCount; - - if ( moduleCount == 0 ) - // skip if no modules - continue; - - string moduletype = systemmoduletypeconfig.moduletypeconfig[i].ModuleType; - - DeviceNetworkList::iterator pt = systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.begin(); - - for ( ; pt != systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.end() ; pt++) - { - string modulename = (*pt).DeviceName; - string moduleID = modulename.substr(MAX_MODULE_TYPE_SIZE, MAX_MODULE_ID_SIZE); - cout << endl << "Module '" << modulename << "' Configuration information" << endl << endl; - - cout << "ModuleType = " << moduletype << endl; - cout << "ModuleDesc = " << systemmoduletypeconfig.moduletypeconfig[i].ModuleDesc << " #" << moduleID << endl; - - HostConfigList::iterator pt1 = (*pt).hostConfigList.begin(); - - for ( ; pt1 != (*pt).hostConfigList.end() ; pt1++) - { - cout << "ModuleIPAdd NIC ID " + oam.itoa((*pt1).NicID) + " = " << (*pt1).IPAddr << endl; - cout << "ModuleHostName NIC ID " + oam.itoa((*pt1).NicID) + " = " << (*pt1).HostName << endl; - } - - DeviceDBRootList::iterator pt3 = systemmoduletypeconfig.moduletypeconfig[i].ModuleDBRootList.begin(); - - for ( ; pt3 != systemmoduletypeconfig.moduletypeconfig[i].ModuleDBRootList.end() ; pt3++) - { - if ( (*pt3).DeviceID == atoi(moduleID.c_str()) ) - { - cout << "DBRootIDs assigned = "; - DBRootConfigList::iterator pt2 = (*pt3).dbrootConfigList.begin(); - - for ( ; pt2 != (*pt3).dbrootConfigList.end() ;) - { - cout << oam.itoa(*pt2); - pt2++; - - if (pt2 != (*pt3).dbrootConfigList.end() ) - cout << ", "; - } - - cout << endl; - } - } - } - } - } - catch (exception& e) - { - cout << endl << "**** getModuleConfig Failed = " << e.what() << endl; - } - } - else - { - // get a single module name info - if (arguments[2] == "") - { - try - { - oam.getSystemConfig(arguments[1], moduleconfig); - - cout << endl << "Module Name Configuration for " << arguments[1] << endl << endl; - - cout << "ModuleType = " << moduleconfig.ModuleType << endl; - cout << "ModuleDesc = " << moduleconfig.ModuleDesc << endl; - HostConfigList::iterator pt1 = moduleconfig.hostConfigList.begin(); - - for ( ; pt1 != moduleconfig.hostConfigList.end() ; pt1++) - { - cout << "ModuleIPAdd NIC ID " + oam.itoa((*pt1).NicID) + " = " << (*pt1).IPAddr << endl; - cout << "ModuleHostName NIC ID " + oam.itoa((*pt1).NicID) + " = " << (*pt1).HostName << endl; - } - - if ( moduleconfig.ModuleType == "pm" ) - { - - cout << "DBRootIDs assigned = "; - - DBRootConfigList::iterator pt2 = moduleconfig.dbrootConfigList.begin(); - - for ( ; pt2 != moduleconfig.dbrootConfigList.end() ; ) - { - cout << oam.itoa(*pt2); - pt2++; - - if (pt2 != moduleconfig.dbrootConfigList.end()) - cout << ", "; - } - - cout << endl << endl; - } - } - catch (exception& e) - { - cout << endl << "**** getModuleConfig Failed = " << e.what() << endl; - } - } - else - { - // get a parameter for a module - // get module ID from module name entered, then get parameter - oam.getSystemConfig(systemmoduletypeconfig); - - cout << endl; - bool found = false; - - for ( unsigned int i = 0 ; i < systemmoduletypeconfig.moduletypeconfig.size(); i++) - { - string moduleType = arguments[1].substr(0, MAX_MODULE_TYPE_SIZE); - string moduleID = arguments[1].substr(MAX_MODULE_TYPE_SIZE, MAX_MODULE_ID_SIZE); - - int moduleCount = systemmoduletypeconfig.moduletypeconfig[i].ModuleCount; - - if ( moduleCount == 0 ) - // skip if no modules - continue; - - if (systemmoduletypeconfig.moduletypeconfig[i].ModuleType == moduleType ) - { - DeviceNetworkList::iterator pt = systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.begin(); - - for ( ; pt != systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.end() ; pt++) - { - if ( (*pt).DeviceName != arguments[1] ) - continue; - - found = true; - - if ( arguments[2] == "ModuleIPAdd" || arguments[2] == "ModuleHostName") - { - HostConfigList::iterator pt1 = (*pt).hostConfigList.begin(); - - for ( ; pt1 != (*pt).hostConfigList.end() ; pt1++) - { - if ( arguments[2] == "ModuleIPAdd" ) - cout << "ModuleIPAdd NIC ID " + oam.itoa((*pt1).NicID) + " = " << (*pt1).IPAddr << endl; - else - cout << "ModuleHostName NIC ID " + oam.itoa((*pt1).NicID) + " = " << (*pt1).HostName << endl; - } - } - else - { - Argument = arguments[2] + oam.itoa(i + 1); - - try - { - oam.getSystemConfig(Argument, returnValue); - cout << endl << " " << arguments[2] << " = " << returnValue << endl << endl; - break; - } - catch (exception& e) - { - cout << endl << "**** getModuleConfig Failed = " << e.what() << endl; - break; - } - } - } - } - } - - if ( !found ) - { - // module name not found - cout << endl << "**** getModuleConfig Failed : Invalid Module Name" << endl; - break; - } - - cout << endl; - } - } - } - break; - - case 39: - { - } - break; - - case 40: - { - } - break; - - case 41: - { - } - break; - - case 42: - { - } - break; - - case 43: // assignElasticIPAddress - { - //get cloud configuration data - string cloud = oam::UnassignedName; - - try - { - oam.getSystemConfig("Cloud", cloud); - } - catch (...) {} - - if ( cloud == oam::UnassignedName ) - { - cout << endl << "**** assignElasticIPAddress Not Supported : For Amazon Systems only" << endl; - break; - } - - if (arguments[2] == "") - { - // need 2 arguments - cout << endl << "**** assignElasticIPAddress Failed : Missing a required Parameter, enter 'help' for additional information" << endl; - break; - } - - parentOAMModule = getParentOAMModule(); - - if ( localModule != parentOAMModule ) - { - // exit out since not on Parent OAM Module - cout << endl << "**** assignElasticIPAddress Failed : only should be run on the Parent OAM Module, which is '" << parentOAMModule << "'" << endl; - break; - } - - string IPaddress = arguments[1]; - string moduleName = arguments[2]; - - if ( oam.validateModule(moduleName) != API_SUCCESS) - { - cout << endl << "**** assignElasticIPAddress Failed : Invalid Module name" << endl; - break; - } - - if ( moduleName == localModule ) - { - if ( arguments[3] != "y") - { - string warning = "Warning: Assigning Elastic IP Address to local module will lock up this terminal session."; - - // confirm request - if (confirmPrompt(warning)) - break; - } - } - - //check and add Elastic IP Address - int AmazonElasticIPCount = 0; - - try - { - oam.getSystemConfig("AmazonElasticIPCount", AmazonElasticIPCount); - } - catch (...) - { - AmazonElasticIPCount = 0; - } - - bool found = false; - int id = 1; - - for ( ; id < AmazonElasticIPCount + 1 ; id++ ) - { - string AmazonElasticModule = "AmazonElasticModule" + oam.itoa(id); - string ELmoduleName; - string AmazonElasticIPAddr = "AmazonElasticIPAddr" + oam.itoa(id); - string ELIPaddress; - - try - { - oam.getSystemConfig(AmazonElasticModule, ELmoduleName); - oam.getSystemConfig(AmazonElasticIPAddr, ELIPaddress); - } - catch (...) {} - - if ( ELmoduleName == moduleName && - ELIPaddress == IPaddress) - { - //assign again incase it got unconnected - //get instance id - string instanceName = oam::UnassignedName; - - try - { - ModuleConfig moduleconfig; - oam.getSystemConfig(moduleName, moduleconfig); - HostConfigList::iterator pt1 = moduleconfig.hostConfigList.begin(); - instanceName = (*pt1).HostName; - } - catch (...) - {} - - try - { - oam.assignElasticIP(instanceName, IPaddress); - cout << endl << " Successfully completed Assigning Elastic IP Address " << endl << endl; - } - catch (...) {} - - found = true; - break; - } - - if ( ELmoduleName == moduleName ) - { - cout << endl << "**** assignElasticIPAddress Failed : module already assigned IP Address " << ELIPaddress << endl; - found = true; - break; - } - - if ( ELIPaddress == IPaddress ) - { - cout << endl << "**** assignElasticIPAddress Failed : IP Address already assigned to module " << ELmoduleName << endl; - found = true; - break; - } - } - - if (found) - break; - - AmazonElasticIPCount++; - - //get instance id - string instanceName = oam::UnassignedName; - - try - { - ModuleConfig moduleconfig; - oam.getSystemConfig(moduleName, moduleconfig); - HostConfigList::iterator pt1 = moduleconfig.hostConfigList.begin(); - instanceName = (*pt1).HostName; - } - catch (...) - {} - - try - { - oam.assignElasticIP(instanceName, IPaddress); - } - catch (...) - { - cout << endl << "**** assignElasticIPAddress Failed : assignElasticIP API Error" << endl; - break; - } - - //add to configuration - string AmazonElasticModule = "AmazonElasticModule" + oam.itoa(id); - string AmazonElasticIPAddr = "AmazonElasticIPAddr" + oam.itoa(id); - - Config* sysConfig = Config::makeConfig(); - - try - { - sysConfig->setConfig("Installation", "AmazonElasticIPCount", oam.itoa(AmazonElasticIPCount)); - sysConfig->setConfig("Installation", AmazonElasticModule, moduleName); - sysConfig->setConfig("Installation", AmazonElasticIPAddr, IPaddress); - sysConfig->write(); - } - catch (...) - { - cout << "ERROR: Problem setting AmazonElasticModule in the Calpont System Configuration file" << endl; - break; - } - - cout << endl << " Successfully completed Assigning Elastic IP Address " << endl << endl; - } - break; - - case 44: // unassignElasticIPAddress - { - //get cloud configuration data - string cloud = oam::UnassignedName; - - try - { - oam.getSystemConfig("Cloud", cloud); - } - catch (...) {} - - if ( cloud == oam::UnassignedName ) - { - cout << endl << "**** unassignElasticIPAddress Not Supported : For Amazon Systems only" << endl; - break; - } - - if (arguments[1] == "") - { - // need 2 arguments - cout << endl << "**** unassignElasticIPAddress Failed : Missing a required Parameter, enter 'help' for additional information" << endl; - break; - } - - parentOAMModule = getParentOAMModule(); - - if ( localModule != parentOAMModule ) - { - // exit out since not on Parent OAM Module - cout << endl << "**** unassignElasticIPAddress Failed : only should be run on the Parent OAM Module, which is '" << parentOAMModule << "'" << endl; - break; - } - - string IPaddress = arguments[1]; - - //check and add Elastic IP Address - int AmazonElasticIPCount = 0; - - try - { - oam.getSystemConfig("AmazonElasticIPCount", AmazonElasticIPCount); - } - catch (...) - { - AmazonElasticIPCount = 0; - } - - bool found = false; - int id = 1; - - for ( ; id < AmazonElasticIPCount + 1 ; id++ ) - { - string AmazonElasticModule = "AmazonElasticModule" + oam.itoa(id); - string ELmoduleName; - string AmazonElasticIPAddr = "AmazonElasticIPAddr" + oam.itoa(id); - string ELIPaddress; - - try - { - oam.getSystemConfig(AmazonElasticIPAddr, ELmoduleName); - oam.getSystemConfig(AmazonElasticIPAddr, ELIPaddress); - } - catch (...) {} - - if ( ELIPaddress == IPaddress ) - { - found = true; - - try - { - oam.deassignElasticIP(IPaddress); - } - catch (...) - { - cout << endl << "**** deassignElasticIPAddress Failed : deassignElasticIP API Error"; - break; - } - - int oldAmazonElasticIPCount = AmazonElasticIPCount; - - Config* sysConfig = Config::makeConfig(); - - //move up any others - if ( oldAmazonElasticIPCount > id ) - { - for ( int newid = id + 1 ; newid < oldAmazonElasticIPCount + 1 ; newid++ ) - { - AmazonElasticModule = "AmazonElasticModule" + oam.itoa(newid); - AmazonElasticIPAddr = "AmazonElasticIPAddr" + oam.itoa(newid); - - try - { - oam.getSystemConfig(AmazonElasticModule, ELmoduleName); - oam.getSystemConfig(AmazonElasticIPAddr, ELIPaddress); - } - catch (...) {} - - AmazonElasticModule = "AmazonElasticModule" + oam.itoa(newid - 1); - AmazonElasticIPAddr = "AmazonElasticIPAddr" + oam.itoa(newid - 1); - - try - { - oam.setSystemConfig(AmazonElasticModule, ELmoduleName); - oam.setSystemConfig(AmazonElasticIPAddr, ELIPaddress); - } - catch (...) {} - } - } - - AmazonElasticModule = "AmazonElasticModule" + oam.itoa(oldAmazonElasticIPCount); - AmazonElasticIPAddr = "AmazonElasticIPAddr" + oam.itoa(oldAmazonElasticIPCount); - - //delete last entry and update count - AmazonElasticIPCount--; - - try - { - sysConfig->setConfig("Installation", "AmazonElasticIPCount", oam.itoa(AmazonElasticIPCount)); - sysConfig->delConfig("Installation", AmazonElasticModule); - sysConfig->delConfig("Installation", AmazonElasticIPAddr); - sysConfig->write(); - } - catch (...) - { - cout << "ERROR: Problem setting AmazonElasticModule in the Calpont System Configuration file" << endl; - break; - } - } - } - - if (!found) - { - cout << endl << " Elastic IP Address " << IPaddress << " not assigned to a module" << endl << endl; - break; - } - - cout << endl << " Successfully completed Unassigning Elastic IP Address " << endl << endl; - - } - break; - - case 45: // getSystemNetworkConfig - { - // get and display Module Network Config - SystemModuleTypeConfig systemmoduletypeconfig; - systemmoduletypeconfig.moduletypeconfig.clear(); - - //check and add Elastic IP Address - int AmazonElasticIPCount = 0; - - try - { - oam.getSystemConfig("AmazonElasticIPCount", AmazonElasticIPCount); - } - catch (...) - { - AmazonElasticIPCount = 0; - } - - // get max length of a host name for header formatting - - int maxSize = 9; - - try - { - oam.getSystemConfig(systemmoduletypeconfig); - - for ( unsigned int i = 0 ; i < systemmoduletypeconfig.moduletypeconfig.size(); i++) - { - if ( systemmoduletypeconfig.moduletypeconfig[i].ModuleType.empty() ) - // end of list - break; - - int moduleCount = systemmoduletypeconfig.moduletypeconfig[i].ModuleCount; - string moduletype = systemmoduletypeconfig.moduletypeconfig[i].ModuleType; - string moduletypedesc = systemmoduletypeconfig.moduletypeconfig[i].ModuleDesc; - - if ( moduleCount > 0 ) - { - DeviceNetworkList::iterator pt = systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.begin(); - - for ( ; pt != systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.end() ; pt++) - { - HostConfigList::iterator pt1 = (*pt).hostConfigList.begin(); - - for ( ; pt1 != (*pt).hostConfigList.end() ; pt1++) - { - if ( maxSize < (int) (*pt1).HostName.size() ) - maxSize = (*pt1).HostName.size(); - } - } - } - } - } - catch (exception& e) - { - cout << endl << "**** getSystemNetworkConfig Failed = " << e.what() << endl; - } - - cout << endl << "System Network Configuration" << endl << endl; - - cout.setf(ios::left); - cout.width(15); - cout << "Module Name"; - cout.width(30); - cout << "Module Description"; - cout.width(10); - cout << "NIC ID"; - cout.width(maxSize + 5); - cout << "Host Name"; - cout.width(20); - cout << "IP Address"; - cout.width(14); - cout << "Status"; - - if ( AmazonElasticIPCount > 0 ) - { - cout.width(20); - cout << "Elastic IP Address"; - } - - cout << endl; - cout.width(15); - cout << "-----------"; - cout.width(30); - cout << "-------------------------"; - cout.width(10); - cout << "------"; - - for ( int i = 0 ; i < maxSize ; i++ ) - { - cout << "-"; - } - - cout << " "; - cout.width(20); - cout << "---------------"; - cout.width(14); - cout << "------------"; - - if ( AmazonElasticIPCount > 0 ) - { - cout.width(20); - cout << "------------------"; - } - - cout << endl; - - try - { - oam.getSystemConfig(systemmoduletypeconfig); - - for ( unsigned int i = 0 ; i < systemmoduletypeconfig.moduletypeconfig.size(); i++) - { - if ( systemmoduletypeconfig.moduletypeconfig[i].ModuleType.empty() ) - // end of list - break; - - int moduleCount = systemmoduletypeconfig.moduletypeconfig[i].ModuleCount; - string moduletype = systemmoduletypeconfig.moduletypeconfig[i].ModuleType; - string moduletypedesc = systemmoduletypeconfig.moduletypeconfig[i].ModuleDesc; - - if ( moduleCount > 0 ) - { - DeviceNetworkList::iterator pt = systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.begin(); - - for ( ; pt != systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.end() ; pt++) - { - string modulename = (*pt).DeviceName; - string moduleID = modulename.substr(MAX_MODULE_TYPE_SIZE, MAX_MODULE_ID_SIZE); - string modulenamedesc = moduletypedesc + " #" + moduleID; - - cout.setf(ios::left); - cout.width(15); - cout << modulename; - cout.width(33); - cout << modulenamedesc; - - HostConfigList::iterator pt1 = (*pt).hostConfigList.begin(); - - for ( ; pt1 != (*pt).hostConfigList.end() ; pt1++) - { - string ipAddr = (*pt1).IPAddr; - string hostname = (*pt1).HostName; - string nicID = oam.itoa((*pt1).NicID); - int state; - - if ( nicID != "1" ) - { - cout.width(48); - cout << " "; - } - - cout.width(7); - cout << nicID; - cout.width(maxSize + 5); - cout << hostname; - cout.width(20); - cout << ipAddr; - cout.width(14); - - try - { - oam.getNICStatus(hostname, state); - - printState(state, " "); - } - catch (exception& e) - { - cout << INITIALSTATE; - } - - if ( nicID == "1" && AmazonElasticIPCount > 0 ) - { - int id = 1; - - for ( ; id < AmazonElasticIPCount + 1 ; id++ ) - { - string AmazonElasticModule = "AmazonElasticModule" + oam.itoa(id); - string ELmoduleName; - string AmazonElasticIPAddr = "AmazonElasticIPAddr" + oam.itoa(id); - string ELIPaddress; - - try - { - oam.getSystemConfig(AmazonElasticModule, ELmoduleName); - oam.getSystemConfig(AmazonElasticIPAddr, ELIPaddress); - } - catch (...) {} - - if ( modulename == ELmoduleName ) - { - cout.width(20); - cout << ELIPaddress; - break; - } - } - } - - cout << endl; - } - } - } - } - } - catch (exception& e) - { - cout << endl << "**** getSystemNetworkConfig Failed = " << e.what() << endl; - } - - //get cloud configuration data - string cloud = oam::UnassignedName; - - try - { - oam.getSystemConfig("Cloud", cloud); - } - catch (...) {} - - if ( cloud == "amazon-ec2" || cloud == "amazon-vpc" ) - { - cout << endl << "Amazon Instance Configuration" << endl << endl; - - string PMInstanceType = oam::UnassignedName; - string UMInstanceType = oam::UnassignedName; - - try - { - oam.getSystemConfig("PMInstanceType", PMInstanceType); - oam.getSystemConfig("UMInstanceType", UMInstanceType); - - cout << "PMInstanceType = " << PMInstanceType << endl; - cout << "UMInstanceType = " << UMInstanceType << endl; - } - catch (...) {} - - if ( cloud == "amazon-vpc" ) - { - string AmazonSubNetID = oam::UnassignedName; - - try - { - oam.getSystemConfig("AmazonSubNetID", AmazonSubNetID); - - cout << "AmazonSubNetID = " << AmazonSubNetID << endl; - } - catch (...) {} - } - } - - cout << endl; - - // get and all display Ext Devices Name config parameters - - try - { - SystemExtDeviceConfig systemextdeviceconfig; - oam.getSystemConfig(systemextdeviceconfig); - - if ( systemextdeviceconfig.Count == 0 ) - break; - - cout << endl << "External Device Configuration" << endl << endl; - - cout.setf(ios::left); - cout.width(30); - cout << "Device Name"; - cout.width(20); - cout << "IP Address"; - cout.width(10); - cout << "Status"; - cout << endl; - cout.width(30); - cout << "---------------------"; - cout.width(20); - cout << "---------------"; - cout.width(12); - cout << "------------"; - cout << endl; - - for ( unsigned int i = 0 ; i < systemextdeviceconfig.Count ; i++ ) - { - cout.setf(ios::left); - cout.width(30); - cout << systemextdeviceconfig.extdeviceconfig[i].Name; - cout.width(20); - cout << systemextdeviceconfig.extdeviceconfig[i].IPAddr; - cout.width(12); - - int state; - - try - { - oam.getExtDeviceStatus(systemextdeviceconfig.extdeviceconfig[i].Name, state); - - printState(state, " "); - } - catch (exception& e) - { - cout << INITIALSTATE; - } - - cout << endl; - } - - cout << endl; - } - catch (exception& e) - { - cout << endl << "**** getextdeviceconfig Failed = " << e.what() << endl; - } - - cout << endl; - - break; - } - - case 46: // enableMySQLReplication - { - string MySQLRep; - - try - { - oam.getSystemConfig("MySQLRep", MySQLRep); - } - catch (...) {} - - if ( MySQLRep == "y" ) - { - string warning = "MySQL Replication Feature is already enabled"; - - // confirm request - if (confirmPrompt(warning)) - break; - } - - string password; - - if ( arguments[1] == "") - { - cout << endl; - string prompt = "Enter the 'User' Password or 'ssh' if configured with ssh-keys"; - password = dataPrompt(prompt); - } - else - password = arguments[1]; - - if ( password == "") - password = oam::UnassignedName; - - string MySQLPasswordConfig; - - try - { - oam.getSystemConfig("MySQLPasswordConfig", MySQLPasswordConfig); - } - catch (...) {} - - if ( MySQLPasswordConfig == oam::UnassignedName ) - { - cout << endl; - string prompt = "Is there a 'MySQL' Password configured on the MySQL Front-end Modules in " + HOME + "/.my.cnf (y,n): "; - MySQLPasswordConfig = dataPrompt(prompt); - } - - if ( MySQLPasswordConfig != "y" ) - MySQLPasswordConfig = "n"; - - try - { - oam.setSystemConfig("MySQLPasswordConfig", MySQLPasswordConfig); - } - catch (...) {} - - //set flag - try - { - oam.setSystemConfig("MySQLRep", "y"); - sleep(2); - } - catch (...) {} - - try - { - oam.enableMySQLRep(password); - cout << endl << " Successful Enabling of MySQL Replication " << endl << endl; - - //display Primary UM Module / Master Node - string PrimaryUMModuleName; - - try - { - oam.getSystemConfig("PrimaryUMModuleName", PrimaryUMModuleName); - } - catch (...) {} - - cout << " MySQL Replication Master Node is " << PrimaryUMModuleName << endl << endl; - } - catch (exception& e) - { - cout << endl << "**** enableMySQLRep Failed : " << e.what() << endl; - } - - break; - } - - case 47: // getCalpontSoftwareInfo - { - cout << endl; - - if ( rootUser) - { - system("rpm -qi infinidb-platform > /tmp/calpont.txt 2>&1"); - - if (oam.checkLogStatus("/tmp/calpont.txt", "Name")) - system("cat /tmp/calpont.txt"); - else - { - system("dpkg -s calpont > /tmp/calpont.txt 2>&1"); - - if (oam.checkLogStatus("/tmp/calpont.txt", "Status: install")) - system("cat /tmp/calpont.txt"); - else - { - cout << "SoftwareVersion = " << columnstore_version << endl; - cout << "SoftwareRelease = " << columnstore_release << endl; - } - } - } - else - { - cout << "SoftwareVersion = " << columnstore_version << endl; - cout << "SoftwareRelease = " << columnstore_release << endl; - } - - cout << endl; - break; - } - - case 48: // addModule - parameters: Module type/Module Name, Number of Modules, Server Hostnames, - // Server root password optional - { - if (arguments[1] == "") - { - // need at least arguments - cout << endl << "**** addModule Failed : Missing a required Parameter, enter 'help' for additional information" << endl; - break; - } - - switch ( serverInstallType ) - { - case (oam::INSTALL_COMBINE_DM_UM_PM): - { - if (arguments[1].find("um") != string::npos ) - { - cout << endl << "**** addModule Failed : User Module Types not supported on this Combined Server Installation" << endl; - return (0); - } - - break; - } - } - - string GlusterConfig = "n"; - int GlusterCopies; - string cloud = oam::UnassignedName; - string GlusterStorageType; - string AmazonVPCNextPrivateIP; - - try - { - oam.getSystemConfig("Cloud", cloud); - oam.getSystemConfig("AmazonVPCNextPrivateIP", AmazonVPCNextPrivateIP); - oam.getSystemConfig("GlusterConfig", GlusterConfig); - oam.getSystemConfig("GlusterCopies", GlusterCopies); - oam.getSystemConfig("GlusterStorageType", GlusterStorageType); - } - catch (...) {} - - ModuleTypeConfig moduletypeconfig; - DeviceNetworkConfig devicenetworkconfig; - DeviceNetworkList devicenetworklist; - DeviceNetworkList enabledevicenetworklist; - HostConfig hostconfig; - - string moduleType; - string moduleName; - int moduleCount; - string password; - typedef std::vector inputNames; - inputNames inputnames; - typedef std::vector umStorageNames; - umStorageNames umstoragenames; - int hostArg; - int dbrootPerPM = 0; - - //check if module type or module name was entered - if ( arguments[1].size() == 2 ) - { - //Module Type was entered - if (arguments[3] == "" && cloud == oam::UnassignedName) - { - // need at least arguments - cout << endl << "**** addModule Failed : Missing a required Parameter, enter 'help' for additional information" << endl; - break; - } - - //Module Type was entered - moduleType = arguments[1]; - moduleCount = atoi(arguments[2].c_str()); - hostArg = 3; - - if (arguments[4] != "") - password = arguments[4]; - else - { - cout << endl; - string prompt = "Enter the 'User' Password or 'ssh' if configured with ssh-keys"; - password = dataPrompt(prompt); - } - - if (arguments[5] != "") - dbrootPerPM = atoi(arguments[5].c_str()); - } - else - { - //Module Name was entered - if (arguments[2] == "" && cloud == oam::UnassignedName) - { - // need at least arguments - cout << endl << "**** addModule Failed : Missing a required Parameter, enter 'help' for additional information" << endl; - break; - } - - moduleName = arguments[1]; - moduleType = arguments[1].substr(0, MAX_MODULE_TYPE_SIZE); - moduleCount = 1; - hostArg = 2; - - if (arguments[3] != "") - password = arguments[3]; - else - { - cout << endl; - string prompt = "Enter the 'User' Password or 'ssh' if configured with ssh-keys"; - password = dataPrompt(prompt); - } - - if (arguments[4] != "") - dbrootPerPM = atoi(arguments[4].c_str()); - } - -//do we needed this check???? - if ( moduleCount < 1 || moduleCount > 10 ) - { - cout << endl << "**** addModule Failed : Failed to Add Module, invalid number-of-modules entered (1-10)" << endl; - break; - } - - if ( GlusterConfig == "y" && moduleType == "pm" ) - { - if ( localModule != parentOAMModule ) - { - // exit out since not on active module - cout << endl << "**** addModule Failed : Can only run command on Active OAM Parent Module (" << parentOAMModule << ")." << endl; - break; - } - - if ( fmod((float) moduleCount, (float) GlusterCopies) != 0 ) - { - cout << endl << "**** addModule Failed : Failed to Add Module, invalid number-of-modules: must be multiple of Data Redundancy Copies, which is " << GlusterCopies << endl; - break; - } - } - - //check and parse input Hostname/VPC-IP Addresses - if (arguments[hostArg] != "") - { - boost::char_separator sep(", "); - boost::tokenizer< boost::char_separator > tokens(arguments[hostArg], sep); - - for ( boost::tokenizer< boost::char_separator >::iterator it = tokens.begin(); - it != tokens.end(); - ++it) - { - inputnames.push_back(*it); - } - } - - if ( inputnames.size() < (unsigned) moduleCount ) - { - if ( cloud == oam::UnassignedName ) - { - cout << endl << "**** addModule Failed : Failed to Add Module, number of hostnames is less than Module Count" << endl; - break; - } - else - { - if ( cloud == "amazon-ec2" ) - { - cout << endl << "Launching new Instance(s)" << endl; - - for ( int id = inputnames.size() ; id < moduleCount ; id++ ) - { - inputnames.push_back(oam::UnassignedName); - } - } - else - { - // amazon-vpc - if ( inputnames.size() == 0 ) - { - if ( AmazonVPCNextPrivateIP == oam::UnassignedName) - { - cout << endl << "**** addModule Failed : Failed to Add Module, enter VPC Private IP Address" << endl; - break; - } - else - { - if ( AmazonVPCNextPrivateIP == "autoassign") - { - for ( int id = inputnames.size() ; id < moduleCount ; id++ ) - { - inputnames.push_back("autoassign"); - } - } - else - { - for ( int id = inputnames.size() ; id < moduleCount ; id++ ) - { - inputnames.push_back(AmazonVPCNextPrivateIP); - - try - { - AmazonVPCNextPrivateIP = oam.incrementIPAddress(AmazonVPCNextPrivateIP); - } - catch (...) - { - cout << endl << "ERROR: incrementIPAddress API error, check logs" << endl; - exit(1); - } - } - } - } - } - } - } - } - - //get configured moduleNames - try - { - oam.getSystemConfig(moduleType, moduletypeconfig); - } - catch (...) - { - cout << endl << "**** addModule Failed : Failed to Add Module, getSystemConfig API Failed" << endl; - break; - } - - //get module names already in-use and Number of NIC IDs for module - typedef std::vector moduleNameList; - moduleNameList modulenamelist; - int nicNumber = 1; - - DeviceNetworkList::iterator pt = moduletypeconfig.ModuleNetworkList.begin(); - - for ( ; pt != moduletypeconfig.ModuleNetworkList.end() ; pt++) - { - modulenamelist.push_back((*pt).DeviceName); - HostConfigList::iterator pt1 = (*pt).hostConfigList.begin(); - - for ( ; pt1 != (*pt).hostConfigList.end() ; pt1++) - { - if ( (*pt1).HostName != oam::UnassignedName ) - { - if ( nicNumber < (*pt1).NicID ) - nicNumber = (*pt1).NicID; - } - } - } - - if ( ((unsigned) nicNumber * moduleCount) != inputnames.size() && cloud == oam::UnassignedName ) - { - cout << endl << "**** addModule Failed : Failed to Add Module, invalid number of hostNames entered. Enter " + oam.itoa(nicNumber * moduleCount) + " hostname(s), which is the number of NICs times the number of modules" << endl; - break; - } - - int moduleID = 1; - inputNames::const_iterator listPT1 = inputnames.begin(); - umStorageNames::const_iterator listPT2 = umstoragenames.begin(); - - for ( int i = 0 ; i < moduleCount ; i++ ) - { - //validate or determine module name - moduleNameList::const_iterator listPT = modulenamelist.begin(); - - for ( ; listPT != modulenamelist.end() ; listPT++) - { - if ( !moduleName.empty() ) - { - //add by moduleName, validate that Entered module name doesn't exist - if ( moduleName == (*listPT) ) - { - cout << endl << "**** addModule Failed : Module Name already exist" << endl; - return 1; - } - } - else - { - //add by moduleType, get available module name - string newModuleName = moduleType + oam.itoa(moduleID); - - if ( newModuleName == (*listPT) ) - moduleID++; - else - { - moduleName = newModuleName; - moduleID++; - break; - } - } - } - - if ( moduleName.empty() ) - { - moduleName = moduleType + oam.itoa(moduleID); - moduleID++; - } - - // store module name - devicenetworkconfig.DeviceName = moduleName; - enabledevicenetworklist.push_back(devicenetworkconfig); - - for ( int j = 0 ; j < nicNumber ; j ++ ) - { - //get/check Server Hostnames IP address - string hostName; - string IPAddress; - - if ( cloud == "amazon-ec2") - { - hostName = *listPT1; - - if ( hostName != oam::UnassignedName ) - { - IPAddress = oam.getEC2InstanceIpAddress(hostName); - - if (IPAddress == "stopped" || IPAddress == "terminated") - { - cout << "ERROR: Instance " + hostName + " not running, please start and retry" << endl << endl; - return 1; - } - } - else - IPAddress = oam::UnassignedName; - } - else - { - if ( cloud == "amazon-vpc") - { - if ( *listPT1 != "autoassign" ) - { - if ( oam.isValidIP(*listPT1) ) - { - //ip address entered - hostName = oam::UnassignedName; - IPAddress = *listPT1; - } - else - { - //instance id entered - hostName = *listPT1; - IPAddress = oam.getEC2InstanceIpAddress(hostName); - - if (IPAddress == "stopped" || IPAddress == "terminated") - { - cout << "ERROR: Instance " + hostName + " not running, please start and retry" << endl << endl; - return 1; - } - } - } - else - { - hostName = oam::UnassignedName; - IPAddress = "autoassign"; - } - } - else - { - // non-amazon - hostName = *listPT1; - IPAddress = oam.getIPAddress(hostName); - - if ( IPAddress.empty() ) - { - // prompt for IP Address - string prompt = "IP Address of " + hostName + " not found, enter IP Address or enter 'abort'"; - IPAddress = dataPrompt(prompt); - - if ( IPAddress == "abort" || !oam.isValidIP(IPAddress)) - return 1; - } - } - } - - hostconfig.IPAddr = IPAddress; - hostconfig.HostName = hostName; - hostconfig.NicID = j + 1; - devicenetworkconfig.hostConfigList.push_back(hostconfig); - listPT1++; - } - - devicenetworklist.push_back(devicenetworkconfig); - devicenetworkconfig.hostConfigList.clear(); - moduleName.clear(); - } - - DBRootConfigList dbrootlist; - int dbrootNumber = -1; - typedef std::vector storageDeviceList; - storageDeviceList storagedevicelist; - string deviceType; - - if ( GlusterConfig == "y" && moduleType == "pm") - { - cout << endl << "System is configured with Data Redundancy, DBRoot Storage will" << endl; - cout << "will be created with the Modules during this command." << endl; - cout << "The Data Redundancy Packages should already be installed on the" << endl; - cout << "Servers being installed." << endl; - cout << "Also the Servers should have either a password-less ssh configured" << endl; - cout << "for the local server or setup for a login via password." << endl; - cout << "If its setup for login via password, then you will be required to" << endl; - cout << "enter the password when prompted. You will be prompted 2 * the" << endl; - cout << "number of modules being added." << endl; - - // confirm request - if (confirmPrompt(" ")) - break; - - if ( dbrootPerPM == 0) - { - cout << endl; - // prompt for number of DBRoot - string prompt = "Number of DBRoots Per Performance Module you want to add"; - dbrootPerPM = atoi(dataPrompt(prompt).c_str()); - } - else - cout << endl << "Number of DBRoots Per Performance Module to be added is " << oam.itoa(dbrootPerPM) << endl; - - dbrootNumber = dbrootPerPM * moduleCount; - - if ( GlusterStorageType == "storage" ) - { - cout << endl << "Data Redundancy Storage Type is configured for 'storage'" << endl; - - cout << "You will need " << oam.itoa(dbrootNumber * GlusterCopies); - cout << " total storage locations and " << oam.itoa(dbrootPerPM * GlusterCopies) << " storage locations per PM. You will now " << endl; - cout << "be asked to enter the device names for the storage locations. You will enter " << endl; - cout << "them for each PM, on one line, separated by spaces (" << oam.itoa(dbrootPerPM * GlusterCopies) << " names on each line)." << endl; - - DeviceNetworkList::iterator pt = devicenetworklist.begin(); - string firstPM = (*pt).DeviceName.substr(MAX_MODULE_TYPE_SIZE, MAX_MODULE_ID_SIZE); - - for ( ; pt != devicenetworklist.end() ; pt++) - { - cout << endl; - string prompt = "Storage Device Names for " + (*pt).DeviceName; - string devices = dataPrompt(prompt); - storagedevicelist.push_back(devices); - } - - cout << endl; - string prompt = "Filesystem type for these storage locations (ext2,ext3,xfs,etc)"; - deviceType = dataPrompt(prompt); - } - - } - - string mysqlpassword = oam::UnassignedName; - - try - { - cout << endl << "Adding Modules "; - DeviceNetworkList::iterator pt = devicenetworklist.begin(); - string firstPM = (*pt).DeviceName.substr(MAX_MODULE_TYPE_SIZE, MAX_MODULE_ID_SIZE); - - for ( ; pt != devicenetworklist.end() ; pt++) - { - cout << (*pt).DeviceName << ", "; - } - - cout << "please wait..." << endl; - - oam.addModule(devicenetworklist, password, mysqlpassword); - - cout << "Add Module(s) successfully completed" << endl; - - if ( GlusterConfig == "y" && moduleType == "pm" ) - { - - if ( GlusterStorageType == "storage" ) - { - //send messages to update fstab to new modules, if needed - DeviceNetworkList::iterator pt2 = devicenetworklist.begin(); - storageDeviceList::iterator pt3 = storagedevicelist.begin(); - - for ( ; pt2 != devicenetworklist.end() ; pt2++, pt3++) - { - string moduleName = (*pt2).DeviceName; - string devices = *pt3; - int brinkID = 1; - boost::char_separator sep(" "); - boost::tokenizer< boost::char_separator > tokens(devices, sep); - - for ( boost::tokenizer< boost::char_separator >::iterator it = tokens.begin(); - it != tokens.end(); - ++it) - { - string deviceName = *it; - string entry = deviceName + " " + startup::StartUp::installDir() + "/gluster/brick" + oam.itoa(brinkID) + " " + deviceType + " defaults 1 2"; - - //send update pm - oam.distributeFstabUpdates(entry, moduleName); - brinkID++; - } - } - } - - //enable modules - try - { - cout << endl << "Enabling Modules " << endl; - oam.enableModule(enabledevicenetworklist); - cout << "Successful Enable of Modules " << endl; - } - catch (exception& e) - { - cout << endl << "**** enableModule Failed : " << e.what() << endl; - break; - } - - cout << endl << "Adding DBRoots" << endl; - - //add dbroots - string firstDBroot; - - try - { - oam.addDbroot(dbrootNumber, dbrootlist); - - cout << "New DBRoot IDs added = "; - DBRootConfigList::iterator pt1 = dbrootlist.begin(); - firstDBroot = oam.itoa(*pt1); - - for ( ; pt1 != dbrootlist.end() ;) - { - cout << oam.itoa(*pt1); - pt1++; - - if (pt1 != dbrootlist.end()) - cout << ", "; - } - - cout << endl; - - } - catch (exception& e) - { - cout << endl << "**** addDbroot Failed: " << e.what() << endl; - break; - } - - cout << endl << "Assigning DBRoots" << endl << endl; - - DeviceNetworkList::iterator pt = devicenetworklist.begin(); - DBRootConfigList::iterator pt1 = dbrootlist.begin(); - - for ( ; pt != devicenetworklist.end() ; pt++) - { - string moduleName = (*pt).DeviceName; - - DBRootConfigList dbrootlist; - - for ( int dbrootNum = 0; dbrootNum < dbrootPerPM ; dbrootNum++) - { - dbrootlist.push_back(*pt1); - pt1++; - } - - //assign dbroots to pm - try - { - oam.assignDbroot(moduleName, dbrootlist); - - cout << endl << "Successfully Assigned DBRoots " << endl; - - } - catch (exception& e) - { - cout << endl << "**** Failed Assign of DBRoots: " << e.what() << endl; - break; - } - } - - cout << endl << "Run Data Redundancy Setup for DBRoots" << endl; - - try - { - string errmsg; - int ret = oam.glusterctl(oam::GLUSTER_ADD, firstPM, firstDBroot, errmsg); - - if ( ret != 0 ) - { - cout << endl << "**** Failed Data Redundancy Add of DBRoots: " << errmsg << endl; - break; - } - - cout << endl << "Successfully Completed Data Redundancy Add DBRoots " << endl; - - } - catch (...) - { - cout << endl << "**** glusterctl GLUSTER_ADD Failed" << endl; - break; - } - - cout << endl << "addModule Command Successfully completed: Run startSystem command to Activate newly added Performance Modules" << endl << endl; - } - else - { - cout << "addModule Command Successfully completed: Modules are Disabled, run alterSystem-enableModule command to enable them" << endl << endl; - } - - try - { - oam.setSystemConfig("AmazonVPCNextPrivateIP", AmazonVPCNextPrivateIP); - } - catch (...) {} - - } - catch (exception& e) - { - cout << endl << "**** addModule Failed: " << e.what() << endl; - } - catch (...) - { - cout << endl << "**** addModule Failed : Failed to Add Module" << endl; - } - - break; - } - - case 49: // removeModule - parameters: Module name/type, number-of-modules - { - if (arguments[1] == "") - { - // need atleast 1 arguments - cout << endl << "**** removeModule Failed : Missing a required Parameter, enter 'help' for additional information" << endl; - break; - } - - parentOAMModule = getParentOAMModule(); - - if ( arguments[1] == parentOAMModule ) - { - // exit out since you can't manually remove OAM Parent Module - cout << endl << "**** removeModule Failed : can't manually remove the Active OAM Parent Module." << endl; - break; - } - - switch ( serverInstallType ) - { - case (oam::INSTALL_COMBINE_DM_UM_PM): - { - if (arguments[1].find("um") != string::npos ) - { - cout << endl << "**** removeModule Failed : User Modules not supported on the Combined Server Installation" << endl; - return 0; - } - } - } - - ModuleTypeConfig moduletypeconfig; - DeviceNetworkConfig devicenetworkconfig; - DeviceNetworkList devicenetworklist; - bool quit = false; - - string moduleType; - - //check if module type or module name was entered - if ( arguments[1].size() == 2 ) - { - //Module Type was entered - - if ( arguments[3] != "y") - { - cout << endl << "!!!!! DESTRUCTIVE COMMAND !!!!!" << endl; - string warning = "This command does a remove a module from the Calpont System"; - - // confirm request - if (confirmPrompt(warning)) - break; - } - - int moduleCount = atoi(arguments[2].c_str()); - - if ( moduleCount < 1 || moduleCount > 10 ) - { - cout << endl << "**** removeModule Failed : Failed to Remove Module, invalid number-of-modules entered (1-10)" << endl; - break; - } - - cout << endl; - - moduleType = arguments[1]; - - //store moduleNames - try - { - oam.getSystemConfig(moduleType, moduletypeconfig); - } - catch (...) - { - cout << endl << "**** removeModule Failed : Failed to Remove Module, getSystemConfig API Failed" << endl; - break; - } - - int currentModuleCount = moduletypeconfig.ModuleCount; - - if ( moduleCount > currentModuleCount ) - { - cout << endl << "**** removeModule Failed : Failed to Remove Module, mount count entered to larger than configured" << endl; - break; - } - - if ( moduleCount == currentModuleCount ) - { - if ( moduleType == "pm" ) - { - cout << endl << "**** removeModule Failed : Failed to Remove Module, you can't remove last Director Module" << endl; - break; - } - } - - //get module names in-use - typedef std::vector moduleNameList; - moduleNameList modulenamelist; - - DeviceNetworkList::iterator pt = moduletypeconfig.ModuleNetworkList.begin(); - - for ( ; pt != moduletypeconfig.ModuleNetworkList.end() ; pt++) - { - HostConfigList::iterator pt1 = (*pt).hostConfigList.begin(); - - if ( (*pt1).HostName != oam::UnassignedName ) - modulenamelist.push_back((*pt).DeviceName); - } - - moduleNameList::reverse_iterator pt1 = modulenamelist.rbegin(); - - for ( int i = 0 ; i < moduleCount ; i++) - { - devicenetworkconfig.DeviceName = *pt1; - pt1++; - devicenetworklist.push_back(devicenetworkconfig); - } - } - else - { - //Module Name was entered - - if ( arguments[2] != "y") - { - cout << endl << "!!!!! DESTRUCTIVE COMMAND !!!!!" << endl; - string warning = "This command does a stop and remove a module from the Calpont System"; - - // confirm request - if (confirmPrompt(warning)) - break; - } - - cout << endl; - - //parse module names - boost::char_separator sep(", "); - boost::tokenizer< boost::char_separator > tokens(arguments[1], sep); - - for ( boost::tokenizer< boost::char_separator >::iterator it = tokens.begin(); - it != tokens.end(); - ++it) - { - devicenetworkconfig.DeviceName = *it; - devicenetworklist.push_back(devicenetworkconfig); - - moduleType = (*it).substr(0, MAX_MODULE_TYPE_SIZE); - - try - { - oam.getSystemConfig(moduleType, moduletypeconfig); - } - catch (...) - { - cout << endl << "**** removeModule Failed : Failed to Remove Module, getSystemConfig API Failed" << endl; - quit = true; - break; - } - - int currentModuleCount = moduletypeconfig.ModuleCount; - - if ( moduleType == "pm" && currentModuleCount == 1) - { - cout << endl << "**** removeModule Failed : Failed to Remove Module, you can't remove last Performance Module" << endl; - quit = true; - break; - } - - if ( moduleType == "um" && currentModuleCount == 1) - { - cout << endl << "**** removeModule Failed : Failed to Remove Module, you can't remove last User Module" << endl; - quit = true; - break; - } - } - } - - if (quit) - break; - - DeviceNetworkList::iterator pt = devicenetworklist.begin(); - DeviceNetworkList::iterator endpt = devicenetworklist.end(); - - // check for module status and if any dbroots still assigned - for ( ; pt != endpt ; pt++) - { - if ( moduleType == "pm" ) - { - // check for dbroots assigned - DBRootConfigList dbrootConfigList; - string moduleID = (*pt).DeviceName.substr(MAX_MODULE_TYPE_SIZE, MAX_MODULE_ID_SIZE); - - try - { - oam.getPmDbrootConfig(atoi(moduleID.c_str()), dbrootConfigList); - } - catch (...) - {} - - if ( !dbrootConfigList.empty() ) - { - cout << "**** removeModule Failed : " << (*pt).DeviceName << " has dbroots still assigned. Please run movePmDbrootConfig or unassignPmDbrootConfig."; - quit = true; - cout << endl; - break; - } - } - - // check module status - try - { - bool degraded; - int opState; - oam.getModuleStatus((*pt).DeviceName, opState, degraded); - - if (opState == oam::MAN_OFFLINE || - opState == oam::MAN_DISABLED || - opState == oam::FAILED) - continue; - else - { - cout << "**** removeModule Failed : " << (*pt).DeviceName << " is not MAN_OFFLINE, DISABLED, or FAILED state."; - quit = true; - cout << endl; - break; - } - } - catch (exception& ex) - {} - } - - if (quit) - { - cout << endl; - break; - } - - try - { - cout << endl << "Removing Module(s) "; - DeviceNetworkList::iterator pt = devicenetworklist.begin(); - - for ( ; pt != devicenetworklist.end() ; pt++) - { - cout << (*pt).DeviceName << ", "; - } - - cout << "please wait..." << endl; - - oam.removeModule(devicenetworklist); - cout << endl << "Remove Module successfully completed" << endl << endl; - } - catch (exception& e) - { - cout << endl << "Failed to Remove Module: " << e.what() << endl << endl; - } - catch (...) - { - cout << endl << "**** removeModule Failed : Failed to Remove Module" << endl << endl; - break; - } - - break; - } - - case 50: // getModuleHostNames - { - SystemModuleTypeConfig systemmoduletypeconfig; - ModuleTypeConfig moduletypeconfig; - ModuleConfig moduleconfig; - systemmoduletypeconfig.moduletypeconfig.clear(); - string returnValue; - string Argument; - - // get and all display Module HostNames (NIC 1) - // No other data will be displayed, only the hostnames. - // This feature is designed for use by other processes. - // It was specifically installed for the sqoop import feature (version 4.5) - // If arguments[1] == PM, display only PMs, UM, display only UMs, else all. - try - { - oam.getSystemConfig(systemmoduletypeconfig); - - for ( unsigned int i = 0 ; i < systemmoduletypeconfig.moduletypeconfig.size(); i++) - { - if ( systemmoduletypeconfig.moduletypeconfig[i].ModuleType.empty() ) - // end of list - break; - - int moduleCount = systemmoduletypeconfig.moduletypeconfig[i].ModuleCount; - - if ( moduleCount == 0 ) - // skip if no modules - continue; - - string moduletype = systemmoduletypeconfig.moduletypeconfig[i].ModuleType; - - if (arguments[1] == "pm" && moduletype != "pm") - continue; - - if (arguments[1] == "um" && moduletype != "um") - continue; - - DeviceNetworkList::iterator pt = systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.begin(); - - for ( ; pt != systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.end() ; pt++) - { - HostConfigList::iterator pt1 = (*pt).hostConfigList.begin(); - - for ( ; pt1 != (*pt).hostConfigList.end() ; pt1++) - { - // Only print for NIC 1 - if ((*pt1).NicID == 1) - { - // We need the name with domain and everything. - if ((*pt1).HostName == "localhost") - { - char hostName[128] = {0}; - gethostname(hostName, 128); - cout << hostName << endl; - } - else - { - struct hostent* hentName = gethostbyname((*pt1).HostName.c_str()); - - if (hentName) - { - cout << hentName->h_name << endl; - } - else - { - cout << (*pt1).HostName.c_str() << endl; - } - } - } - } - } - } - } - catch (exception& e) - { - cout << endl << "**** getModuleHostNames Failed = " << e.what() << endl; - } - - break; - } - - case 51: // disableMySQLReplication - { - string MySQLRep; - - try - { - oam.getSystemConfig("MySQLRep", MySQLRep); - } - catch (...) {} - - if ( MySQLRep == "n" ) - { - string warning = "MySQL Replication Feature is already disable"; - - // confirm request - if (confirmPrompt(warning)) - break; - } - - string MySQLPasswordConfig; - - try - { - oam.getSystemConfig("MySQLPasswordConfig", MySQLPasswordConfig); - } - catch (...) {} - - if ( MySQLPasswordConfig == oam::UnassignedName ) - { - cout << endl; - string prompt = "Is there a 'MySQL' Password configured on the MySQL Front-end Modules in " + HOME + "/.my.cnf (y,n): "; - MySQLPasswordConfig = dataPrompt(prompt); - } - - if ( MySQLPasswordConfig != "y" ) - MySQLPasswordConfig = "n"; - - try - { - oam.setSystemConfig("MySQLPasswordConfig", MySQLPasswordConfig); - } - catch (...) {} - - //set flag - try - { - oam.setSystemConfig("MySQLRep", "n"); - sleep(2); - } - catch (...) {} - - try - { - oam.disableMySQLRep(); - cout << endl << " Successful Disable of MySQL Replication " << endl; - } - catch (exception& e) - { - cout << endl << "**** disableMySQLRep Failed : " << e.what() << endl; - } - - break; - } - - case 52: // getModuleCpuUsers - { - if (arguments[1] == "") - { - // need 1 arguments - cout << endl << "**** getModuleCpuUsers Failed : Missing a required Parameter, enter 'help' for additional information" << endl; - break; - } - - int topNumber = 5; - - if (arguments[2] != "") - { - topNumber = atoi(arguments[2].c_str()); - - if ( topNumber < 1 || topNumber > 10 ) - { - cout << endl << "**** getModuleCpuUsers Failed : Invalid top Number entered" << endl; - break; - } - } - - TopProcessCpuUsers topprocesscpuusers; - - try - { - oam.getTopProcessCpuUsers(arguments[1], topNumber, topprocesscpuusers); - - printModuleCpuUsers(topprocesscpuusers); - - } - catch (exception& e) - { - cout << endl << "Failed to get Top CPU Users: " << e.what() << endl << endl; - } - catch (...) - { - cout << endl << "**** getModuleCpuUsers Failed : Failed to get Top CPU Users" << endl << endl; - break; - } - - break; - } - - case 53: // getSystemCpuUsers - { - int topNumber = 5; - - if (arguments[1] != "") - { - topNumber = atoi(arguments[1].c_str()); - - if ( topNumber < 1 || topNumber > 10 ) - { - cout << endl << "**** getSystemCpuUsers Failed : Invalid top Number entered" << endl; - break; - } - } - - cout << endl << "System Process Top CPU Users per Module" << endl << endl; - - SystemTopProcessCpuUsers systemtopprocesscpuusers; - TopProcessCpuUsers topprocesscpuusers; - - try - { - oam.getTopProcessCpuUsers(topNumber, systemtopprocesscpuusers); - - for ( unsigned int i = 0 ; i < systemtopprocesscpuusers.topprocesscpuusers.size(); i++) - { - printModuleCpuUsers(systemtopprocesscpuusers.topprocesscpuusers[i]); - } - - } - catch (exception& e) - { - cout << endl << "Failed to get Top CPU Users: " << e.what() << endl << endl; - } - catch (...) - { - cout << endl << "**** getSystemCpuUsers Failed : Failed to get Top CPU Users" << endl << endl; - break; - } - - break; - } - - case 54: // getModuleCpu - { - if (arguments[1] == "") - { - // need 1 arguments - cout << endl << "**** getModuleCpu Failed : Missing a required Parameter, enter 'help' for additional information" << endl; - break; - } - - ModuleCpu modulecpu; - - try - { - oam.getModuleCpuUsage(arguments[1], modulecpu); - - printModuleCpu(modulecpu); - - } - catch (exception& e) - { - cout << endl << "Failed to get CPU Usage: " << e.what() << endl << endl; - } - catch (...) - { - cout << endl << "**** getModuleCpu Failed : Failed to get Module CPU Usage" << endl << endl; - break; - } - - break; - } - - case 55: // getSystemCpu - { - cout << endl << "System CPU Usage per Module" << endl << endl; - - SystemCpu systemcpu; - - try - { - oam.getSystemCpuUsage(systemcpu); - - for ( unsigned int i = 0 ; i < systemcpu.modulecpu.size(); i++) - { - printModuleCpu(systemcpu.modulecpu[i]); - } - - } - catch (exception& e) - { - cout << endl << "Failed to get CPU Usage: " << e.what() << endl << endl; - } - catch (...) - { - cout << endl << "**** getSystemCpu Failed : Failed to get CPU Usage" << endl << endl; - break; - } - - break; - } - - case 56: // getModuleMemoryUsers - { - if (arguments[1] == "") - { - // need 1 arguments - cout << endl << "**** getModuleMemoryUsers Failed : Missing a required Parameter, enter 'help' for additional information" << endl; - break; - } - - int topNumber = 5; - - if (arguments[2] != "") - { - topNumber = atoi(arguments[2].c_str()); - - if ( topNumber < 1 || topNumber > 10 ) - { - cout << endl << "**** getModuleMemoryUsers Failed : Invalid top Number entered" << endl; - break; - } - } - - TopProcessMemoryUsers topprocessmemoryusers; - - try - { - oam.getTopProcessMemoryUsers(arguments[1], topNumber, topprocessmemoryusers); - - printModuleMemoryUsers(topprocessmemoryusers); - - } - catch (exception& e) - { - cout << endl << "Failed to get Top Memory Users: " << e.what() << endl << endl; - } - catch (...) - { - cout << endl << "**** getModuleMemoryUsers Failed : Failed to get Top Memory Users" << endl << endl; - break; - } - - break; - } - - case 57: // getSystemMemoryUsers - { - int topNumber = 5; - - if (arguments[1] != "") - { - topNumber = atoi(arguments[1].c_str()); - - if ( topNumber < 1 || topNumber > 10 ) - { - cout << endl << "**** getSystemMemoryUsers Failed : Invalid top Number entered" << endl; - break; - } - } - - cout << endl << "System Process Top Memory Users per Module" << endl << endl; - - SystemTopProcessMemoryUsers systemtopprocessmemoryusers; - TopProcessMemoryUsers topprocessmemoryusers; - - try - { - oam.getTopProcessMemoryUsers(topNumber, systemtopprocessmemoryusers); - - for ( unsigned int i = 0 ; i < systemtopprocessmemoryusers.topprocessmemoryusers.size(); i++) - { - printModuleMemoryUsers(systemtopprocessmemoryusers.topprocessmemoryusers[i]); - } - - } - catch (exception& e) - { - cout << endl << "Failed to get Top CPU Users: " << e.what() << endl << endl; - } - catch (...) - { - cout << endl << "**** getSystemMemoryUsers Failed : Failed to get Top CPU Users" << endl << endl; - break; - } - - break; - } - - case 58: // getModuleMemory - { - if (arguments[1] == "") - { - // need 1 arguments - cout << endl << "**** getModuleMemory Failed : Missing a required Parameter, enter 'help' for additional information" << endl; - break; - } - - ModuleMemory modulememory; - - try - { - oam.getModuleMemoryUsage(arguments[1], modulememory); - - cout << endl << "Module Memory Usage (in K bytes)" << endl << endl; - - cout.setf(ios::left); - cout.width(8); - cout << "Module"; - cout.width(11); - cout << "Mem Total"; - cout.width(9); - cout << "Mem Used"; - cout.width(9); - cout << "cache"; - cout.width(12); - cout << "Mem Usage %"; - cout.width(11); - cout << "Swap Total"; - cout.width(10); - cout << "Swap Used"; - cout.width(13); - cout << "Swap Usage %"; - cout << endl; - - cout.setf(ios::left); - cout.width(8); - cout << "------"; - cout.width(11); - cout << "---------"; - cout.width(9); - cout << "-------"; - cout.width(9); - cout << "-------"; - cout.width(12); - cout << "----------"; - cout.width(11); - cout << "----------"; - cout.width(10); - cout << "---------"; - cout.width(13); - cout << "-----------"; - cout << endl; - - printModuleMemory(modulememory); - } - catch (exception& e) - { - cout << endl << "Failed to get Memory Usage: " << e.what() << endl << endl; - } - catch (...) - { - cout << endl << "**** getModuleMemory Failed : Failed to get Module Memory Usage" << endl << endl; - break; - } - - break; - } - - case 59: // getSystemMemory - { - cout << endl << "System Memory Usage per Module (in K bytes)" << endl << endl; - - cout.setf(ios::left); - cout.width(8); - cout << "Module"; - cout.width(11); - cout << "Mem Total"; - cout.width(10); - cout << "Mem Used"; - cout.width(9); - cout << "Cache"; - cout.width(13); - cout << "Mem Usage %"; - cout.width(12); - cout << "Swap Total"; - cout.width(11); - cout << "Swap Used"; - cout.width(14); - cout << "Swap Usage %"; - cout << endl; - - cout.setf(ios::left); - cout.width(8); - cout << "------"; - cout.width(11); - cout << "---------"; - cout.width(10); - cout << "--------"; - cout.width(9); - cout << "-------"; - cout.width(13); - cout << "-----------"; - cout.width(12); - cout << "----------"; - cout.width(11); - cout << "---------"; - cout.width(14); - cout << "------------"; - cout << endl; - - SystemMemory systemmemory; - - try - { - oam.getSystemMemoryUsage(systemmemory); - - for ( unsigned int i = 0 ; i < systemmemory.modulememory.size(); i++) - { - printModuleMemory(systemmemory.modulememory[i]); - } - - } - catch (exception& e) - { - cout << endl << "Failed to get Memory Usage: " << e.what() << endl << endl; - } - catch (...) - { - cout << endl << "**** getSystemCpu Failed : Failed to get Memory Usage" << endl << endl; - break; - } - - break; - } - - case 60: // getModuleDisk - { - if (arguments[1] == "") - { - // need 1 arguments - cout << endl << "**** getModuleDisk Failed : Missing a required Parameter, enter 'help' for additional information" << endl; - break; - } - - ModuleDisk moduledisk; - - try - { - oam.getModuleDiskUsage(arguments[1], moduledisk); - - printModuleDisk(moduledisk); - - } - catch (exception& e) - { - cout << endl << "Failed to get Disk Usage: " << e.what() << endl << endl; - } - catch (...) - { - cout << endl << "**** getModuleDisk Failed : Failed to get Module Disk Usage" << endl << endl; - break; - } - - break; - } - - case 61: // getSystemDisk - { - cout << endl << "System Disk Usage per Module" << endl << endl; - - SystemDisk systemdisk; - - try - { - oam.getSystemDiskUsage(systemdisk); - - for ( unsigned int i = 0 ; i < systemdisk.moduledisk.size(); i++) - { - printModuleDisk(systemdisk.moduledisk[i]); - } - - } - catch (exception& e) - { - cout << endl << "Failed to get Memory Usage: " << e.what() << endl << endl; - } - catch (...) - { - cout << endl << "**** getSystemCpu Failed : Failed to get Memory Usage" << endl << endl; - break; - } - - break; - } - - case 62: // getModuleResources - { - if (arguments[1] == "") - { - // need 1 arguments - cout << endl << "**** getModuleResources Failed : Missing a required Parameter, enter 'help' for additional information" << endl; - break; - } - - int topNumber = 5; - - TopProcessCpuUsers topprocesscpuusers; - - try - { - oam.getTopProcessCpuUsers(arguments[1], topNumber, topprocesscpuusers); - } - catch (exception& e) - { - cout << endl << "Failed to get Top CPU Users: " << e.what() << endl << endl; - break; - } - catch (...) - { - cout << endl << "**** getModuleCpuUsers Failed : Failed to get Top CPU Users" << endl << endl; - break; - } - - ModuleCpu modulecpu; - - try - { - oam.getModuleCpuUsage(arguments[1], modulecpu); - } - catch (exception& e) - { - cout << endl << "Failed to get CPU Usage: " << e.what() << endl << endl; - break; - } - catch (...) - { - cout << endl << "**** getModuleCpu Failed : Failed to get Module CPU Usage" << endl << endl; - break; - } - - TopProcessMemoryUsers topprocessmemoryusers; - - try - { - oam.getTopProcessMemoryUsers(arguments[1], topNumber, topprocessmemoryusers); - } - catch (exception& e) - { - cout << endl << "Failed to get Top Memory Users: " << e.what() << endl << endl; - break; - } - catch (...) - { - cout << endl << "**** getModuleMemoryUsers Failed : Failed to get Top Memory Users" << endl << endl; - break; - } - - ModuleMemory modulememory; - - try - { - oam.getModuleMemoryUsage(arguments[1], modulememory); - } - catch (exception& e) - { - cout << endl << "Failed to get Memory Usage: " << e.what() << endl << endl; - break; - } - catch (...) - { - cout << endl << "**** getModuleMemory Failed : Failed to get Module Memory Usage" << endl << endl; - break; - } - - ModuleDisk moduledisk; - - try - { - oam.getModuleDiskUsage(arguments[1], moduledisk); - } - catch (exception& e) - { - cout << endl << "Failed to get Disk Usage: " << e.what() << endl << endl; - break; - } - catch (...) - { - cout << endl << "**** getModuleDisk Failed : Failed to get Module Disk Usage" << endl << endl; - break; - } - - printModuleResources(topprocesscpuusers, modulecpu, topprocessmemoryusers, modulememory, moduledisk); - - break; - } - - case 63: // getSystemResources - { - cout << endl << "System Resource Usage per Module" << endl << endl; - - int topNumber = 5; - - SystemModuleTypeConfig systemmoduletypeconfig; - ModuleTypeConfig moduletypeconfig; - - try - { - oam.getSystemConfig(systemmoduletypeconfig); - - for ( unsigned int i = 0 ; i < systemmoduletypeconfig.moduletypeconfig.size(); i++) - { - if ( systemmoduletypeconfig.moduletypeconfig[i].ModuleType.empty() ) - // end of list - continue; - - int moduleCount = systemmoduletypeconfig.moduletypeconfig[i].ModuleCount; - - if ( moduleCount == 0 ) - continue; - - DeviceNetworkList::iterator pt = systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.begin(); - - for ( ; pt != systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.end() ; pt++) - { - string modulename = (*pt).DeviceName; - - if ( modulename == "unknown" ) - continue; - - TopProcessCpuUsers topprocesscpuusers; - - try - { - oam.getTopProcessCpuUsers(modulename, topNumber, topprocesscpuusers); - } - catch (exception& e) - { - cout << endl << "Failed to get Top CPU Users: " << e.what() << endl << endl; - break; - } - catch (...) - { - cout << endl << "**** getModuleCpuUsers Failed : Failed to get Top CPU Users" << endl << endl; - break; - } - - ModuleCpu modulecpu; - - try - { - oam.getModuleCpuUsage(modulename, modulecpu); - } - catch (exception& e) - { - cout << endl << "Failed to get CPU Usage: " << e.what() << endl << endl; - break; - } - catch (...) - { - cout << endl << "**** getModuleCpu Failed : Failed to get Module CPU Usage" << endl << endl; - break; - } - - TopProcessMemoryUsers topprocessmemoryusers; - - try - { - oam.getTopProcessMemoryUsers(modulename, topNumber, topprocessmemoryusers); - } - catch (exception& e) - { - cout << endl << "Failed to get Top Memory Users: " << e.what() << endl << endl; - break; - } - catch (...) - { - cout << endl << "**** getModuleMemoryUsers Failed : Failed to get Top Memory Users" << endl << endl; - break; - } - - ModuleMemory modulememory; - - try - { - oam.getModuleMemoryUsage(modulename, modulememory); - } - catch (exception& e) - { - cout << endl << "Failed to get Memory Usage: " << e.what() << endl << endl; - break; - } - catch (...) - { - cout << endl << "**** getModuleMemory Failed : Failed to get Module Memory Usage" << endl << endl; - break; - } - - ModuleDisk moduledisk; - - try - { - oam.getModuleDiskUsage(modulename, moduledisk); - } - catch (exception& e) - { - cout << endl << "Failed to get Disk Usage: " << e.what() << endl << endl; - break; - } - catch (...) - { - cout << endl << "**** getModuleDisk Failed : Failed to get Module Disk Usage" << endl << endl; - break; - } - - printModuleResources(topprocesscpuusers, modulecpu, topprocessmemoryusers, modulememory, moduledisk); - } - } - } - catch (exception& e) - { - cout << endl << "**** getSystemResources Failed : " << e.what() << endl; - } - - break; - } - - case 64: // getActiveSQLStatements - { - cout << endl << "Get List of Active SQL Statements" << endl; - cout << "=================================" << endl << endl; - - ActiveSqlStatements activesqlstatements; - - try - { - oam.getActiveSQLStatements(activesqlstatements); - - if ( activesqlstatements.size() == 0 ) - { - cout << "No Active SQL Statements at this time" << endl << endl; - break; - } - - cout << "Start Time Time (hh:mm:ss) Session ID SQL Statement" << endl; - cout << "---------------- ---------------- -------------------- ------------------------------------------------------------" << endl; - - for ( unsigned int i = 0 ; i < activesqlstatements.size(); i++) - { - struct tm tmStartTime; - char timeBuf[36]; - time_t startTime = activesqlstatements[i].starttime; - localtime_r(&startTime, &tmStartTime); - (void)strftime(timeBuf, 36, "%b %d %H:%M:%S", &tmStartTime); - - cout.setf(ios::left); - cout.width(21); - cout << timeBuf; - - //get current time in Epoch - time_t cal; - time (&cal); - - int runTime = cal - activesqlstatements[i].starttime; - int runHours = runTime / 3600; - int runMinutes = (runTime - (runHours * 3600)) / 60; - int runSeconds = runTime - (runHours * 3600) - (runMinutes * 60); - - cout.width(15); - string hours = oam.itoa(runHours); - string minutes = oam.itoa(runMinutes); - string seconds = oam.itoa(runSeconds); - - string run; - - if ( hours.size() == 1 ) - run = "0" + hours + ":"; - else - run = hours + ":"; - - if ( minutes.size() == 1 ) - run = run + "0" + minutes + ":"; - else - run = run + minutes + ":"; - - if ( seconds.size() == 1 ) - run = run + "0" + seconds; - else - run = run + seconds; - - cout << run; - - cout.width(23); - cout << activesqlstatements[i].sessionid; - - string SQLStatement = activesqlstatements[i].sqlstatement; - int pos = 0; - - for ( ;; ) - { - string printSQL = SQLStatement.substr(pos, 60); - pos = pos + 60; - cout << printSQL << endl; - - if ( printSQL.size() < 60 ) - break; - - cout.width(59); - cout << " "; - } - - cout << endl; - } - - } - catch (exception& e) - { - cout << endl << "Failed to get List of Active SQL Statements: " << e.what() << endl << endl; - } - catch (...) - { - cout << endl << "**** getActiveSQLStatements Failed : Failed to get List of Active SQL Statements" << endl << endl; - break; - } - - break; - } - - case 65: // alterSystem-disableModule - { - if (arguments[1] == "") - { - // need arguments - cout << endl << "**** alterSystem-disableModule Failed : Missing a required Parameter, enter 'help' for additional information" << endl; - break; - } - - parentOAMModule = getParentOAMModule(); - - if ( arguments[1] == parentOAMModule ) - { - // exit out since you can't manually remove OAM Parent Module - cout << endl << "**** alterSystem-disableModule Failed : can't manually disable the Active OAM Parent Module." << endl; - break; - } - - string moduleType = arguments[1].substr(0, MAX_MODULE_TYPE_SIZE); - - gracefulTemp = INSTALL; - - //display Primary UM Module - string PrimaryUMModuleName; - - try - { - oam.getSystemConfig("PrimaryUMModuleName", PrimaryUMModuleName); - } - catch (...) {} - - bool primUM = false; - - if ( PrimaryUMModuleName == arguments[1] ) - { - cout << endl << "This command stops the processing of applications on the Primary User Module, which is where DDL/DML are performed"; - - if (confirmPrompt("If there is another module that can be changed to a new Primary User Module, this will be done")) - break; - - primUM = true; - } - else - { - // confirm request - if ( arguments[2] != "y" ) - { - if (confirmPrompt("This command stops the processing of applications on a Module within the Calpont System")) - break; - } - } - - //parse module names - DeviceNetworkConfig devicenetworkconfig; - DeviceNetworkList devicenetworklist; - - boost::char_separator sep(", "); - boost::tokenizer< boost::char_separator > tokens(arguments[1], sep); - - for ( boost::tokenizer< boost::char_separator >::iterator it = tokens.begin(); - it != tokens.end(); - ++it) - { - devicenetworkconfig.DeviceName = *it; - devicenetworklist.push_back(devicenetworkconfig); - } - - DeviceNetworkList::iterator pt = devicenetworklist.begin(); - DeviceNetworkList::iterator endpt = devicenetworklist.end(); - - bool quit = false; - - // check for module status and if any dbroots still assigned - if ( moduleType == "pm" ) - { - for ( ; pt != endpt ; pt++) - { - // check for dbroots assigned - DBRootConfigList dbrootConfigList; - string moduleID = (*pt).DeviceName.substr(MAX_MODULE_TYPE_SIZE, MAX_MODULE_ID_SIZE); - - try - { - oam.getPmDbrootConfig(atoi(moduleID.c_str()), dbrootConfigList); - } - catch (...) - {} - - if ( !dbrootConfigList.empty() ) - { - cout << endl << "**** alterSystem-disableModule Failed : " << (*pt).DeviceName << " has dbroots still assigned and will not be disabled. Please run movePmDbrootConfig or unassignPmDbrootConfig."; - quit = true; - cout << endl; - break; - } - } - - if (quit) - { - cout << endl; - break; - } - } - - if ( devicenetworklist.empty() ) - { - cout << endl << "quiting, no modules to remove." << endl << endl; - break; - } - - // stop module - try - { - cout << endl << " Stopping Modules" << endl; - oam.stopModule(devicenetworklist, gracefulTemp, ackTemp); - cout << " Successful stop of Modules " << endl; - } - catch (exception& e) - { - - string Failed = e.what(); - - if (Failed.find("Disabled") != string::npos) - cout << endl << " Successful stop of Modules " << endl; - else - { - cout << endl << "**** stopModule Failed : " << e.what() << endl; - break; - } - } - - // disable module - try - { - cout << endl << " Disabling Modules" << endl; - oam.disableModule(devicenetworklist); - cout << " Successful disable of Modules " << endl; - - //display Primary UM Module - string PrimaryUMModuleName; - - try - { - oam.getSystemConfig("PrimaryUMModuleName", PrimaryUMModuleName); - } - catch (...) {} - - if ( primUM && - PrimaryUMModuleName != arguments[1] ) - cout << endl << " New Primary User Module = " << PrimaryUMModuleName << endl; - - } - catch (exception& e) - { - cout << endl << "**** disableModule Failed : " << e.what() << endl; - break; - } - - cout << endl; - break; - } - - case 66: // alterSystem-enableModule - { - if (arguments[1] == "") - { - // need arguments - cout << endl << "**** alterSystem-enableModule Failed : Missing a required Parameter, enter 'help' for additional information" << endl; - break; - } - - string moduleType = arguments[1].substr(0, MAX_MODULE_TYPE_SIZE); - - ACK_FLAG ackTemp = ACK_YES; - - // confirm request - if ( arguments[2] != "y" ) - { - if (confirmPrompt("This command starts the processing of applications on a Module within the Calpont System")) - break; - } - - //parse module names - DeviceNetworkConfig devicenetworkconfig; - DeviceNetworkList devicenetworklist; - boost::char_separator sep(", "); - boost::tokenizer< boost::char_separator > tokens(arguments[1], sep); - - for ( boost::tokenizer< boost::char_separator >::iterator it = tokens.begin(); - it != tokens.end(); - ++it) - { - devicenetworkconfig.DeviceName = *it; - devicenetworklist.push_back(devicenetworkconfig); - } - - //get the system status, enable modules and startmodules if system is ACTIVE - SystemStatus systemstatus; - - try - { - oam.getSystemStatus(systemstatus); - - // enable module - try - { - cout << endl << " Enabling Modules " << endl; - oam.enableModule(devicenetworklist); - cout << " Successful enable of Modules " << endl; - } - catch (exception& e) - { - cout << endl << "**** enableModule Failed : " << e.what() << endl; - break; - } - - if ( moduleType == "pm" ) - { - cout << endl << " Performance Module(s) Enabled, run movePmDbrootConfig or assignDbrootPmConfig to assign dbroots, if needed" << endl << endl; - break; - } - else - { - if (systemstatus.SystemOpState == oam::ACTIVE ) - { - try - { - cout << endl << " Starting Modules" << endl; - oam.startModule(devicenetworklist, ackTemp); - - //reload DBRM with new configuration, needs to be done here after startModule - string cmd = startup::StartUp::installDir() + "/bin/dbrmctl reload > /dev/null 2>&1"; - system(cmd.c_str()); - sleep(15); - - cout << " Successful start of Modules " << endl; - } - catch (exception& e) - { - cout << endl << "**** startModule Failed : " << e.what() << endl; - break; - } - } - else - cout << endl << " System not Active, run 'startSystem' to start system if needed" << endl; - } - } - catch (exception& e) - { - cout << endl << "**** alterSystem-enableModule Failed : " << e.what() << endl; - break; - } - catch (...) - { - cout << endl << "**** alterSystem-enableModule Failed, Failed return from getSystemStatus API" << endl; - break; - } - - cout << endl; - - break; - } - - case 67: // AVAILABLE - { - } - - - default: - { - cout << arguments[0] << ": Unknown Command, type help for list of commands" << endl << endl; - return 1; - } - } - - return 0; -} - -/****************************************************************************************** - * @brief ProcessSupportCommand - * - * purpose: Process Support commands - * - ******************************************************************************************/ -int ProcessSupportCommand(int CommandID, std::string arguments[]) -{ - Oam oam; - GRACEFUL_FLAG gracefulTemp = GRACEFUL; - ACK_FLAG ackTemp = ACK_YES; - CC_SUSPEND_ANSWER suspendAnswer = WAIT; - bool bNeedsConfirm = true; - - switch ( CommandID ) - { - case 0: // helpsupport - { - // display commands in the Support Command list - cout << endl << "List of Support commands" << endl << endl; - - for (int i = 1;; i++) - { - if (supportCmds[i] == "") - // end of list - break; - - cout << " " << supportCmds[i] << endl; - } - - cout << endl; - } - break; - - case 1: // stopprocess - parameters: Process-name, Module-name, Graceful flag, Ack flag - { - if (arguments[2] == "") - { - // need arguments - cout << endl << "**** stopprocess Failed : Missing a required Parameter, Enter Process and Module names" << endl; - break; - } - - // don't allow stopping of Process-Monitor - if ( arguments[1] == "ProcessMonitor" ) - { - cout << "ProcessMonitor is controlled by 'init' and can not be stopped" << endl; - break; - } - else - { - // give warning for Process-Monitor - if ( arguments[1] == "ProcessManager" ) - { - if (confirmPrompt("ProcessManager is the Interface for the Console and should only be removed as part of a Calpont Package installation")) - break; - } - else - { - if ( arguments[3] != "y" ) - { - getFlags(arguments, gracefulTemp, ackTemp, suspendAnswer, bNeedsConfirm); - - // confirm request - if (confirmPrompt("This command stops the processing of an application on a Module within the Calpont System")) - break; - } - } - } - - try - { - oam.stopProcess(arguments[2], arguments[1], gracefulTemp, ackTemp); - cout << endl << " Successful stop of Process " << arguments[1] << endl << endl; - } - catch (exception& e) - { - cout << endl << "**** stopprocess Failed : " << e.what() << endl; - } - } - break; - - case 2: // startprocess - parameters: Process-name, Module-name, Graceful flag, Ack flag - { - if (arguments[2] == "") - { - // need arguments - cout << endl << "**** startprocess Failed : Missing a required Parameter, Enter Process and Module names" << endl; - break; - } - - getFlags(arguments, gracefulTemp, ackTemp, suspendAnswer, bNeedsConfirm); - - try - { - oam.startProcess(arguments[2], arguments[1], gracefulTemp, ackTemp); - cout << endl << " Successful start of Process " << arguments[1] << endl << endl; - } - catch (exception& e) - { - cout << endl << "**** startprocess Failed : " << e.what() << endl; - } - } - break; - - case 3: // restartprocess - parameters: Process-name, Module-name, Graceful flag, Ack flag - { - if (arguments[2] == "") - { - // need arguments - cout << endl << "**** restartprocess Failed : Missing a required Parameter, Enter Process and Module names" << endl; - break; - } - - getFlags(arguments, gracefulTemp, ackTemp, suspendAnswer, bNeedsConfirm); - - // confirm request - if (confirmPrompt("This command restarts the processing of an application on a Module within the Calpont System")) - break; - - try - { - oam.restartProcess(arguments[2], arguments[1], gracefulTemp, ackTemp); - cout << endl << " Successful restart of Process " << arguments[1] << endl << endl; - } - catch (exception& e) - { - cout << endl << "**** restartprocess Failed : " << e.what() << endl; - } - } - break; - - case 4: // killpid - { - if (arguments[1] == "" || arguments[2] != "") - { - // need arguments - cout << endl << "**** killpid Failed : Invalid or Missing Parameter, Enter local Process-ID" << endl; - break; - } - - pid_t PID = atoi(arguments[1].c_str()); - - if ( PID <= 0 ) - { - cout << endl << "**** killpid Failed : Invalid Process-ID Entered" << endl; - break; - } - - int status = kill( PID, SIGTERM); - - if ( status != API_SUCCESS) - cout << endl << " Failure in kill of Process-ID " << arguments[1] << ", Failed: " << errno << endl << endl; - else - cout << endl << " Successful kill of Process-ID " << arguments[1] << endl << endl; - } - break; - - case 5: // rebootsystem - parameters: password - { - if ( !rootUser) - { - cout << endl << "**** rebootsystem Failed : command not available when running as non-root user" << endl; - break; - } - - parentOAMModule = getParentOAMModule(); - - if ( localModule != parentOAMModule ) - { - // exit out since not on Parent OAM Module - cout << endl << "**** rebootsystem Failed : only should be run on the Parent OAM Module, which is '" << parentOAMModule << "'" << endl; - break; - } - - if (arguments[1] == "" || arguments[1] == "y") - { - // need arguments - cout << endl << "**** rebootsystem Failed : Invalid or Missing Parameter, Provide root-password" << endl; - break; - } - - string password = arguments[1]; - - if ( arguments[2] != "y") - { - cout << endl << "!!!!! DESTRUCTIVE COMMAND !!!!!" << endl; - string warning = "This command stops the Processing of applications and reboots all modules within the Calpont System"; - - // confirm request - if (confirmPrompt(warning)) - break; - } - - cout << endl << " Stop System being performed, please wait..." << endl; - - try - { - cout << endl << " System being stopped, please wait... " << endl; - oam.stopSystem(GRACEFUL, ACK_YES); - - if ( waitForStop() ) - cout << endl << " Successful stop of System " << endl << endl; - else - cout << endl << "**** stopSystem Failed : check log files" << endl; - } - catch (exception& e) - { - cout << endl << "**** stopSystem Failed : " << e.what() << endl; - string warning = "stopSystem command failed,"; - - // confirm request - if (confirmPrompt(warning)) - break; - } - - SystemModuleTypeConfig systemmoduletypeconfig; - systemmoduletypeconfig.moduletypeconfig.clear(); - - try - { - oam.getSystemConfig(systemmoduletypeconfig); - - bool FAILED = false; - - for ( unsigned int i = 0 ; i < systemmoduletypeconfig.moduletypeconfig.size(); i++) - { - if ( systemmoduletypeconfig.moduletypeconfig[i].ModuleType.empty() ) - // end of list - break; - - int moduleCount = systemmoduletypeconfig.moduletypeconfig[i].ModuleCount; - string moduletype = systemmoduletypeconfig.moduletypeconfig[i].ModuleType; - - if ( moduleCount > 0 ) - { - DeviceNetworkList::iterator pt = systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.begin(); - - for ( ; pt != systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.end() ; pt++) - { - string modulename = (*pt).DeviceName; - - if (modulename == parentOAMModule ) - { - //do me last - continue; - } - - //skip modules in MAN_DISABLED state - try - { - int opState; - bool degraded; - oam.getModuleStatus(modulename, opState, degraded); - - if (opState == oam::MAN_DISABLED ) - //skip - continue; - } - catch (exception& ex) - {} - - //run remote command script - HostConfigList::iterator pt1 = (*pt).hostConfigList.begin(); - string cmd = startup::StartUp::installDir() + "/bin/remote_command.sh " + (*pt1).IPAddr + " " + password + " reboot " ; - int rtnCode = system(cmd.c_str()); - - if (WEXITSTATUS(rtnCode) != 0) - { - cout << "Failed with running remote_command.sh" << endl; - FAILED = true; - } - else - cout << endl << " Successful reboot request of Module " << modulename << endl; - } - } - } - - if ( FAILED ) - break; - - //reboot local module - int rtnCode = system("reboot"); - - if (WEXITSTATUS(rtnCode) != 0) - cout << "Failed rebooting local module" << endl; - else - { - cout << endl << " Successful reboot request of local Module" << endl; - // close the log file - writeLog("End of a command session!!!"); - logFile.close(); - cout << endl << "Exiting the Calpont Command Console" << endl; - exit (0); - } - } - catch (...) - { - cout << endl << "**** rebootsystem Failed : Failed on getSystemConfig API" << endl; - break; - } - } - break; - - case 6: // rebootnode - parameters: module-name password - { - if ( !rootUser) - { - cout << endl << "**** rebootnode Failed : command not available when running as non-root user" << endl; - break; - } - - if (arguments[1] == "" || arguments[2] == "") - { - // need arguments - cout << endl << "**** rebootnode Failed : Invalid or Missing Parameter, Enter module-name and root-password" << endl; - break; - } - - string inputModuleName = arguments[1]; - string password = arguments[2]; - - if ( arguments[3] != "y") - { - cout << endl << "!!!!! DESTRUCTIVE COMMAND !!!!!" << endl; - string warning = "This command reboots a node within the Calpont System"; - - // confirm request - if (confirmPrompt(warning)) - break; - } - - SystemModuleTypeConfig systemmoduletypeconfig; - systemmoduletypeconfig.moduletypeconfig.clear(); - - try - { - oam.getSystemConfig(systemmoduletypeconfig); - unsigned int i = 0; - - for ( ; i < systemmoduletypeconfig.moduletypeconfig.size(); i++) - { - if ( systemmoduletypeconfig.moduletypeconfig[i].ModuleType.empty() ) - { - // end of list - break; - } - - int moduleCount = systemmoduletypeconfig.moduletypeconfig[i].ModuleCount; - string moduletype = systemmoduletypeconfig.moduletypeconfig[i].ModuleType; - - if ( moduleCount > 0 ) - { - DeviceNetworkList::iterator pt = systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.begin(); - - for ( ; pt != systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.end() ; pt++) - { - string modulename = (*pt).DeviceName; - - if (inputModuleName == modulename ) - { - if (inputModuleName == localModule ) - { - //reboot local module - int rtnCode = system("reboot"); - - if (WEXITSTATUS(rtnCode) != 0) - cout << "Failed rebooting local node" << endl; - else - { - cout << endl << " Successful reboot request of Node " << modulename << endl; - // close the log file - writeLog("End of a command session!!!"); - logFile.close(); - cout << endl << "Exiting the Calpont Command Console" << endl; - exit (0); - } - } - else - { - HostConfigList::iterator pt1 = (*pt).hostConfigList.begin(); - string ipAddr = (*pt1).IPAddr; - //run remote command script - string cmd = startup::StartUp::installDir() + "/bin/remote_command.sh " + ipAddr + " " + password + " reboot " ; - int rtnCode = system(cmd.c_str()); - - if (WEXITSTATUS(rtnCode) != 0) - cout << "Failed with running remote_command.sh" << endl; - else - cout << endl << " Successful reboot request of Node " << modulename << endl; - - return (0); - } - } - } - } - } - } - catch (...) - { - cout << endl << "**** rebootnode Failed : Failed on getSystemConfig API" << endl; - break; - } - } - break; - - case 7: // stopdbrmprocess - { - if ( arguments[1] != "y" ) - { - // confirm request - if (confirmPrompt("This command stops the dbrm processes within the Calpont System")) - break; - } - - try - { - oam.stopProcessType("DBRM"); - cout << endl << " Successful stop of DBRM Processes" << endl << endl; - } - catch (exception& e) - { - cout << endl << "**** stopdbrmprocess Failed : " << e.what() << endl; - } - } - break; - - case 8: // startdbrmprocess - { - try - { - oam.startProcessType("DBRM"); - cout << endl << " Successful Start of DBRM Processes" << endl << endl; - } - catch (exception& e) - { - cout << endl << "**** startdbrmprocess Failed : " << e.what() << endl; - } - } - break; - - case 9: // restartdbrmprocess - { - if ( arguments[1] != "y" ) - { - // confirm request - if (confirmPrompt("This command restarts the dbrm processes within the Calpont System")) - break; - } - - try - { - oam.restartProcessType("DBRM"); - cout << endl << " Successful Restart of DBRM Processes" << endl << endl; - } - catch (exception& e) - { - cout << endl << "**** restartdbrmprocess Failed : " << e.what() << endl; - } - } - break; - - case 10: // setsystemstartupstate - { - Config* sysConfig = Config::makeConfig(); - - parentOAMModule = getParentOAMModule(); - - if ( localModule != parentOAMModule ) - { - // exit out since not on Parent OAM Module - cout << endl << "**** setsystemstartupstate Failed : only should be run on the Parent OAM Module, which is '" << parentOAMModule << "'" << endl; - break; - } - - string systemStartupOffline; - - try - { - systemStartupOffline = sysConfig->getConfig("Installation", "SystemStartupOffline"); - cout << "SystemStartupOffline currently set to '" + systemStartupOffline + "'" << endl; - } - catch (...) - { - cout << "ERROR: Problem getting systemStartupOffline from the Calpont System Configuration file" << endl; - return 1; - } - - while (true) - { - char* pcommand = 0; - string prompt; - string temp = "cancel"; - prompt = "Set system startup state to offline: (y,n,cancel) [cancel]: "; - pcommand = readline(prompt.c_str()); - - if (pcommand) - { - if (strlen(pcommand) > 0) temp = pcommand; - - free(pcommand); - pcommand = 0; - } - - if ( temp == "cancel" ) - return 0; - - if ( temp == "n" || temp == "y") - { - systemStartupOffline = temp; - break; - } - - cout << "Invalid Option, please re-enter" << endl; - } - - try - { - sysConfig->setConfig("Installation", "SystemStartupOffline", systemStartupOffline); - sysConfig->write(); - } - catch (...) - { - cout << "ERROR: Problem setting systemStartupOffline in the Calpont System Configuration file" << endl; - exit(-1); - } - - cout << endl << " Successful setting of systemStartupOffline to '" << systemStartupOffline << "'" << endl << endl; - } - break; - - case 11: // stopPrimProcs - { - if ( arguments[1] != "y" ) - { - // confirm request - if (confirmPrompt("This command stops the PrimProc processes within the Calpont System")) - break; - } - - try - { - oam.stopProcessType("PrimProc"); - cout << endl << " Successful stop of PrimProc Processes" << endl << endl; - } - catch (exception& e) - { - cout << endl << "**** stopPrimProcs Failed : " << e.what() << endl; - } - } - break; - - case 12: // startPrimProcs - { - try - { - oam.startProcessType("PrimProc"); - cout << endl << " Successful Start of PrimProc Processes" << endl << endl; - } - catch (exception& e) - { - cout << endl << "**** startPrimProcs Failed : " << e.what() << endl; - } - } - break; - - case 13: // restartPrimProcs - { - if ( arguments[1] != "y" ) - { - // confirm request - if (confirmPrompt("This command restarts the PrimProc processes within the Calpont System")) - break; - } - - try - { - oam.restartProcessType("PrimProc"); - cout << endl << " Successful Restart of PrimProc Processes" << endl << endl; - } - catch (exception& e) - { - cout << endl << "**** restartPrimProcs Failed : " << e.what() << endl; - } - } - break; - - case 14: // stopExeMgrs - { - if ( arguments[1] != "y" ) - { - // confirm request - if (confirmPrompt("This command stops the ExeMgr processes within the Calpont System")) - break; - } - - try - { - oam.stopProcessType("ExeMgr"); - cout << endl << " Successful stop of ExeMgr Processes" << endl << endl; - } - catch (exception& e) - { - cout << endl << "**** stopExeMgrs Failed : " << e.what() << endl; - } - } - break; - - case 15: // startExeMgrs - { - try - { - oam.startProcessType("ExeMgr"); - cout << endl << " Successful Start of ExeMgr Processes" << endl << endl; - } - catch (exception& e) - { - cout << endl << "**** startExeMgrs Failed : " << e.what() << endl; - } - } - break; - - case 16: // restartExeMgrs - { - if ( arguments[1] != "y" ) - { - // confirm request - if (confirmPrompt("This command restarts the ExeMgr processes within the Calpont System")) - break; - } - - try - { - oam.restartProcessType("ExeMgr"); - cout << endl << " Successful Restart of ExeMgr Processes" << endl << endl; - } - catch (exception& e) - { - cout << endl << "**** restartExeMgrs Failed : " << e.what() << endl; - } - } - break; - - case 17: // getProcessStatusStandby - parameters: NONE - { - printProcessStatus("ProcStatusControlStandby"); - } - break; - - case 18: // distributeconfigfile - parameters: option, moduleName - { - string name = "system"; - - if ( arguments[1] != "" ) - name = arguments[1]; - - try - { - oam.distributeConfigFile(name); - cout << endl << " Successful Distribution of Calpont Config File" << endl << endl; - } - catch (exception& e) - { - cout << endl << "**** Distribution of Calpont Config File Failed : " << e.what() << endl; - } - } - break; - - case 19: // getPmDbrootConfig - paramaters: pm id - { - string pmID; - - if (arguments[1] == "") - { - cout << endl; - string prompt = "Enter the Performance Module ID"; - pmID = dataPrompt(prompt); - } - else - pmID = arguments[1]; - - try - { - DBRootConfigList dbrootConfigList; - oam.getPmDbrootConfig(atoi(pmID.c_str()), dbrootConfigList); - - cout << "DBRoot IDs assigned to 'pm" + pmID + "' = "; - - DBRootConfigList::iterator pt = dbrootConfigList.begin(); - - for ( ; pt != dbrootConfigList.end() ;) - { - cout << oam.itoa(*pt); - pt++; - - if (pt != dbrootConfigList.end()) - cout << ", "; - } - - cout << endl; - } - catch (exception& e) - { - cout << endl << "**** getPmDbrootConfig Failed : " << e.what() << endl; - } - } - break; - - case 20: // getDbrootPmConfig - parameters dbroot id - { - string dbrootID; - - if (arguments[1] == "") - { - cout << endl; - string prompt = "Enter the DBRoot ID"; - dbrootID = dataPrompt(prompt); - } - else - dbrootID = arguments[1]; - - try - { - int pmID; - oam.getDbrootPmConfig(atoi(dbrootID.c_str()), pmID); - - cout << endl << " DBRoot ID " << dbrootID << " is assigned to 'pm" << pmID << "'" << endl; - } - catch (exception& e) - { - cout << endl << "**** getDbrootPmConfig Failed : " << e.what() << endl; - } - } - break; - - case 21: // getSystemDbrootConfig - { - cout << endl << "System DBroot Configuration" << endl << endl; - - try - { - DBRootConfigList dbrootConfigList; - oam.getSystemDbrootConfig(dbrootConfigList); - - cout << "System DBRoot IDs = "; - DBRootConfigList::iterator pt = dbrootConfigList.begin(); - - for ( ; pt != dbrootConfigList.end() ;) - { - cout << oam.itoa(*pt); - pt++; - - if (pt != dbrootConfigList.end()) - cout << ", "; - } - - cout << endl; - } - catch (exception& e) - { - cout << endl << "**** getSystemDbrootConfig Failed : " << e.what() << endl; - } - } - break; - - case 22: // checkDBFunctional - { - try - { - oam.checkDBFunctional(false); - cout << endl << " checkDBFunctional Successful" << endl << endl; - } - catch (exception& e) - { - cout << endl << "**** checkDBFunctional Failed : " << e.what() << endl; - cout << endl << " can check UM /tmp/dbfunctional.log for possible additional information" << endl << endl; - } - catch (...) - { - cout << endl << " checkDBFunctional Failed: check UM /tmp/dbfunctional.log" << endl << endl; - } - } - break; - - case 23: // getsystemreadflags - { - - cout << " Print the DB System Flags. 1 = set and ready, 0 = clear and not ready" << endl; - - BRM::DBRM dbrm; - - cout << endl; - - try - { - cout << "getSystemQueryReady = " << dbrm.getSystemQueryReady() << endl; - } - catch (...) - {} - - try - { - cout << "getSystemReady = " << dbrm.getSystemReady() << endl; - } - catch (...) - {} - - try - { - cout << "getSystemSuspended = " << dbrm.getSystemSuspended() << endl; - } - catch (...) - {} - } - break; - - case 24: // setsystemqueryready - { - BRM::DBRM dbrm; - - string set = "0"; - - if (arguments[1] == "") - { - cout << endl; - string prompt = "Enter 1 for set and 0 for clear"; - set = dataPrompt(prompt); - } - else - set = arguments[1]; - - bool flag = true; - - if ( set == "0" ) - flag = false; - - cout << endl; - - try - { - cout << "getSystemQueryReady = " << dbrm.getSystemQueryReady() << endl; - } - catch (...) - {} - - cout << endl; - - try - { - dbrm.setSystemQueryReady(flag); - cout << "setSystemQueryReady = " << flag << endl; - } - catch (...) - {} - - cout << endl; - - try - { - cout << "getSystemQueryReady = " << dbrm.getSystemQueryReady() << endl; - } - catch (...) - {} - } - - default: // shouldn't get here, but... - return 1; - - } // end of switch - - return 0; -} - -/****************************************************************************************** - * @brief getFlags - * - * purpose: get and convert Graceful and Ack flags - * - ******************************************************************************************/ -void getFlags(const string* arguments, GRACEFUL_FLAG& gracefulTemp, ACK_FLAG& ackTemp, oam::CC_SUSPEND_ANSWER& suspendAnswer, bool& bNeedsConfirm, string* password) -{ - gracefulTemp = GRACEFUL; // default - ackTemp = ACK_YES; // default - suspendAnswer = CANCEL; - bNeedsConfirm = true; - - for ( int i = 1; i < ArgNum; i++) - { - if (strcasecmp(arguments[i].c_str(), "Y") == 0) - bNeedsConfirm = false; - else if (strcasecmp(arguments[i].c_str(), "N") == 0) - bNeedsConfirm = true; - else if (strcasecmp(arguments[i].c_str(), "GRACEFUL") == 0) - gracefulTemp = oam::GRACEFUL; - else if (strcasecmp(arguments[i].c_str(), "FORCEFUL") == 0) - gracefulTemp = FORCEFUL; - else if (strcasecmp(arguments[i].c_str(), "INSTALL") == 0) - gracefulTemp = INSTALL; - else if (strcasecmp(arguments[i].c_str(), "ACK_YES") == 0 || strcasecmp(arguments[i].c_str(), "YES_ACK") == 0) - ackTemp = ACK_YES; - else if (strcasecmp(arguments[i].c_str(), "ACK_NO") == 0 || strcasecmp(arguments[i].c_str(), "NO_ACK") == 0) - ackTemp = ACK_NO; - else if (strcasecmp(arguments[i].c_str(), "WAIT") == 0) - suspendAnswer = WAIT; - else if (strcasecmp(arguments[i].c_str(), "ROLLBACK") == 0) - suspendAnswer = ROLLBACK; - else if (strcasecmp(arguments[i].c_str(), "FORCE") == 0) - suspendAnswer = FORCE; - else if (password && arguments[i].length() > 0) - *password = arguments[i]; - } -} - - -/****************************************************************************************** - * @brief confirmPrompt - * - * purpose: Confirmation prompt - * - ******************************************************************************************/ -int confirmPrompt(std::string warningCommand) -{ - char* pcommand = 0; - char* p; - string argument = "n"; - - while (true) - { - // read input - if (warningCommand.size() > 0) - { - cout << endl << warningCommand << endl; - } - - pcommand = readline(" Do you want to proceed: (y or n) [n]: "); - - if (pcommand && *pcommand) - { - p = strtok(pcommand, " "); - argument = p; - free(pcommand); - pcommand = 0; - } - - if (pcommand) - { - free(pcommand); - pcommand = 0; - } - - // covert argument into lowercase - transform (argument.begin(), argument.end(), argument.begin(), to_lower()); - - if ( argument == "y") - return 0; - else if ( argument == "n") - return 1; - } -} - -/****************************************************************************************** - * @brief dataPrompt - * - * purpose: Prompt for additional data - * - ******************************************************************************************/ -std::string dataPrompt(std::string promptCommand) -{ - char data[CmdSize]; - char* pdata = data; - char* pd; - string argument; - - while (true) - { - // read input - cout << promptCommand << endl; - pdata = readline(" Please enter: "); - - if (!pdata) // user hit -D - pdata = strdup("exit"); - - else if (!*pdata) - // just an enter-key was entered, ignore and reprompt - continue; - - pd = pdata; - argument = pd; - - return argument; - } -} - - -/****************************************************************************************** - * @brief writeLog for command - * - * purpose: write command to the log file - * - ******************************************************************************************/ -void writeLog(string command) -{ - Oam oam; - - //filter off password on reboot commands - - logFile << oam.getCurrentTime() << ": " << command << endl; - logFile.flush(); - return; -} - -/****************************************************************************************** - * @brief printAlarmSummary - * - * purpose: get active alarms and produce a summary - * - ******************************************************************************************/ -void printAlarmSummary() -{ - AlarmList alarmList; - Oam oam; - - try - { - oam.getActiveAlarms(alarmList); - } - catch (...) - { - return; - } - - int critical = 0, major = 0, minor = 0, warning = 0, info = 0; - AlarmList :: iterator i; - - for (i = alarmList.begin(); i != alarmList.end(); ++i) - { - switch (i->second.getSeverity()) - { - case CRITICAL: - ++critical; - break; - - case MAJOR: - ++major; - break; - - case MINOR: - ++minor; - break; - - case WARNING: - ++warning; - break; - - case INFORMATIONAL: - ++info; - break; - } - } - - cout << endl << "Active Alarm Counts: "; - cout << "Critical = " << critical; - cout << ", Major = " << major; - cout << ", Minor = " << minor; - cout << ", Warning = " << warning; - cout << ", Info = " << info; - cout << endl; -} - -/****************************************************************************************** - * @brief printCriticalAlarms - * - * purpose: get active Critical alarms - * - ******************************************************************************************/ -void printCriticalAlarms() -{ - AlarmList alarmList; - Oam oam; - - try - { - oam.getActiveAlarms(alarmList); - } - catch (...) - { - return; - } - - cout << endl << "Critical Active Alarms:" << endl << endl; - - AlarmList :: iterator i; - - for (i = alarmList.begin(); i != alarmList.end(); ++i) - { - switch (i->second.getSeverity()) - { - case CRITICAL: - cout << "AlarmID = " << i->second.getAlarmID() << endl; - cout << "Brief Description = " << i->second.getDesc() << endl; - cout << "Alarm Severity = "; - cout << "CRITICAL" << endl; - cout << "Time Issued = " << i->second.getTimestamp() << endl; - cout << "Reporting Module = " << i->second.getSname() << endl; - cout << "Reporting Process = " << i->second.getPname() << endl; - cout << "Reported Device = " << i->second.getComponentID() << endl << endl; - break; - - case MAJOR: - case MINOR: - case WARNING: - case INFORMATIONAL: - break; - } - } -} - -/****************************************************************************************** - * @brief printSystemStatus - * - * purpose: get and Display System and Module Statuses - * - ******************************************************************************************/ -void printSystemStatus() -{ - SystemStatus systemstatus; - Oam oam; - BRM::DBRM dbrm(true); - - cout << endl << "System " << systemName << endl << endl; - cout << "System and Module statuses" << endl << endl; - cout << "Component Status Last Status Change" << endl; - cout << "------------ -------------------------- ------------------------" << endl; - - try - { - oam.getSystemStatus(systemstatus, false); - cout << "System "; - cout.setf(ios::left); - cout.width(29); - int state = systemstatus.SystemOpState; - string extraInfo = " "; - bool bRollback = false; - bool bForce = false; - - if (dbrm.isDBRMReady()) - { - if (dbrm.getSystemSuspended() > 0) - { - extraInfo = " WRITE SUSPENDED"; - } - else if (dbrm.getSystemSuspendPending(bRollback) > 0) - { - extraInfo = " WRITE SUSPEND PENDING"; - } - else if (dbrm.getSystemShutdownPending(bRollback, bForce) > 0) - { - extraInfo = " SHUTDOWN PENDING"; - } - } - - printState(state, extraInfo); - cout.width(24); - string stime = systemstatus.StateChangeDate; - stime = stime.substr (0, 24); - cout << stime << endl << endl; - - for ( unsigned int i = 0 ; i < systemstatus.systemmodulestatus.modulestatus.size(); i++) - { - if ( systemstatus.systemmodulestatus.modulestatus[i].Module.empty() ) - // end of list - break; - - cout << "Module "; - cout.setf(ios::left); - cout.width(7); - cout << systemstatus.systemmodulestatus.modulestatus[i].Module; - cout.width(29); - state = systemstatus.systemmodulestatus.modulestatus[i].ModuleOpState; - - // get NIC functional state (degraded or not) - bool degraded = false; - - try - { - int state; - oam.getModuleStatus(systemstatus.systemmodulestatus.modulestatus[i].Module, state, degraded); - } - catch (...) - {} - - string nicFun = " "; - - if (degraded) - nicFun = "/" + DEGRADEDSTATE; - - printState(state, nicFun); - - cout.width(24); - string stime = systemstatus.systemmodulestatus.modulestatus[i].StateChangeDate ; - stime = stime.substr (0, 24); - cout << stime << endl; - } - - cout << endl; - - if ( systemstatus.systemmodulestatus.modulestatus.size() > 1) - { - // get and display Parent OAM Module - cout << "Active Parent OAM Performance Module is '" << getParentOAMModule() << "'" << endl; - - //display Primary UM Module - string PrimaryUMModuleName; - - try - { - oam.getSystemConfig("PrimaryUMModuleName", PrimaryUMModuleName); - } - catch (...) {} - - if ( serverInstallType != oam::INSTALL_COMBINE_DM_UM_PM ) - { - ModuleTypeConfig moduletypeconfig; - - try - { - oam.getSystemConfig("um", moduletypeconfig); - } - catch (...) - {} - - if ( moduletypeconfig.ModuleCount > 1 ) - { - if ( PrimaryUMModuleName != oam::UnassignedName ) - cout << "Primary Front-End MySQL Module is '" << PrimaryUMModuleName << "'" << endl; - } - } - else - { - if ( PrimaryUMModuleName != oam::UnassignedName ) - cout << "Primary Front-End MySQL Module is '" << PrimaryUMModuleName << "'" << endl; - } - } - - //display local Query / PMwithUM feature, if enabled - string PMwithUM; - - try - { - oam.getSystemConfig("PMwithUM", PMwithUM); - } - catch (...) {} - - if ( PMwithUM == "y" ) - cout << "Local Query Feature is enabled" << endl; - - //display MySQL replication feature, if enabled - string MySQLRep; - - try - { - oam.getSystemConfig("MySQLRep", MySQLRep); - } - catch (...) {} - - if ( MySQLRep == "y" ) - cout << "MySQL Replication Feature is enabled" << endl << endl; - } - catch (exception& e) - { - cout << endl << "**** printSystemStatus Failed = " << e.what() << endl; - throw runtime_error(""); - } -} - -/****************************************************************************************** - * @brief printProcessStatus - * - * purpose: get and Display Process Statuses - * - ******************************************************************************************/ -void printProcessStatus(std::string port) -{ - SystemProcessStatus systemprocessstatus; - ProcessStatus processstatus; - ModuleTypeConfig moduletypeconfig; - Oam oam; - BRM::DBRM dbrm(true); - - int state; - string extraInfo = " "; - bool bRollback = false; - bool bForce = false; - bool bSuspend = false; - - if (dbrm.isDBRMReady()) - { - if (dbrm.getSystemSuspended() > 0) - { - bSuspend = true; - extraInfo = "WRITE_SUSPEND"; - } - else if (dbrm.getSystemSuspendPending(bRollback) > 0) - { - bSuspend = true; - - if (bRollback) - { - extraInfo = "ROLLBACK"; - } - else - { - extraInfo = "SUSPEND_PENDING"; - } - } - else if (dbrm.getSystemShutdownPending(bRollback, bForce) > 0) - { - bSuspend = true; - - if (bRollback) - { - extraInfo = "ROLLBACK"; - } - else - { - extraInfo = "SHUTDOWN_PENDING"; - } - } - } - - cout << endl << "Calpont Process statuses" << endl << endl; - cout << "Process Module Status Last Status Change Process ID" << endl; - cout << "------------------ ------ --------------- ------------------------ ----------" << endl; - - try - { - oam.getProcessStatus(systemprocessstatus, port); - - string prevModule = systemprocessstatus.processstatus[0].Module; - - for ( unsigned int i = 0 ; i < systemprocessstatus.processstatus.size(); i++) - { - if ( prevModule != systemprocessstatus.processstatus[i].Module) - cout << endl; //added a space line between different modules - - cout.setf(ios::left); - cout.width(20); - cout << systemprocessstatus.processstatus[i].ProcessName; - cout.width(10); - cout << systemprocessstatus.processstatus[i].Module; - cout.width(18); - state = systemprocessstatus.processstatus[i].ProcessOpState; - - // For these processes, if state is ACTIVE and we're in write - // suspend, then we want to display the extra data instead of state. - // Otherwise, we ignore extra data and display state. - if (state == ACTIVE && bSuspend && - ( systemprocessstatus.processstatus[i].ProcessName == "DMLProc" - || systemprocessstatus.processstatus[i].ProcessName == "DDLProc" - || systemprocessstatus.processstatus[i].ProcessName == "WriteEngineServer")) - { - printState(LEAVE_BLANK, extraInfo); - } - else - { - state = systemprocessstatus.processstatus[i].ProcessOpState; - printState(state, " "); - } - - cout.width(24); - string stime = systemprocessstatus.processstatus[i].StateChangeDate ; - stime = stime.substr (0, 24); - cout << stime; - - if ( state == COLD_STANDBY ) - { - cout << endl; - continue; - } - else - { - cout.setf(ios::right); - cout.width(12); - - if ( systemprocessstatus.processstatus[i].ProcessID != 0 ) - cout << systemprocessstatus.processstatus[i].ProcessID << endl; - else - cout << endl; - } - - cout.unsetf(ios::right); - - prevModule = systemprocessstatus.processstatus[i].Module; - - } - } - catch (exception& e) - { - cout << endl << "**** printProcessStatus Failed = " << e.what() << endl; - throw runtime_error(""); - } -} - -/****************************************************************************************** - * @brief printModuleCpuUsers - * - * purpose: get and Display Module TOP CPU users - * - ******************************************************************************************/ -void printModuleCpuUsers(TopProcessCpuUsers topprocesscpuusers) -{ - cout << "Module '" + topprocesscpuusers.ModuleName + "' Top CPU Users" << endl << endl; - cout << "Process CPU Usage %" << endl; - cout << "----------------- -----------" << endl; - - for ( unsigned int i = 0 ; i < topprocesscpuusers.processcpuuser.size(); i++) - { - cout.setf(ios::left); - cout.width(25); - cout << topprocesscpuusers.processcpuuser[i].ProcessName; - cout.width(10); - cout << topprocesscpuusers.processcpuuser[i].CpuUsage << endl; - } - - cout << endl; -} - -/****************************************************************************************** - * @brief printModuleCpu - * - * purpose: get and Display Module CPU Usage - * - ******************************************************************************************/ -void printModuleCpu(ModuleCpu modulecpu) -{ - Oam oam; - - cout << endl << "Module '" + modulecpu.ModuleName + "' CPU Usage % = " + oam.itoa(modulecpu.CpuUsage) << endl; -} - -/****************************************************************************************** - * @brief printModuleMemoryUsers - * - * purpose: get and Display Module TOP Memory users - * - ******************************************************************************************/ -void printModuleMemoryUsers(TopProcessMemoryUsers topprocessmemoryusers) -{ - cout << "Module '" + topprocessmemoryusers.ModuleName + "' Top Memory Users (in bytes)" << endl << endl; - cout << "Process Memory Used Memory Usage %" << endl; - cout << "----------------- ----------- --------------" << endl; - - for ( unsigned int i = 0 ; i < topprocessmemoryusers.processmemoryuser.size(); i++) - { - cout.setf(ios::left); - cout.width(20); - cout << topprocessmemoryusers.processmemoryuser[i].ProcessName; - cout.width(19); - cout << topprocessmemoryusers.processmemoryuser[i].MemoryUsed; - cout.width(3); - cout << topprocessmemoryusers.processmemoryuser[i].MemoryUsage << endl; - } - - cout << endl; -} - -/****************************************************************************************** - * @brief printModuleMemory - * - * purpose: get and Display Module Memory Usage - * - ******************************************************************************************/ -void printModuleMemory(ModuleMemory modulememory) -{ - Oam oam; - cout.setf(ios::left); - cout.width(8); - cout << modulememory.ModuleName; - cout.width(11); - cout << oam.itoa(modulememory.MemoryTotal); - cout.width(10); - cout << oam.itoa(modulememory.MemoryUsed); - cout.width(13); - cout << oam.itoa(modulememory.cache); - cout.width(9); - cout << oam.itoa(modulememory.MemoryUsage); - cout.width(12); - cout << oam.itoa(modulememory.SwapTotal); - cout.width(16); - cout << oam.itoa(modulememory.SwapUsed); - cout.width(7); - cout << oam.itoa(modulememory.SwapUsage); - cout << endl; -} - -/****************************************************************************************** - * @brief printModuleDisk - * - * purpose: get and Display Module disk usage - * - ******************************************************************************************/ -void printModuleDisk(ModuleDisk moduledisk) -{ - Oam oam; - - cout << "Module '" + moduledisk.ModuleName + "' Disk Usage (in 1K blocks)" << endl << endl; - cout << "Mount Point Total Blocks Used Blocks Usage %" << endl; - cout << "----------------------------- ------------ ------------ -------" << endl; - - string etcdir = startup::StartUp::installDir() + "/etc"; - - for ( unsigned int i = 0 ; i < moduledisk.diskusage.size(); i++) - { - //skip mounts to other server disk - if ( moduledisk.diskusage[i].DeviceName.find("/mnt", 0) == string::npos && - moduledisk.diskusage[i].DeviceName.find(etcdir, 0) == string::npos ) - { - cout.setf(ios::left); - cout.width(31); - cout << moduledisk.diskusage[i].DeviceName; - cout.width(14); - cout << moduledisk.diskusage[i].TotalBlocks; - cout.width(17); - cout << moduledisk.diskusage[i].UsedBlocks; - cout.width(2); - cout << moduledisk.diskusage[i].DiskUsage << endl; - } - } - - cout << endl; -} - -/****************************************************************************************** - * @brief printModuleResources - * - * purpose: get and Display Module resource usage - * - ******************************************************************************************/ -void printModuleResources(TopProcessCpuUsers topprocesscpuusers, ModuleCpu modulecpu, TopProcessMemoryUsers topprocessmemoryusers, ModuleMemory modulememory, ModuleDisk moduledisk) -{ - Oam oam; - string etcdir = startup::StartUp::installDir() + "/etc"; - - cout << endl << "Module '" + topprocesscpuusers.ModuleName + "' Resource Usage" << endl << endl; - - cout << "CPU: " + oam.itoa(modulecpu.CpuUsage) << "% Usage" << endl; - - cout << "Mem: " << oam.itoa(modulememory.MemoryTotal) << "k total, " << oam.itoa(modulememory.MemoryUsed); - cout << "k used, " << oam.itoa(modulememory.cache) << "k cache, " << oam.itoa(modulememory.MemoryUsage) << "% Usage" << endl; - cout << "Swap: " << oam.itoa(modulememory.SwapTotal) << " k total, " << oam.itoa(modulememory.SwapUsed); - cout << "k used, " << oam.itoa(modulememory.SwapUsage) << "% Usage" << endl; - - cout << "Top CPU Process Users: "; - - for ( unsigned int i = 0 ; i < topprocesscpuusers.processcpuuser.size(); i++) - { - cout << topprocesscpuusers.processcpuuser[i].ProcessName << " "; - cout << topprocesscpuusers.processcpuuser[i].CpuUsage; - - if ( i + 1 != topprocesscpuusers.processcpuuser.size() ) - cout << "%, "; - else - cout << "%"; - } - - cout << endl; - - cout << "Top Memory Process Users: "; - - for ( unsigned int i = 0 ; i < topprocessmemoryusers.processmemoryuser.size(); i++) - { - cout << topprocessmemoryusers.processmemoryuser[i].ProcessName << " "; - cout << topprocessmemoryusers.processmemoryuser[i].MemoryUsage; - - if ( i + 1 != topprocessmemoryusers.processmemoryuser.size() ) - cout << "%, "; - else - cout << "%"; - } - - cout << endl; - - cout << "Disk Usage: "; - - for ( unsigned int i = 0 ; i < moduledisk.diskusage.size(); i++) - { - //skip mounts to other server disk - if ( moduledisk.diskusage[i].DeviceName.find("/mnt", 0) == string::npos && - moduledisk.diskusage[i].DeviceName.find(etcdir, 0) == string::npos ) - { - cout << moduledisk.diskusage[i].DeviceName << " "; - cout << moduledisk.diskusage[i].DiskUsage; - - if ( i + 1 != moduledisk.diskusage.size() ) - cout << "%, "; - else - cout << "%"; - } - } - - cout << endl << endl; -} - -/****************************************************************************************** - * @brief printModuleResources - * - * purpose: get and Display Module resource usage - * - ******************************************************************************************/ -void printState(int state, std::string addInfo) -{ - switch (state) - { - case MAN_OFFLINE: - cout << MANOFFLINE + addInfo; - break; - - case AUTO_OFFLINE: - cout << AUTOOFFLINE + addInfo; - break; - - case MAN_INIT: - cout << MANINIT + addInfo; - break; - - case AUTO_INIT: - cout << AUTOINIT + addInfo; - break; - - case ACTIVE: - cout << ACTIVESTATE + addInfo; - break; - - case LEAVE_BLANK: - cout << addInfo; - break; - - case STANDBY: - cout << STANDBYSTATE + addInfo; - break; - - case FAILED: - cout << FAILEDSTATE + addInfo; - break; - - case UP: - cout << UPSTATE + addInfo; - break; - - case DOWN: - cout << DOWNSTATE + addInfo; - break; - - case COLD_STANDBY: - cout << COLDSTANDBYSTATE + addInfo; - break; - - case INITIAL: - cout << INITIALSTATE + addInfo; - break; - - case MAN_DISABLED: - cout << MANDISABLEDSTATE + addInfo; - break; - - case AUTO_DISABLED: - cout << AUTODISABLEDSTATE + addInfo; - break; - - case STANDBY_INIT: - cout << STANDBYINIT + addInfo; - break; - - case BUSY_INIT: - cout << BUSYINIT + addInfo; - break; - - case DEGRADED: - cout << DEGRADEDSTATE + addInfo; - break; - - default: - cout << INITIALSTATE + addInfo; - break; - } -} - -/****************************************************************************************** - * @brief checkPromptThread - * - * purpose: check for exit out of repeat command - * - ******************************************************************************************/ -static void checkPromptThread() -{ - char* pcommand = 0; - - while (true) - { - // check input - pcommand = readline(""); - - if (!pcommand) // user hit -D - { - repeatStop = true; - break; - } - - free(pcommand); - pcommand = 0; - } - - pthread_exit(0); - return; -} - -/****************************************************************************************** - * @brief getParentOAMModule - * - * purpose: get Parent OAm Module name - * - ******************************************************************************************/ -std::string getParentOAMModule() -{ - Oam oam; - - // Get Parent OAM module Name - try - { - string parentOAMModule; - oam.getSystemConfig("ParentOAMModuleName", parentOAMModule); - return parentOAMModule; - } - catch (...) - { - cout << endl << "**** Failed : Failed to read Parent OAM Module Name" << endl; - exit(-1); - } -} - -/****************************************************************************************** - * @brief checkForDisabledModules - * - * purpose: Chcek and report any modules in a disabled state - * - ******************************************************************************************/ -bool checkForDisabledModules() -{ - - SystemModuleTypeConfig systemmoduletypeconfig; - Oam oam; - - try - { - oam.getSystemConfig(systemmoduletypeconfig); - } - catch (...) - { - return false; - } - - bool found = false; - bool dbroot = false; - - for ( unsigned int i = 0 ; i < systemmoduletypeconfig.moduletypeconfig.size(); i++) - { - int moduleCount = systemmoduletypeconfig.moduletypeconfig[i].ModuleCount; - - if ( moduleCount == 0) - continue; - - string moduleType = systemmoduletypeconfig.moduletypeconfig[i].ModuleType; - - DeviceNetworkList::iterator pt = systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.begin(); - - for ( ; pt != systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.end(); pt++) - { - string moduleName = (*pt).DeviceName; - - // report DISABLED modules - try - { - int opState; - bool degraded; - oam.getModuleStatus(moduleName, opState, degraded); - - if (opState == oam::MAN_DISABLED || opState == oam::AUTO_DISABLED) - { - if (!found) - { - cout << " NOTE: These module(s) are DISABLED: "; - found = true; - } - - cout << moduleName << " "; - - if ( moduleType == "um" ) - continue; - - //check if module has any dbroots assigned to it - string PMID = moduleName.substr(MAX_MODULE_TYPE_SIZE, MAX_MODULE_ID_SIZE);; - DBRootConfigList dbrootConfigList; - - try - { - oam.getPmDbrootConfig(atoi(PMID.c_str()), dbrootConfigList); - - if ( dbrootConfigList.size() != 0 ) - dbroot = true; - } - catch (exception& e) - {} - } - } - catch (...) - {} - } - } - - if (found) - cout << endl << endl; - - if (dbroot) - return false; - - return true; -} - -/** @brief Ask the user for cancel/wait/rollback/force - * - * When a Shutdown, stop, restart or suspend operation is - * requested but there are active transactions of some sort, - * we ask the user what to do. - */ -CC_SUSPEND_ANSWER AskSuspendQuestion(int CmdID) -{ - char* szAnswer = 0; - char* p; - string argument = "cancel"; - - const char* szCommand = "Unknown"; - - switch (CmdID) - { - case 16: - szCommand = "stop"; - break; - - case 17: - szCommand = "shutdown"; - break; - - case 19: - szCommand = "restart"; - break; - - case 28: - szCommand = "switch parent oam"; - break; - - case 32: - szCommand = "suspend"; - break; - - default: - return CANCEL; - break; - } - - cout << "Your options are:" << endl - << " Cancel -- Cancel the " << szCommand << " request" << endl - << " Wait -- Wait for write operations to end and then " << szCommand << endl; - -// << " Rollback -- Rollback all transactions and then " << szCommand << endl; - if (CmdID != 28 && CmdID != 32) - { - cout << " Force -- Force a " << szCommand << endl; - } - - while (true) - { - argument = "cancel"; - // read input - szAnswer = readline("What would you like to do: [Cancel]: "); - - if (szAnswer && *szAnswer) - { - p = strtok(szAnswer, " "); - argument = p; - free(szAnswer); - szAnswer = 0; - } - - // In case they just hit return. - if (szAnswer) - { - free(szAnswer); - szAnswer = 0; - } - - // convert argument into lowercase - transform(argument.begin(), argument.end(), argument.begin(), to_lower()); - - if ( argument == "cancel") - { - return CANCEL; - } - else if ( argument == "wait") - { - return WAIT; - } -// else if( argument == "rollback") -// { -// return ROLLBACK; -// } - else if ( argument == "force" && (CmdID == 16 || CmdID == 17 || CmdID == 19)) - { - return FORCE; - } - else - { - cout << argument << " is an invalid response" << endl; - } - } -} - -// vim:ts=4 sw=4: - diff --git a/oamapps/calpontConsole/calpontConsole.h b/oamapps/calpontConsole/calpontConsole.h deleted file mode 100644 index 11613358f..000000000 --- a/oamapps/calpontConsole/calpontConsole.h +++ /dev/null @@ -1,135 +0,0 @@ -/* Copyright (C) 2014 InfiniDB, Inc. - - This program 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; version 2 of - the License. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - MA 02110-1301, USA. */ - -/****************************************************************************************** - * $Id: calpontConsole.h 3071 2013-04-04 18:45:53Z rdempsey $ - * - ******************************************************************************************/ -/** - * @file - */ -#ifndef CALPONTCONSOLE_H -#define CALPONTCONSOLE_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "liboamcpp.h" -#include "configcpp.h" -#include "alarmmanager.h" -#include "alarmglobal.h" -#include "calpontsystemcatalog.h" -#include "brmtypes.h" - - -const int CmdSize = 80; -const int ArgNum = 10; -const int DescNumMax = 10; -const int cmdNum = 68; - -const std::string DEFAULT_LOG_FILE = "/var/log/mariadb/columnstore/uiCommands.log"; -std::ofstream logFile; - -/** - * write the command to the log file - */ -void writeLog(std::string command); - -/** @brief location of the Process Configuration file - */ -const std::string ConsoleCmdsFile = "ConsoleCmds.xml"; - -void getFlags(const std::string* arguments, oam::GRACEFUL_FLAG& gracefulTemp, oam::ACK_FLAG& ackTemp, oam::CC_SUSPEND_ANSWER& suspendAnswer, bool& bNeedsConfirm, std::string* password = NULL); -int confirmPrompt(std::string warningCommand); -std::string dataPrompt(std::string promptCommand); -int processCommand(std::string*); -int ProcessSupportCommand(int CommandID, std::string arguments[]); -void printAlarmSummary(); -void printCriticalAlarms(); -void checkRepeat(std::string*, int); -void printSystemStatus(); -void printProcessStatus(std::string port = "ProcStatusControl"); -void printModuleCpuUsers(oam::TopProcessCpuUsers topprocesscpuusers); -void printModuleCpu(oam::ModuleCpu modulecpu); -void printModuleMemoryUsers(oam::TopProcessMemoryUsers topprocessmemoryusers); -void printModuleMemory(oam::ModuleMemory modulememory); -void printModuleDisk(oam::ModuleDisk moduledisk); -void printModuleResources(oam::TopProcessCpuUsers topprocesscpuusers, oam::ModuleCpu modulecpu, oam::TopProcessMemoryUsers topprocessmemoryusers, oam::ModuleMemory modulememory, oam::ModuleDisk moduledisk); -void printState(int state, std::string addInfo); -std::string getParentOAMModule(); -bool checkForDisabledModules(); -oam::CC_SUSPEND_ANSWER AskSuspendQuestion(int CmdID); - - - -class to_lower -{ -public: - char operator() (char c) const // notice the return type - { - return tolower(c); - } -}; - -/** @brief Hidden Support commands in lower-case -*/ -const std::string supportCmds[] = { "helpsupport", - "stopprocess", - "startprocess", - "restartprocess", - "killpid", - "rebootsystem", - "rebootnode", - "stopdbrmprocess", - "startdbrmprocess", - "restartdbrmprocess", - "setsystemstartupstate", - "stopprimprocs", - "startprimprocs", - "restartprimprocs", - "stopexemgrs", - "startexemgrs", - "restartexemgrs", - "getprocessstatusstandby", - "distributeconfigfile", - "getpmdbrootconfig", - "getdbrootpmconfig", - "getsystemdbrootconfig", - "checkdbfunctional", - "getsystemreadflags", - "setsystemqueryready", - "" - }; - - -#endif diff --git a/oamapps/calpontConsole/tdriver.cpp b/oamapps/calpontConsole/tdriver.cpp deleted file mode 100644 index 5be1266e9..000000000 --- a/oamapps/calpontConsole/tdriver.cpp +++ /dev/null @@ -1,380 +0,0 @@ -/* Copyright (C) 2014 InfiniDB, Inc. - - This program 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; version 2 of - the License. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - MA 02110-1301, USA. */ - -/*************************************************************************** -* $Id: tdriver.cpp 3072 2013-04-04 19:04:45Z rdempsey $ -* - * dhill@srvengcm1.calpont.com - * - * Purpose: Calpont Console tester - * - ***************************************************************************/ - -#include -#include -using namespace std; - -#include -using namespace boost; - -#include - -class GeneralCmdsTest : public CppUnit::TestFixture -{ - - CPPUNIT_TEST_SUITE( GeneralCmdsTest ); - - CPPUNIT_TEST( test1 ); - CPPUNIT_TEST( test2 ); - CPPUNIT_TEST( test3 ); - CPPUNIT_TEST( test4 ); - CPPUNIT_TEST( test5 ); - CPPUNIT_TEST( test6 ); - CPPUNIT_TEST( test7 ); - - CPPUNIT_TEST_SUITE_END(); - -private: - -public: - void setUp() - { - } - - void tearDown() - { - } - - void test1() - { - system("./calpontConsole help > tdriver.output"); - } - - void test2() - { - system("./calpontConsole ? >> tdriver.output"); - } - - void test3() - { - system("./calpontConsole help verbose >> tdriver.output"); - } - - void test4() - { - system("./calpontConsole help getAlarmConfig >> tdriver.output"); - } - - void test5() - { - system("./calpontConsole exit >> tdriver.output"); - } - - void test6() - { - system("./calpontConsole quit >> tdriver.output"); - } - - void test7() - { - system("./calpontConsole system ls -ltr >> tdriver.output"); - } -}; - -class AlarmConfigTest : public CppUnit::TestFixture -{ - - CPPUNIT_TEST_SUITE( AlarmConfigTest ); - - CPPUNIT_TEST( test1 ); - CPPUNIT_TEST( test2 ); - CPPUNIT_TEST( test3 ); - CPPUNIT_TEST( test4 ); - - CPPUNIT_TEST_SUITE_END(); - -private: - -public: - void setUp() - { - } - - void tearDown() - { - } - - void test1() - { - system("./calpontConsole getAlarmConfig >> tdriver.output"); - } - - void test2() - { - system("./calpontConsole getAlarmConfig 1 >> tdriver.output"); - } - - void test3() - { - system("./calpontConsole setAlarmConfig 1 Threshold 50 >> tdriver.output"); - } - - void test4() - { - system("./calpontConsole getAlarmConfig 1 >> tdriver.output"); - } - -}; - -class ProcessConfigTest : public CppUnit::TestFixture -{ - - CPPUNIT_TEST_SUITE( ProcessConfigTest ); - - CPPUNIT_TEST( test1 ); - CPPUNIT_TEST( test2 ); - CPPUNIT_TEST( test3 ); - CPPUNIT_TEST( test4 ); - CPPUNIT_TEST( test5 ); - CPPUNIT_TEST( test6 ); - CPPUNIT_TEST( test7 ); - - CPPUNIT_TEST_SUITE_END(); - -private: - -public: - void setUp() - { - } - - void tearDown() - { - } - - void test1() - { - system("./calpontConsole getProcessConfig >> tdriver.output"); - } - - void test2() - { - system("./calpontConsole getProcessConfig ProcessManager dm1 >> tdriver.output"); - } - - void test3() - { - system("./calpontConsole getProcessConfig ProcessManager dm1 LaunchID >> tdriver.output"); - } - - void test4() - { - system("./calpontConsole setProcessConfig ProcessManager dm1 LaunchID 1 >> tdriver.output"); - } - - void test5() - { - system("./calpontConsole getProcessConfig ProcessManager dm1 LaunchID >> tdriver.output"); - } - - void test6() - { - system("./calpontConsole setProcessConfig ProcessManager dm1 LaunchID 3 >> tdriver.output"); - } - - void test7() - { - system("./calpontConsole getProcessConfig ProcessManager dm1 LaunchID >> tdriver.output"); - } - -}; - -class ServerConfigTest : public CppUnit::TestFixture -{ - - CPPUNIT_TEST_SUITE( ServerConfigTest ); - - CPPUNIT_TEST( test1 ); - CPPUNIT_TEST( test2 ); - CPPUNIT_TEST( test3 ); - CPPUNIT_TEST( test4 ); - CPPUNIT_TEST( test5 ); - CPPUNIT_TEST( test6 ); - CPPUNIT_TEST( test7 ); - - CPPUNIT_TEST_SUITE_END(); - -private: - -public: - void setUp() - { - } - - void tearDown() - { - } - - void test1() - { - system("./calpontConsole getModuleConfig >> tdriver.output"); - } - - void test2() - { - system("./calpontConsole getModuleConfig dm1 >> tdriver.output"); - } - - void test3() - { - system("./calpontConsole getModuleConfig dm1 ServerCPUCriticalThreshold >> tdriver.output"); - } - - void test4() - { - system("./calpontConsole setModuleConfig dm1 ServerCPUCriticalThreshold 9999 >> tdriver.output"); - } - - void test5() - { - system("./calpontConsole getModuleConfig dm1 ServerCPUCriticalThreshold >> tdriver.output"); - } - - void test6() - { - system("./calpontConsole setModuleConfig dm1 ServerCPUCriticalThreshold 9000 >> tdriver.output"); - } - - void test7() - { - system("./calpontConsole getModuleConfig dm1 ServerCPUCriticalThreshold >> tdriver.output"); - } - -}; - -class SystemConfigTest : public CppUnit::TestFixture -{ - - CPPUNIT_TEST_SUITE( SystemConfigTest ); - - CPPUNIT_TEST( test1 ); - CPPUNIT_TEST( test2 ); - CPPUNIT_TEST( test3 ); - CPPUNIT_TEST( test4 ); - - CPPUNIT_TEST_SUITE_END(); - -private: - -public: - void setUp() - { - } - - void tearDown() - { - } - - void test1() - { - system("./calpontConsole getSystemConfig >> tdriver.output"); - } - - void test2() - { - system("./calpontConsole getSystemConfig SystemVersion >> tdriver.output"); - } - - void test3() - { - system("./calpontConsole setSystemConfig SystemVersion 2.0.0.0 >> tdriver.output"); - } - - void test4() - { - system("./calpontConsole getSystemConfig SystemVersion >> tdriver.output"); - } - -}; - -class SystemActionTest : public CppUnit::TestFixture -{ - - CPPUNIT_TEST_SUITE( SystemActionTest ); - - CPPUNIT_TEST( test1 ); // valid, but will fail command - CPPUNIT_TEST( test2 ); // valid, but will fail command - CPPUNIT_TEST( test3 ); // valid, but will fail command - CPPUNIT_TEST( test4 ); // valid, but will fail command - - - CPPUNIT_TEST_SUITE_END(); - -private: - -public: - void setUp() - { - } - - void tearDown() - { - } - - void test1() - { - system("./calpontConsole stopSystem >> tdriver.output"); - } - - void test2() - { - system("./calpontConsole shutdownSystem >> tdriver.output"); - } - - void test3() - { - system("./calpontConsole startSystem >> tdriver.output"); - } - - void test4() - { - system("./calpontConsole restartSystem >> tdriver.output"); - } - -}; - - -//CPPUNIT_TEST_SUITE_REGISTRATION( SystemActionTest ); -CPPUNIT_TEST_SUITE_REGISTRATION( SystemConfigTest ); -CPPUNIT_TEST_SUITE_REGISTRATION( ServerConfigTest ); -CPPUNIT_TEST_SUITE_REGISTRATION( ProcessConfigTest ); -CPPUNIT_TEST_SUITE_REGISTRATION( AlarmConfigTest ); -CPPUNIT_TEST_SUITE_REGISTRATION( GeneralCmdsTest ); - -#include -#include - -int main( int argc, char** argv) -{ - CppUnit::TextUi::TestRunner runner; - CppUnit::TestFactoryRegistry& registry = CppUnit::TestFactoryRegistry::getRegistry(); - runner.addTest( registry.makeTest() ); - bool wasSuccessful = runner.run( "", false ); - return (wasSuccessful ? 0 : 1); -} - - diff --git a/oamapps/calpontDB/CMakeLists.txt b/oamapps/calpontDB/CMakeLists.txt deleted file mode 100644 index 781a909e2..000000000 --- a/oamapps/calpontDB/CMakeLists.txt +++ /dev/null @@ -1,49 +0,0 @@ - -# -# Not used -# -# - - - -#original Makefile.am contents follow: - -## Copyright (C) 2014 InfiniDB, Inc. -## -## This program 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; version 2 of -## the License. -## -## This program 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 this program; if not, write to the Free Software -## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -## MA 02110-1301, USA. -# -## $Id: Makefile.am 333 2009-04-03 20:35:04Z rdempsey $ -### Process this file with automake to produce Makefile.in -# -#AM_CPPFLAGS = $(idb_cppflags) -#AM_CFLAGS = $(idb_cflags) -#AM_CXXFLAGS = $(idb_cxxflags) -#AM_LDFLAGS = $(idb_ldflags) -#bin_PROGRAMS = calpontDBWrite -#calpontDBWrite_SOURCES = calpontDB.cpp -#calpontDBWrite_CPPFLAGS = $(idb_common_includes) $(AM_CPPFLAGS) -#calpontDBWrite_LDFLAGS = $(idb_common_ldflags) $(idb_common_libs) $(idb_oam_libs) $(idb_exec_libs) -lreadline -lncurses $(AM_LDFLAGS) -# -#test: -# -#coverage: -# -#leakcheck: -# -#docs: -# -#bootstrap: install-data-am -# diff --git a/oamapps/calpontDB/calpontDB.cpp b/oamapps/calpontDB/calpontDB.cpp deleted file mode 100644 index a29f53a27..000000000 --- a/oamapps/calpontDB/calpontDB.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* Copyright (C) 2014 InfiniDB, Inc. - - This program 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; version 2 of - the License. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - MA 02110-1301, USA. */ - -/****************************************************************************************** - * $Id: calpontDB.cpp 419 2007-07-22 17:18:00Z dhill $ - * - ******************************************************************************************/ -/** - * @file - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "liboamcpp.h" -#include "configcpp.h" -#include "installdir.h" - -using namespace std; -using namespace oam; -using namespace config; - -namespace -{ - -void usage(char* prog) -{ - - cout << endl; - cout << "Usage: " << prog << " [options]" << endl; - - cout << endl; - cout << "This utility is used to suspend and resume Calpont Database Writes." << endl; - cout << "Normally this would be done while performing Database Backups and" << endl; - cout << "Restores " << endl; - cout << endl; - - cout << "Options:" << endl; - cout << "-c Command: suspend or resume" << endl << endl; - cout << "-h Display this help." << endl << endl; -} -} - -int main(int argc, char** argv) -{ - string command; - Oam oam; - BRM::DBRM dbrm; - - char c; - - // Invokes member function `int operator ()(void);' - while ((c = getopt(argc, argv, "c:h")) != -1) - { - switch (c) - { - case 'c': - command = optarg; - break; - - case 'h': - usage(argv[0]); - exit(-1); - break; - - default: - usage(argv[0]); - exit(1); - break; - } - } - - if ( command == "suspend" ) - { - try - { - std::vector tableLocks = dbrm.getAllTableLocks(); - - if (!tableLocks.empty()) - { - oam.DisplayLockedTables(tableLocks, &dbrm); - } - else - { - dbrm.setSystemSuspended(true); - sleep(5); - string cmd = startup::StartUp::installDir() + "/bin/save_brm > /var/log/mariadb/columnstore/save_brm.log1 2>&1"; - int rtnCode = system(cmd.c_str()); - - if (rtnCode == 0) - { - cout << endl << "Suspend Calpont Database Writes Request successfully completed" << endl; - } - else - { - cout << endl << "Suspend Calpont Database Writes Failed: save_brm Failed" << endl; - dbrm.setSystemSuspended(false); - } - } - } - catch (exception& e) - { - cout << endl << "**** Suspend Calpont Database Writes Failed: " << e.what() << endl; - } - catch (...) - { - cout << endl << "**** Suspend Calpont Database Writes Failed" << endl; - } - } - else - { - if ( command == "resume" ) - { - try - { - dbrm.setSystemSuspended(false); - cout << endl << "Resume Calpont Database Writes Request successfully completed" << endl; - } - catch (exception& e) - { - cout << endl << "**** Resume Calpont Database Writes Failed: " << e.what() << endl; - } - catch (...) - { - cout << endl << "**** Resume Calpont Database Writes Failed" << endl; - } - } - else - { - cout << "Invalid Command Entered, please try again" << endl; - exit(-1); - } - } - - exit(0); -} - diff --git a/oamapps/calpontDB/calpontDBWrite.vpj b/oamapps/calpontDB/calpontDBWrite.vpj deleted file mode 100644 index 9e14f5296..000000000 --- a/oamapps/calpontDB/calpontDBWrite.vpj +++ /dev/null @@ -1,216 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/oamapps/calpontSupport/CMakeLists.txt b/oamapps/calpontSupport/CMakeLists.txt deleted file mode 100644 index 3db067d75..000000000 --- a/oamapps/calpontSupport/CMakeLists.txt +++ /dev/null @@ -1,57 +0,0 @@ - -# -# Not used -# -# - - -#original Makefile.am contents follow: - -## Copyright (C) 2014 InfiniDB, Inc. -## -## This program 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; version 2 of -## the License. -## -## This program 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 this program; if not, write to the Free Software -## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -## MA 02110-1301, USA. -# -## $Id: Makefile.am 333 2009-04-03 20:35:04Z rdempsey $ -### Process this file with automake to produce Makefile.in -# -#AM_CPPFLAGS = $(idb_cppflags) -#AM_CFLAGS = $(idb_cflags) -#AM_CXXFLAGS = $(idb_cxxflags) -#AM_LDFLAGS = $(idb_ldflags) -#bin_PROGRAMS = calpontSupport -#calpontSupport_SOURCES = calpontSupport.cpp -#calpontSupport_CPPFLAGS = $(idb_common_includes) $(AM_CPPFLAGS) -#calpontSupport_LDFLAGS = $(idb_common_ldflags) $(idb_brm_libs) $(idb_oam_libs) $(idb_exec_libs) -lreadline -lncurses $(AM_LDFLAGS) -#dist_bin_SCRIPTS=\ -# alarmReport.sh \ -# bulklogReport.sh \ -# configReport.sh \ -# hadoopReport.sh \ -# hardwareReport.sh \ -# logReport.sh \ -# resourceReport.sh \ -# softwareReport.sh -# -#test: -# -#coverage: -# -#leakcheck: -# -#docs: -# -#bootstrap: install-data-am -# diff --git a/oamapps/calpontSupport/alarmReport.sh b/oamapps/calpontSupport/alarmReport.sh deleted file mode 100755 index 865ea95a4..000000000 --- a/oamapps/calpontSupport/alarmReport.sh +++ /dev/null @@ -1,36 +0,0 @@ -#! /bin/sh -# -# $Id: logReport.sh 421 2007-04-05 15:46:55Z dhill $ -# -if [ $1 ] ; then - SERVER=$1 -else - SERVER="localhost" -fi - -if [ $2 ] ; then - DATE=$2 -else - DATE=" " -fi - -rm -f /tmp/logReport.log - -{ -echo " " -echo "******************** Alarm Report for $SERVER ********************" -echo " " - -echo "-- Today's Alarms --" -echo " " -cat /var/log/mariadb/columnstore/alarm.log 2>/dev/null - -if test -f /var/log/mariadb/columnstore/archive/alarm.log-$DATE ; then - echo "-- Archived Alarms --" - echo " " - cat /var/log/mariadb/columnstore/archive/alarm.log-$DATE 2>/dev/null -fi - -} > /tmp/logReport.log - -exit 0 \ No newline at end of file diff --git a/oamapps/calpontSupport/analytics/create.sql b/oamapps/calpontSupport/analytics/create.sql deleted file mode 100644 index a7026bc6a..000000000 --- a/oamapps/calpontSupport/analytics/create.sql +++ /dev/null @@ -1,26 +0,0 @@ -/* -Table for output from track.sh. - -Contains a row per process / snapshot. - -*/ - -drop table if exists processLog; - -create table processLog ( -snapshotid int, -dtm datetime, /* repeated for a snapshot */ -processPid int, -processUserName varchar(7), -processPriority int, -processNice int, -moduleSwapUsedK int, -moduleCachedUsedK int, -processVirt int, -processRes int, -processShr int, -processS char(8), -processCPUPct decimal(4,1), -processMemPct decimal(4,1), -processTime varchar(20), -processCommand varchar(20))engine=infinidb; diff --git a/oamapps/calpontSupport/analytics/track.sh b/oamapps/calpontSupport/analytics/track.sh deleted file mode 100755 index 6dc4dd672..000000000 --- a/oamapps/calpontSupport/analytics/track.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash -# -# Usage: -# track.sh - -# top output -#top - 12:45:49 up 21:58, 2 users, load average: 0.04, 0.10, 0.08 -#Tasks: 164 total, 1 running, 163 sleeping, 0 stopped, 0 zombie -#Cpu(s): 2.9%us, 2.4%sy, 10.3%ni, 76.2%id, 8.0%wa, 0.0%hi, 0.2%si, 0.0%st -#Mem: 16440336k total, 6129588k used, 10310748k free, 74336k buffers -#Swap: 2031608k total, 14848k used, 2016760k free, 511012k cached -# -# PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND - -# track.sh output -# SEQ DATE PID USER PR NI SWAP CACHE VIRT RES SHR S %CPU %MEM TIME+ COMMAND -# SWAP and CACHE are systemwise swap space: Swap: ... used ... cached - -i=0 -while [ true ] -do - let i++ - dt=`date '+%Y-%m-%d %H:%M:%S'` - top -b -n 1 | - egrep "Swap:|PrimProc|ExeMgr|DMLProc|DDLProc|cpimport|WriteEngineServ|controllernode|workernode|mysqld|DecomSvr" | - awk '{if(NR==1){s=$4; c=$8; next}}; {print s" "c" "$0}' | - awk -v i=$i -v dt="$dt" '{ - sub(/k/,"",$1); sub(/k/,"",$2); sub(/m/,"000",$7); sub(/m/,"000",$8); sub(/m/,"000",$9); - sub(/\.([0-9]+)g/, "&00000",$7); sub(/^[0-9]+g/, "&000000",$7); gsub(/[.|g]/, "",$7); - sub(/\.([0-9]+)g/, "&00000",$8); sub(/^[0-9]+g/, "&000000",$8); gsub(/[.|g]/, "",$8)} - {print i"|"dt"|"$3"|"$4"|"$5"|"$6"|"$1"|"$2"|"$7"|"$8"|"$9"|"$10"|"$11"|"$12"|"$13"|"$14"|"}' - if [ -f stop.txt ]; then - rm -f stop.txt - exit - fi - sleep 1 -done diff --git a/oamapps/calpontSupport/approximateRowCount.sh b/oamapps/calpontSupport/approximateRowCount.sh deleted file mode 100755 index 13cea4582..000000000 --- a/oamapps/calpontSupport/approximateRowCount.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash - -# -# Estimates the row count for a given table. Uses number of extents * 8M for the estimate. -# - -# -# Initialize variables. -# - -if [ -z "$MYSQLCMD" ]; then - INSTALLDIR="/usr/local/mariadb/columnstore" - MYSQLCNF=$INSTALLDIR/mysql/my.cnf - MYSQLCMD="$INSTALLDIR/mysql/bin/mysql --defaults-extra-file=$MYSQLCNF -u root" -fi - -# -# Validate that there are two parameters - schema and table. -# -if [ $# -ne 2 ]; then - echo "" - echo "Reports the approximate row count for the given table." - echo "" - echo "Parameters:" - echo " Schema" - echo " Table" -fi -db=$1 -table=$2 - -# -# Validate that the table exists. -# -sql="select count(*) from systable where \`schema\`='$db' and tablename='$table';" -count=`$MYSQLCMD calpontsys --skip-column-names -e "$sql;"` -if [ $count -le 0 ]; then - echo "" - echo "$db.$table does not exist in InfiniDB." - echo "" - exit 1 -fi - -# -# Grab the objectid and column width for a column in the table. -# -sql="select objectid from syscolumn where \`schema\`='$db' and tablename='$table' limit 1;" -objectid=`$MYSQLCMD calpontsys --skip-column-names -e "$sql"` -sql="select columnlength from syscolumn where objectid=$objectid;" -colWidth=`$MYSQLCMD calpontsys --skip-column-names -e "$sql"` - -# -# Use editem to count the extents. -# -extentCount=`/usr/local/mariadb/columnstore/bin/editem -o $objectid | wc -l` -let extentCount-=2 # Take out the 2 extra rows for header and blank line at end. -let approximateRowCount=$extentCount*8192*1024; - -echo "" -echo "Approximate row count for $db.$table is $approximateRowCount." -echo "" - -exit 0 diff --git a/oamapps/calpontSupport/bulklogReport.sh b/oamapps/calpontSupport/bulklogReport.sh deleted file mode 100755 index 755aa29d2..000000000 --- a/oamapps/calpontSupport/bulklogReport.sh +++ /dev/null @@ -1,38 +0,0 @@ -#! /bin/sh -# -# $Id: logReport.sh 421 2007-04-05 15:46:55Z dhill $ -# -if [ $1 ] ; then - MODULE=$1 -else - MODULE="pm1" -fi - -if [ $2 ] ; then - INSTALLDIR=$2 -else - INSTALLDIR="/usr/local/mariadb/columnstore" -fi - -if [ $USER = "root" ]; then - SUDO=" " -else - SUDO="sudo" -fi - -$SUDO rm -f /tmp/${MODULE}_bulklogReport.txt - -{ - -if test -d $INSTALLDIR/data/bulk ; then - echo " " - echo "-- Check for Errors in Bulk Logs --" - echo " " - echo "################# egrep '(ERR|CRIT)' $INSTALLDIR/data/bulk/log/*.err #################" - echo " " - egrep '(ERR|CRIT)' $INSTALLDIR/data/bulk/log/*.err 2>/dev/null -fi - -} > /tmp/${MODULE}_bulklogReport.txt - -exit 0 \ No newline at end of file diff --git a/oamapps/calpontSupport/calpontSupport.bat b/oamapps/calpontSupport/calpontSupport.bat deleted file mode 100644 index eb2a2a93f..000000000 --- a/oamapps/calpontSupport/calpontSupport.bat +++ /dev/null @@ -1,227 +0,0 @@ -@echo off -pushd . -set help= -if "%1" == "-h" (set help=true) -if "%1" == "/h" (set help=true) -if "%1" == "--help" (set help=true) -if "%help%"=="true" ( - echo The InfiniDB Support Report creates a report that can be sent to InfiniDB - echo for help with field support. There are no options to this command. - set help= - exit /B 0 -) - -echo. -echo Running the InfiniDB Support Report, outputting to InfiniDBSupportReport.txt - -call :func > InfiniDBSupportReport.txt 2>&1 - -echo. -echo Report finished - -popd -exit /B 0 - -:ErrorExit - -echo. -echo Error - Failed to find InfiniDB Install Directory in Windows Registry, Exiting -popd -exit /B 1 - -:func - - setlocal - set key="HKLM\SOFTWARE\Calpont\InfiniDB" - set homeValue=InfiniDBHome - set configValue=ConfigFile - - for /f "tokens=3,*" %%a in ('reg query %key% /ve 2^>NUL ^| findstr REG_SZ') do ( - set InfiniDBInstall=%%b - ) - - if "%InfiniDBInstall%" == "" ( - for /f "tokens=2,*" %%a in ('reg query %key% /ve 2^>NUL ^| findstr REG_SZ') do ( - set InfiniDBInstall=%%b - ) - ) - - ::error out if can't locate Install Directory - if "%InfiniDBInstall%" == "" GOTO ErrorExit - -echo ####################################################################### -echo # # -echo # InfiniDB Support Report - %date% %time% -echo # # -echo ####################################################################### -echo. -echo. -echo ======================================================================= -echo = Software/Version Report = -echo ======================================================================= -echo. -echo. -echo -- InfiniDB Software Version -- -type %InfiniDBInstall%\etc\CalpontVersion.txt -echo. -echo -- mysql Software Version -- -mysql --user=root -e status -echo. -echo -- Windows Version -- -ver -echo. -echo. -echo ======================================================================= -echo = Status Report = -echo ======================================================================= -echo. -echo. -echo -- InfiniDB Process Status -- -echo. - -tasklist /FI "Imagename eq mysqld.exe" -tasklist /FI "Imagename eq controllernode.exe" -tasklist /FI "Imagename eq workernode.exe" -tasklist /FI "Imagename eq PrimProc.exe" -tasklist /FI "Imagename eq ExeMgr.exe" -tasklist /FI "Imagename eq DDLProc.exe" -tasklist /FI "Imagename eq DMLProc.exe" -tasklist /FI "Imagename eq WriteEngineServer.exe" - -echo. -echo. -echo ======================================================================= -echo = Configuration Report = -echo ======================================================================= -echo. -echo -- Windows InfiniDB Registry Values -- -echo. - - echo InfiniDBInstall = %InfiniDBInstall% - - for /f "tokens=2,*" %%a in ('reg query %key% /v %homeValue% 2^>NUL ^| findstr %homeValue%') do ( - set InfiniDBHome=%%b - ) - echo InfiniDBHome = %InfiniDBHome% - - for /f "tokens=2,*" %%a in ('reg query %key% /v %configValue% 2^>NUL ^| findstr %configValue%') do ( - set ConfigFile=%%b - ) - echo ConfigFile = %ConfigFile% -echo. -echo. -echo -- InfiniDB System Configuration Information -- -echo. -cd %InfiniDBInstall%\bin -for /f "delims=" %%a in ('getConfig.exe DBBC NumBlocksPct') do @echo NumBlocksPct = %%a -for /f "delims=" %%a in ('getConfig.exe HashJoin TotalUmMemory') do @echo TotalUmMemory = %%a -for /f "delims=" %%a in ('getConfig.exe VersionBuffer VersionBufferFileSize') do @echo VersionBufferFileSize = %%a -for /f "delims=" %%a in ('getConfig.exe ExtentMap FilesPerColumnPartition') do @echo FilesPerColumnPartition = %%a -for /f "delims=" %%a in ('getConfig.exe ExtentMap ExtentsPerSegmentFile') do @echo ExtentsPerSegmentFile = %%a -echo. -echo. -echo -- InfiniDB System Configuration File -- -echo. -type "%ConfigFile%" -echo. -echo. -echo -- System Process Status -- -echo. -tasklist /v -echo. -echo ======================================================================= -echo = Resource Usage Report = -echo ======================================================================= -echo. -echo -- System Information-- -echo. -systeminfo -echo. -echo -- IP Configuration Information -- -echo. -ipconfig -echo. -echo -- Disk BRM Data files -- -echo. -dir "%InfiniDBInstall%\dbrm\" -echo. -echo -- View Table Locks -- -echo. -cd %InfiniDBInstall%\bin\ -viewtablelock.exe -echo. -echo. -echo -- BRM Extent Map -- -echo. -cd %InfiniDBInstall%\bin\ -editem.exe -i -echo. -echo. -echo ======================================================================= -echo = Log Report = -echo ======================================================================= -echo. -echo -- InfiniDB Platform Logs -- -echo. -type "%InfiniDBInstall%\log\InfiniDBLog.txt" -echo. -echo. -echo -- InfiniDB MySQl log -- -echo. -type "%InfiniDBInstall%\mysqldb\*.err" -echo. -echo. -echo -- InfiniDB Bulk Load Logs -- -echo. -dir "%InfiniDBInstall%\bulk\data" -echo. -dir "%InfiniDBInstall%\bulk\log" -echo. -dir "%InfiniDBInstall%\bulk\job" -echo. -echo -- Check for Errors in Bulk Logs -- -echo. -cd "%InfiniDBInstall%\bulk\log" -findstr /spin /c:"error" * -findstr /spin /c:"failed" * -cd "%InfiniDBInstall%\bulk\job" -findstr /spin /c:"error" * -findstr /spin /c:"failed" * -echo. -echo ======================================================================= -echo = DBMS Report = -echo ======================================================================= -echo. -echo -- DBMS InfiniDB Mysql Version -- -echo. -mysql --user=root -e status -echo. -echo -- DBMS Mysql InfiniDB System Column -- -echo. -mysql --user=root -e "desc calpontsys.syscolumn" -echo. -echo -- DBMS Mysql InfiniDB System Table -- -echo. -mysql --user=root -e "desc calpontsys.systable" -echo. -echo -- DBMS Mysql InfiniDB System Table Data -- -echo. -mysql --user=root -e "select * from calpontsys.systable" -echo. -echo -- DBMS Mysql InfiniDB Databases -- -echo. -mysql --user=root -e "show databases" -echo. -echo -- DBMS Mysql InfiniDB variables -- -echo. -mysql --user=root -e "show variables" -echo. -echo -- DBMS Mysql InfiniDB config file -- -echo. -type "%InfiniDBInstall%\my.ini" -echo. -echo -- Active Queries -- - -::cd \InfiniDB\genii\oamapps\calpontSupport - - diff --git a/oamapps/calpontSupport/calpontSupport.cpp b/oamapps/calpontSupport/calpontSupport.cpp deleted file mode 100644 index b96349bfe..000000000 --- a/oamapps/calpontSupport/calpontSupport.cpp +++ /dev/null @@ -1,1102 +0,0 @@ -/* Copyright (C) 2013 Calpont Corp. */ - - -/****************************************************************************************** -* $Id: calpontSupport.cpp 64 2006-10-12 22:21:51Z dhill $ -* -* -* -******************************************************************************************/ -/** - * @file - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "stdio.h" -#include "ctype.h" -#include -#include - -#include "liboamcpp.h" -#include "configcpp.h" -#include "installdir.h" - -using namespace std; -using namespace oam; -using namespace config; - -typedef struct Child_Module_struct -{ - std::string moduleName; - std::string moduleIP; - std::string hostName; -} ChildModule; - -typedef std::vector ChildModuleList; - -string currentDate; -string systemName; -string localModule; -string localModuleHostName; -ChildModuleList childmodulelist; -ChildModuleList parentmodulelist; -ChildModule childmodule; - -string rootPassword = ""; -string debug_flag = "0"; -string mysqlpw = " "; - -int runningThreads = 0; -pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; - -typedef boost::tuple threadInfo_t; - -bool LOCAL = false; - -void title(string outputFile = "calpontSupportReport.txt") -{ - string cmd = "echo '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' System " + systemName + "' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' calpontSupportReport script ran from Module " + localModule + " on " + currentDate + "' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%' >> " + outputFile; - system(cmd.c_str()); -} - -void childReportThread(threadInfo_t& st) -{ - ChildModuleList::iterator& list = boost::get<0>(st); - string reportType = boost::get<1>(st); - - string remoteModuleName = (*list).moduleName; - string remoteModuleIP = (*list).moduleIP; - string remoteHostName = (*list).hostName; - - string installDir(startup::StartUp::installDir()); - - pthread_mutex_lock( &mutex1 ); - runningThreads++; -//cout << "++ " << runningThreads << endl; - pthread_mutex_unlock( &mutex1 ); - - string outputFile; - - if (reportType == "log") - { - outputFile = remoteModuleName + "_" + reportType + "Report.tar.gz"; - } - else if (reportType == "hadoop") - { - outputFile = "hadoopReport.txt"; - } - else - { - outputFile = remoteModuleName + "_" + reportType + "Report.txt"; - - title(outputFile); - - string cmd = "echo '=======================================================================' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '= " + reportType + " report =' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '=======================================================================' >> " + outputFile; - system(cmd.c_str()); - } - - //run remote report script - if (reportType == "hadoop") - cout << "Get " + reportType + " report data" << endl; - else - cout << "Get " + reportType + " report data for " + remoteModuleName + " " << endl; - - cout.flush(); - - string cmd = installDir + "/bin/remote_command.sh " + remoteModuleIP + " " + rootPassword + " '" + - installDir + "/bin/" + reportType + "Report.sh " + remoteModuleName + " " + installDir + - "' " + debug_flag + " - forcetty"; - int rtnCode = system(cmd.c_str()); - - if (WEXITSTATUS(rtnCode) != 0) - { - cout << "Error with running remote_command.sh, exiting..." << endl; - } - - cmd = installDir + "/bin/remote_scp_get.sh " + remoteModuleIP + " " + rootPassword + " /tmp/" + outputFile + " > /dev/null 2>&1"; - rtnCode = system(cmd.c_str()); - - if (WEXITSTATUS(rtnCode) != 0) - cout << "ERROR: failed to retrieve /tmp/" << outputFile << " from " + remoteHostName << endl; - - pthread_mutex_lock( &mutex1 ); - runningThreads--; -//cout << "-- " << runningThreads << endl; - pthread_mutex_unlock( &mutex1 ); - - // exit thread - pthread_exit(0); -} - -void reportThread(string reporttype) -{ - string reportType = reporttype; - - string installDir(startup::StartUp::installDir()); - Oam oam; - - pthread_mutex_lock( &mutex1 ); - runningThreads++; -//cout << "++ " << runningThreads << endl; - pthread_mutex_unlock( &mutex1 ); - - string outputFile = localModule + "_" + reportType + "Report.txt"; - - // run on child servers and get report - if (!LOCAL) - { - ChildModuleList::iterator list1 = childmodulelist.begin(); - - for (; list1 != childmodulelist.end() ; list1++) - { - threadInfo_t* st = new threadInfo_t; - *st = boost::make_tuple(list1, reportType); - - pthread_t childreportthread; - int status = pthread_create (&childreportthread, NULL, (void* (*)(void*)) &childReportThread, st); - - if ( status != 0 ) - { - cout << "ERROR: childreportthread: pthread_create failed, return status = " + oam.itoa(status) << endl; - } - - sleep(1); - } - } - - // run report on local server - cout << "Get " + reportType + " report data for " + localModule << endl; - - if (reportType == "log") - { - string cmd = installDir + "/bin/logReport.sh " + localModule + " " + installDir; - system(cmd.c_str()); - - cmd = "mv -f /tmp/" + localModule + "_logReport.tar.gz ."; - system(cmd.c_str()); - - cmd = "tar -zcf " + localModule + "_mysqllogReport.tar.gz " + installDir + "/mysql/db/*.err* 2>/dev/null"; - system(cmd.c_str()); - - // run log config on local server - cout << "Get log config data for " + localModule << endl; - - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '******************** Log Configuration ********************' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '################# mcsadmin getLogConfig ################# ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = installDir + "/bin/mcsadmin getLogConfig >> " + outputFile; - system(cmd.c_str()); - } - else - { - //get local report - title(outputFile); - - string cmd = "echo '=======================================================================' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '= " + reportType + " report =' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '=======================================================================' >> " + outputFile; - system(cmd.c_str()); - - cmd = installDir + "/bin/" + reportType + "Report.sh " + localModule + " " + installDir; - system(cmd.c_str()); - cmd = " mv -f /tmp/" + localModule + "_" + reportType + "Report.txt ."; - system(cmd.c_str()); - - if (reportType == "config" ) - { - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '******************** System Network Configuration ********************' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '################# mcsadmin getSystemNetworkConfig ################# ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = installDir + "/bin/mcsadmin getSystemNetworkConfig >> " + outputFile; - system(cmd.c_str()); - - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '******************** System Module Configure ********************' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '################# mcsadmin getModuleTypeConfig ################# ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = installDir + "/bin/mcsadmin getModuleTypeConfig >> " + outputFile; - system(cmd.c_str()); - - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '******************** System Storage Configuration ********************' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '################# mcsadmin getStorageConfig ################# ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = installDir + "/bin/mcsadmin getStorageConfig >> " + outputFile; - system(cmd.c_str()); - - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '******************** System Storage Status ********************' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '################# mcsadmin getStorageStatus ################# ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = installDir + "/bin/mcsadmin getStorageStatus >> " + outputFile; - system(cmd.c_str()); - - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '******************** System Status ********************' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '################# mcsadmin getSystemInfo ################# ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = installDir + "/bin/mcsadmin getSystemInfo >> " + outputFile; - system(cmd.c_str()); - - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '******************** System Configuration File ********************' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '################# cat /etc/Columnstore.xml ################# ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "cat " + installDir + "/etc/Columnstore.xml >> " + outputFile; - system(cmd.c_str()); - } - - if (reportType == "resource" ) - { - if (LOCAL) - { - cmd = "echo '################# mcsadmin getModuleResourceUsage ################# ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - string cmd = installDir + "/bin/mcsadmin getModuleResourceUsage " + localModule + " >> " + outputFile; - system(cmd.c_str()); - } - else - { - cmd = "echo '################# mcsadmin getSystemResourceUsage ################# ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - string cmd = installDir + "/bin/mcsadmin getSystemResourceUsage >> " + outputFile; - system(cmd.c_str()); - } - } - } - - // exit thread - pthread_mutex_lock( &mutex1 ); - runningThreads--; -//cout << "-- " << runningThreads << endl; - pthread_mutex_unlock( &mutex1 ); - - pthread_exit(0); -} - -int main(int argc, char* argv[]) -{ - Oam oam; - string installDir(startup::StartUp::installDir()); - - Config* sysConfig = Config::makeConfig(); - string SystemSection = "SystemConfig"; - string InstallSection = "Installation"; - - bool HARDWARE = false; - bool SOFTWARE = false; - bool CONFIG = false; - bool DBMS = false; - bool RESOURCE = false; - bool LOG = false; - bool BULKLOG = false; - bool HADOOP = false; - - //get current time and date - time_t now; - now = time(NULL); - struct tm tm; - localtime_r(&now, &tm); - char timestamp[200]; - strftime (timestamp, 200, "%m:%d:%y-%H:%M:%S", &tm); - currentDate = timestamp; - - char helpArg[3] = "-h"; - - // Get System Name - try - { - oam.getSystemConfig("SystemName", systemName); - } - catch (...) - { - systemName = "unassigned"; - } - - // get Local Module Name and Server Install Indicator - string singleServerInstall; - - oamModuleInfo_t st; - - try - { - st = oam.getModuleInfo(); - localModule = boost::get<0>(st); - } - catch (...) - { - cout << endl << "**** Failed : Failed to read Local Module Name" << endl; - exit(-1); - } - - try - { - oam.getSystemConfig("SingleServerInstall", singleServerInstall); - } - catch (...) - { - singleServerInstall = "y"; - } - - if (argc == 1) - { - argv[1] = &helpArg[0]; - argc = 2; - } - - string DataFilePlugin; - - try - { - DataFilePlugin = sysConfig->getConfig(SystemSection, "DataFilePlugin"); - } - catch (...) - { - cout << "ERROR: Problem accessing InfiniDB configuration file" << endl; - exit(-1); - } - - for ( int i = 1; i < argc; i++ ) - { - if ( string("-h") == argv[i] ) - { - cout << endl; - cout << "'calpontSupport' generates a Set of System Support Report Files in a tar file" << endl; - cout << "called calpontSupportReport.'system-name'.tar.gz in the local directory." << endl; - cout << "It should be run on the server with the DBRM front-end." << endl; - cout << "Check the Admin Guide for additional information." << endl; - cout << endl; - cout << "Usage: calpontSupport [-h][-a][-hw][-s][-c][-db][-r][-l][-bl][-lc][-p 'root-password'][-mp 'mysql-root-password'][-de]"; - - // if hdfs set up print the hadoop option - if (!DataFilePlugin.empty()) - cout << "[-hd]"; - - cout << endl; - cout << " -h help" << endl; - cout << " -a Output all Reports (excluding Bulk Logs Reports)" << endl; - cout << " -hw Output Hardware Reports only" << endl; - cout << " -s Output Software Reports only" << endl; - cout << " -c Output Configuration/Status Reports only" << endl; - cout << " -db Output DBMS Reports only" << endl; - cout << " -r Output Resource Reports only" << endl; - cout << " -l Output Calpont Log/Alarms Reports only" << endl; - cout << " -bl Output Calpont Bulk Log Reports only" << endl; - cout << " -lc Output Reports for Local Server only" << endl; - cout << " -p password (multi-server systems), root-password or 'ssh' to use 'ssh keys'" << endl; - cout << " -mp mysql root user password" << endl; - cout << " -de Debug Flag" << endl; - - // if hdfs set up print the hadoop option - if (!DataFilePlugin.empty()) - cout << " -hd Output hadoop reports only" << endl; - - exit (0); - } - else - { - if ( string("-a") == argv[i] ) - { - HARDWARE = true; - SOFTWARE = true; - CONFIG = true; - DBMS = true; - RESOURCE = true; - LOG = true; - HADOOP = (DataFilePlugin.empty() ? false : true); - } - else if ( string("-hw") == argv[i] ) - HARDWARE = true; - else if ( string("-s") == argv[i] ) - SOFTWARE = true; - else if ( string("-c") == argv[i] ) - CONFIG = true; - else if ( string("-db") == argv[i] ) - DBMS = true; - else if ( string("-r") == argv[i] ) - RESOURCE = true; - else if ( string("-l") == argv[i] ) - LOG = true; - else if ( string("-bl") == argv[i] ) - BULKLOG = true; - else if ( string("-lc") == argv[i] ) - LOCAL = true; - else if ( string("-p") == argv[i] ) - { - i++; - - if ( argc == i ) - { - cout << "ERROR: missing root password argument" << endl; - exit(-1); - } - - rootPassword = argv[i]; - - //add single quote for special characters - if ( rootPassword != "ssh" ) - { - rootPassword = "'" + rootPassword + "'"; - } - } - else if ( string("-mp") == argv[i] ) - { - i++; - - if ( argc == i ) - { - cout << "ERROR: missing mysql root user password argument" << endl; - exit(-1); - } - - mysqlpw = argv[i]; - mysqlpw = "'" + mysqlpw + "'"; - } - else if ( string("-de") == argv[i] ) - debug_flag = "1"; - else if ( string("-hd") == argv[i] ) - { - HADOOP = (DataFilePlugin.empty() ? false : true); - } - else - { - cout << "Invalid Option of '" << argv[i] << "', run with '-h' for help" << endl; - exit (1); - } - } - } - - //default to -a if nothing is set - if ( !HARDWARE && !SOFTWARE && !CONFIG && !DBMS && !RESOURCE && !LOG && !BULKLOG && !HADOOP) - { - HARDWARE = true; - SOFTWARE = true; - CONFIG = true; - DBMS = true; - RESOURCE = true; - LOG = true; - HADOOP = (DataFilePlugin.empty() ? false : true); - } - - //get Parent OAM Module Name and setup of it's Custom OS files - string PrimaryUMModuleName; - - try - { - PrimaryUMModuleName = sysConfig->getConfig(SystemSection, "PrimaryUMModuleName"); - } - catch (...) - { - cout << "ERROR: Problem getting Parent OAM Module Name" << endl; - exit(-1); - } - - if ( PrimaryUMModuleName == "unassigned" ) - PrimaryUMModuleName = localModule; - - if ( (localModule != PrimaryUMModuleName) && DBMS ) - { - char* pcommand = 0; - char* p; - string argument = "n"; - - while (true) - { - cout << endl << "You selected to get the DBMS data." << endl; - cout << "You need to run the calpontSupport command on module '" << PrimaryUMModuleName << "' to get that information." << endl; - cout << "Or you can proceed on to get all data except the DBMS." << endl; - - pcommand = readline(" Do you want to proceed: (y or n) [n]: "); - - if (pcommand && *pcommand) - { - p = strtok(pcommand, " "); - argument = p; - free(pcommand); - pcommand = 0; - } - - if (pcommand) - { - free(pcommand); - pcommand = 0; - } - - if ( argument == "y") - { - cout << endl; - break; - } - else if ( argument == "n") - exit (1); - } - } - - //get number of worker-nodes, will tell us if a single server system - //get Parent OAM Module Name and setup of it's Custom OS files - try - { - string NumWorkers = sysConfig->getConfig("DBRM_Controller", "NumWorkers"); - - if ( NumWorkers == "1" ) - singleServerInstall = "y"; - } - catch (...) - {} - - if ( singleServerInstall == "n" && !LOCAL) - if ( HARDWARE || SOFTWARE || CONFIG || RESOURCE || LOG || HADOOP ) - if ( rootPassword.empty() ) - { - cout << "ERROR: Multi-Module System, Password Argument required or use '-lc' option, check help for more information" << endl; - exit(-1); - } - - //get Parent OAM Module Name and setup of it's Custom OS files - //string parentOAMModuleName; - ChildModule parentOAMModule; - - try - { - parentOAMModule.moduleName = sysConfig->getConfig(SystemSection, "ParentOAMModuleName"); - } - catch (...) - { - cout << "ERROR: Problem getting Parent OAM Module Name" << endl; - exit(-1); - } - - //Get list of configured system modules - SystemModuleTypeConfig sysModuleTypeConfig; - - try - { - oam.getSystemConfig(sysModuleTypeConfig); - } - catch (...) - { - cout << "ERROR: Problem reading the Calpont System Configuration file" << endl; - exit(-1); - } - - string ModuleSection = "SystemModuleConfig"; - - for ( unsigned int i = 0 ; i < sysModuleTypeConfig.moduletypeconfig.size(); i++) - { - string moduleType = sysModuleTypeConfig.moduletypeconfig[i].ModuleType; - int moduleCount = sysModuleTypeConfig.moduletypeconfig[i].ModuleCount; - - if ( moduleCount == 0 ) - //no modules equipped for this Module Type, skip - continue; - - //get IP addresses and Host Names - DeviceNetworkList::iterator listPT = sysModuleTypeConfig.moduletypeconfig[i].ModuleNetworkList.begin(); - - for ( ; listPT != sysModuleTypeConfig.moduletypeconfig[i].ModuleNetworkList.end() ; listPT++) - { - string moduleName = (*listPT).DeviceName; - HostConfigList::iterator pt1 = (*listPT).hostConfigList.begin(); - string moduleIPAddr = (*pt1).IPAddr; - string moduleHostName = (*pt1).HostName; - - if ( moduleName == localModule) - { - localModuleHostName = moduleHostName; - } - - //save Child modules - if ( moduleName != localModule && moduleType != "xm") - { - childmodule.moduleName = moduleName; - childmodule.moduleIP = moduleIPAddr; - childmodule.hostName = moduleHostName; - childmodulelist.push_back(childmodule); - } - - if (moduleName == parentOAMModule.moduleName) - { - parentOAMModule.moduleIP = moduleIPAddr; - parentOAMModule.hostName = moduleHostName; - parentOAMModule.moduleName = moduleName; - } - } - } //end of i for loop - - // create a clean Calpont Support Report - system("rm -f *_configReport.txt"); - system("rm -f *_dbmsReport.txt"); - system("rm -f *_hardwareReport.txt"); - system("rm -f *_logReport.txt"); - system("rm -f *_bulklogReport.txt"); - system("rm -f *_resourceReport.txt"); - system("rm -f *_softwareReport.txt"); - system("rm -f hadoopReport.txt"); - - // - // Software - // - - if ( SOFTWARE ) - { - string reportType = "software"; - pthread_t reportthread; - int status = pthread_create (&reportthread, NULL, (void* (*)(void*)) &reportThread, &reportType); - - if ( status != 0 ) - { - cout << "ERROR: reportthread: pthread_create failed, return status = " + oam.itoa(status); - } - - sleep(5); - } - - // - // Configuration - // - - if ( CONFIG ) - { - string reportType = "config"; - pthread_t reportthread; - int status = pthread_create (&reportthread, NULL, (void* (*)(void*)) &reportThread, &reportType); - - if ( status != 0 ) - { - cout << "ERROR: reportthread: pthread_create failed, return status = " + oam.itoa(status); - } - - sleep(5); - } - - // - // Alarms and Calpont Logs - // - - if ( LOG ) - { - string reportType = "log"; - pthread_t reportthread; - int status = pthread_create (&reportthread, NULL, (void* (*)(void*)) &reportThread, &reportType); - - if ( status != 0 ) - { - cout << "ERROR: reportthread: pthread_create failed, return status = " + oam.itoa(status); - } - - sleep(5); - } - - // - // Bulk Logs - // - - if ( BULKLOG ) - { - string reportType = "bulklog"; - pthread_t reportthread; - int status = pthread_create (&reportthread, NULL, (void* (*)(void*)) &reportThread, &reportType); - - if ( status != 0 ) - { - cout << "ERROR: reportthread: pthread_create failed, return status = " + oam.itoa(status); - } - - sleep(5); - } - - // - // Hardware - // - - if ( HARDWARE ) - { - string reportType = "hardware"; - pthread_t reportthread; - int status = pthread_create (&reportthread, NULL, (void* (*)(void*)) &reportThread, &reportType); - - if ( status != 0 ) - { - cout << "ERROR: reportthread: pthread_create failed, return status = " + oam.itoa(status); - } - - sleep(5); - } - - // - // Resources - // - - if ( RESOURCE ) - { - string reportType = "resource"; - pthread_t reportthread; - int status = pthread_create (&reportthread, NULL, (void* (*)(void*)) &reportThread, &reportType); - - if ( status != 0 ) - { - cout << "ERROR: reportthread: pthread_create failed, return status = " + oam.itoa(status); - } - - sleep(5); - } - - // - // DBMS - // - - if ( DBMS ) - { - system("rm -f calpontSupportReport.txt;touch calpontSupportReport.txt"); - title(); - - system("echo '=======================================================================' >> calpontSupportReport.txt"); - system("echo '= DBMS Report =' >> calpontSupportReport.txt"); - system("echo '=======================================================================' >> calpontSupportReport.txt"); - - // run DBMS report on local server - cout << "Get dbms report data for " << localModule << endl; - - bool FAILED = false; - - if ( localModule != PrimaryUMModuleName ) - { - cout << " FAILED: run calpontSupport on '" << PrimaryUMModuleName << "' to get the dbrm report" << endl; - FAILED = true; - } - else - { - // check if mysql is supported and get info - string calpontMysql = installDir + "/mysql/bin/mysql --defaults-file=" + installDir + "/mysql/my.cnf -u root "; - string cmd = calpontMysql + " -e 'status' > /tmp/idbmysql.log 2>&1"; - system(cmd.c_str()); - - //check for mysql password set - string pwprompt = " "; - - if (oam.checkLogStatus("/tmp/idbmysql.log", "ERROR 1045") ) - { - cout << "NOTE: MySQL root user password is set" << endl; - - //needs a password, was password entered on command line - if ( mysqlpw == " " ) - { - //go check my.cnf - string file = installDir + "/mysql/my.cnf"; - ifstream oldFile (file.c_str()); - - vector lines; - char line[200]; - string buf; - - while (oldFile.getline(line, 200)) - { - buf = line; - string::size_type pos = buf.find("password", 0); - - if (pos != string::npos) - { - string::size_type pos1 = buf.find("=", 0); - - if (pos1 != string::npos) - { - pos = buf.find("#", 0); - - if (pos == string::npos) - { - //password arg in my.cnf, go get password - cout << "NOTE: Using password from my.cnf" << endl; - mysqlpw = buf.substr(pos1 + 1, 80); - cout << mysqlpw << endl; - break; - } - } - } - } - - oldFile.close(); - - if ( mysqlpw == " " ) - { - cout << "NOTE: No password provide on command line or found uncommented in my.cnf" << endl; - cout << endl; - string prompt = " *** Enter MySQL password > "; - mysqlpw = getpass(prompt.c_str()); - } - } - - //check for mysql password set - pwprompt = "--password=" + mysqlpw; - - string cmd = calpontMysql + pwprompt + " -e 'status' > /tmp/idbmysql.log 2>&1"; - system(cmd.c_str()); - - if (oam.checkLogStatus("/tmp/idbmysql.log", "ERROR 1045") ) - { - cout << "FAILED: Failed login using MySQL root user password '" << mysqlpw << "'" << endl; - FAILED = true; - } - } - - if (!FAILED) - { - // check if mysql is supported and get info - string calpontMysql = installDir + "/mysql/bin/mysql --defaults-file=" + installDir + "/mysql/my.cnf -u root " + pwprompt; - string cmd = calpontMysql + " -V > /dev/null 2>&1"; - int ret = system(cmd.c_str()); - - if ( WEXITSTATUS(ret) == 0) - { - // run DBMS report info - system("echo ' ' >> calpontSupportReport.txt"); - system("echo '******************** DBMS InfiniDB Mysql Version ********************' >> calpontSupportReport.txt"); - system("echo ' ' >> calpontSupportReport.txt"); - cmd = "echo '################# " + calpontMysql + " -e status ################# ' >> calpontSupportReport.txt"; - system(cmd.c_str()); - cmd = "echo ' ' >> calpontSupportReport.txt"; - system(cmd.c_str()); - cmd = calpontMysql + " -e 'status' >> calpontSupportReport.txt"; - system(cmd.c_str()); - - system("echo ' ' >> calpontSupportReport.txt"); - system("echo '******************** DBMS Mysql Calpont System Column ********************' >> calpontSupportReport.txt"); - system("echo ' ' >> calpontSupportReport.txt"); - cmd = "echo '################# " + calpontMysql + " -e desc calpontsys.syscolumn ################# ' >> calpontSupportReport.txt"; - system(cmd.c_str()); - cmd = "echo ' ' >> calpontSupportReport.txt"; - system(cmd.c_str()); - cmd = calpontMysql + " -e 'desc calpontsys.syscolumn;' >> calpontSupportReport.txt"; - system(cmd.c_str()); - - system("echo ' ' >> calpontSupportReport.txt"); - system("echo '******************** DBMS Mysql Calpont System Table ********************' >> calpontSupportReport.txt"); - system("echo ' ' >> calpontSupportReport.txt"); - cmd = "echo '################# " + calpontMysql + " -e desc calpontsys.systable ################# ' >> calpontSupportReport.txt"; - system(cmd.c_str()); - cmd = "echo ' ' >> calpontSupportReport.txt"; - system(cmd.c_str()); - cmd = calpontMysql + " -e 'desc calpontsys.systable;' >> calpontSupportReport.txt"; - system(cmd.c_str()); - - system("echo ' ' >> calpontSupportReport.txt"); - system("echo '******************** DBMS Mysql Calpont System Catalog Data ********************' >> calpontSupportReport.txt"); - system("echo ' ' >> calpontSupportReport.txt"); - cmd = "echo '################# " + calpontMysql + " calpontsys < " + installDir + "/mysql/dumpcat_mysql.sql ################# ' >> calpontSupportReport.txt"; - system(cmd.c_str()); - cmd = "echo ' ' >> calpontSupportReport.txt"; - system(cmd.c_str()); - cmd = calpontMysql + " calpontsys < " + installDir + "/mysql/dumpcat_mysql.sql >> calpontSupportReport.txt"; - system(cmd.c_str()); - - system("echo ' ' >> calpontSupportReport.txt"); - system("echo '******************** DBMS Mysql Calpont System Table Data ********************' >> calpontSupportReport.txt"); - system("echo ' ' >> calpontSupportReport.txt"); - cmd = "echo '################# " + calpontMysql + " -e select * from calpontsys.systable ################# ' >> calpontSupportReport.txt"; - system(cmd.c_str()); - cmd = "echo ' ' >> calpontSupportReport.txt"; - system(cmd.c_str()); - cmd = calpontMysql + " -e 'select * from calpontsys.systable;' >> calpontSupportReport.txt"; - system(cmd.c_str()); - - system("echo ' ' >> calpontSupportReport.txt"); - system("echo '******************** DBMS Mysql Calpont Usernames ********************' >> calpontSupportReport.txt"); - system("echo ' ' >> calpontSupportReport.txt"); - cmd = "echo '################# " + calpontMysql + " -e show databases ################# ' >> calpontSupportReport.txt"; - system(cmd.c_str()); - cmd = "echo ' ' >> calpontSupportReport.txt"; - system(cmd.c_str()); - cmd = calpontMysql + " -e 'show databases;' >> calpontSupportReport.txt"; - system(cmd.c_str()); - - system("echo ' ' >> calpontSupportReport.txt"); - system("echo '******************** DBMS Mysql InfiniDB variables ********************' >> calpontSupportReport.txt"); - system("echo ' ' >> calpontSupportReport.txt"); - cmd = "echo '################# " + calpontMysql + " show variables ################# ' >> calpontSupportReport.txt"; - system(cmd.c_str()); - cmd = "echo ' ' >> calpontSupportReport.txt"; - system(cmd.c_str()); - cmd = calpontMysql + " -e 'show variables;' >> calpontSupportReport.txt"; - system(cmd.c_str()); - } - } - } - - system("echo ' ' >> calpontSupportReport.txt"); - system("echo '******************** Database Size Report ********************' >> calpontSupportReport.txt"); - system("echo ' ' >> calpontSupportReport.txt"); - string cmd = "echo '################# /bin/databaseSizeReport ################# ' >> calpontSupportReport.txt"; - system(cmd.c_str()); - cmd = "echo ' ' >> calpontSupportReport.txt"; - system(cmd.c_str()); - cmd = installDir + "/bin/databaseSizeReport >> calpontSupportReport.txt"; - system(cmd.c_str()); - - system("echo ' ' >> calpontSupportReport.txt"); - system("echo '******************** DBMS Mysql InfiniDB config file ********************' >> calpontSupportReport.txt"); - system("echo ' ' >> calpontSupportReport.txt"); - cmd = "echo '################# cat /mysql/my.cnf ################# ' >> calpontSupportReport.txt"; - system(cmd.c_str()); - cmd = "echo ' ' >> calpontSupportReport.txt"; - system(cmd.c_str()); - cmd = "cat " + installDir + "/mysql/my.cnf 2>/dev/null >> calpontSupportReport.txt"; - system(cmd.c_str()); - - system("echo ' ' >> calpontSupportReport.txt"); - system("echo '******************** Active Queries ********************' >> calpontSupportReport.txt"); - system("echo ' ' >> calpontSupportReport.txt"); - cmd = "echo '################# mcsadmin getActiveSqlStatement ################# ' >> calpontSupportReport.txt"; - system(cmd.c_str()); - cmd = "echo ' ' >> calpontSupportReport.txt"; - system(cmd.c_str()); - cmd = installDir + "/bin/mcsadmin getActiveSqlStatement >> calpontSupportReport.txt"; - system(cmd.c_str()); - - cmd = "cat calpontSupportReport.txt > " + localModule + "_dbmsReport.txt"; - system(cmd.c_str()); - } - - // - // HADOOP - // - - if (HADOOP) - { - if (LOCAL || childmodulelist.empty()) - { - cout << "Get hadoop report data" << endl; - string cmd = installDir + "/bin/hadoopReport.sh " + localModule + " " + installDir + "\n"; - cmd += " mv -f /tmp/hadoopReport.txt ."; - FILE* pipe = popen(cmd.c_str(), "r"); - - if (!pipe) - { - cout << "Failed to get a pipe for hadoop health check commands" << endl; - exit(-1); - } - - pclose(pipe); - } - else - { - // only get hadoop report from parentOAMModule, because it's consistant view. - parentmodulelist.push_back(parentOAMModule); - threadInfo_t* st = new threadInfo_t; - ChildModuleList::iterator iter = parentmodulelist.begin(); - *st = boost::make_tuple(iter, "hadoop"); - - pthread_t hdthread; - int status = pthread_create (&hdthread, NULL, (void* (*)(void*)) &childReportThread, st); - - if ( status != 0 ) - { - cout << "ERROR: childreportthread: pthread_create failed, return status = " + oam.itoa(status) << endl; - } - } - } - - //wait for all threads to complete - sleep(5); - int wait = 0; - - while (true) - { -//cout << "check " << runningThreads << endl; - if (runningThreads < 1) - break; - - sleep(2); - wait++; - - // give it 60 minutes to complete - if ( wait >= 3600 * 5) - { - cout << "Timed out (60 minutes) waiting for Requests to complete" << endl; - } - } - - system("rm -f calpontSupportReport.txt"); - - system("unix2dos *Report.txt > /dev/null 2>&1"); - system("rm -rf calpontSupportReport;mkdir calpontSupportReport;mv *Report.txt calpontSupportReport/. > /dev/null 2>&1;mv *Report.tar.gz calpontSupportReport/. > /dev/null 2>&1"); - string cmd = "tar -zcf calpontSupportReport." + systemName + ".tar.gz calpontSupportReport/*"; - system(cmd.c_str()); - - - cout << endl << "Calpont Support Script Successfully completed, files located in calpontSupportReport." + systemName + ".tar.gz" << endl; -} diff --git a/oamapps/calpontSupport/configReport.sh b/oamapps/calpontSupport/configReport.sh deleted file mode 100755 index 6b7cf3499..000000000 --- a/oamapps/calpontSupport/configReport.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash -# -# $Id: hardwareReport.sh 421 2007-04-05 15:46:55Z dhill $ -# -if [ $1 ] ; then - MODULE=$1 -else - MODULE="pm1" -fi - -if [ $2 ] ; then - INSTALLDIR=$2 -else - INSTALLDIR="/usr/local/mariadb/columnstore" -fi - -if [ $USER = "root" ]; then - SUDO=" " -else - SUDO="sudo" -fi - -$SUDO rm -f /tmp/${MODULE}_configReport.txt - -{ -echo " " -echo "******************** Configuration/Status Report for ${MODULE} ********************" -echo " " - -if test -f /sbin/chkconfig ; then - echo "-- chkconfig configuration --" - echo " " - echo "################# /sbin/chkconfig --list | grep infinidb #################" - echo " " - $SUDO /sbin/chkconfig --list | grep infinidb 2>/dev/null - echo "################# /sbin/chkconfig --list | grep mysql-Columnstore #################" - echo " " - $SUDO /sbin/chkconfig --list | grep mysql-Columnstore 2>/dev/null -fi - -echo " " -echo "-- fstab Configuration --" -echo " " -echo "################# cat /etc/fstab #################" -echo " " -$SUDO cat /etc/fstab 2>/dev/null - -echo " " -echo "-- Server Processes --" -echo " " -echo "################# ps axu #################" -echo " " -$SUDO ps axu - -echo " " -echo "-- Server Processes with resource usage --" -echo " " -echo "################# top -b -n 1 #################" -echo " " -$SUDO top -b -n 1 - -} > /tmp/${MODULE}_configReport.txt - -exit 0 \ No newline at end of file diff --git a/oamapps/calpontSupport/findStranded.sh b/oamapps/calpontSupport/findStranded.sh deleted file mode 100755 index 1263aace9..000000000 --- a/oamapps/calpontSupport/findStranded.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh - -# -# This script lists InfiniDBlpont data files that do not have associated extent map entries. -# -# NOTES: -# 1) Only looks in $COLUMNSTORE_INSTALL_DIR/data* for the data files. -# 2) Only checks for an existing extent with a matching OID, doesn't validate that there is an -# existing extent for the exact segment. -# -# Close enough for hand grenades. - -if [ -z "$COLUMNSTORE_INSTALL_DIR" ]; then - COLUMNSTORE_INSTALL_DIR=/usr/local/mariadb/columnstore -fi - -export COLUMNSTORE_INSTALL_DIR=$COLUMNSTORE_INSTALL_DIR - -if [ $COLUMNSTORE_INSTALL_DIR != "/usr/local/mariadb/columnstore" ]; then - export PATH=$COLUMNSTORE_INSTALL_DIR/bin:$COLUMNSTORE_INSTALL_DIR/mysql/bin:/bin:/usr/bin - export LD_LIBRARY_PATH=$COLUMNSTORE_INSTALL_DIR/lib:$COLUMNSTORE_INSTALL_DIR/mysql/lib -fi - -cd $COLUMNSTORE_INSTALL_DIR - -last=-1 -existsInExtentMap=0 -count=0 - -for i in $COLUMNSTORE_INSTALL_DIR/data*/*/*/*/*/*/FILE*cdf; do - let count++ - oid=`$COLUMNSTORE_INSTALL_DIR/bin/file2oid.pl $i` - if [ $last -ne $oid ]; then - last=$oid - existsInExtentMap=`$COLUMNSTORE_INSTALL_DIR/bin/editem -o $oid | wc -l` - fi - if [ $existsInExtentMap -le 0 ]; then - echo "Missing oid $oid path $i" - fi -done diff --git a/oamapps/calpontSupport/getMinMax.sh b/oamapps/calpontSupport/getMinMax.sh deleted file mode 100755 index 9a95e518d..000000000 --- a/oamapps/calpontSupport/getMinMax.sh +++ /dev/null @@ -1,132 +0,0 @@ -#!/bin/bash - -# -# Reports the max value from the extent map for the given column. -# - -# -# Initialize variables. -# - -if [ -z "$MYSQLCMD" ]; then - INSTALLDIR="/usr/local/mariadb/columnstore" - MYSQLCNF=$INSTALLDIR/mysql/my.cnf - MYSQLCMD="$INSTALLDIR/mysql/bin/mysql --defaults-extra-file=$MYSQLCNF -u root" -fi - -# -# Validate that there are three parameters - schema and table and columnname. -# -if [ $# -ne 3 ]; then - echo "" - echo "Reports the max value for the given column." - echo "" - echo "Parameters:" - echo " Schema" - echo " Table" - echo " Column" - exit 1 -fi -db=$1 -table=$2 -column=$3 - -# -# Validate that the column exists. -# -sql="select count(*) from syscolumn where \`schema\`='$db' and tablename='$table' and columnname='$column';" -count=`$MYSQLCMD calpontsys --skip-column-names -e "$sql;"` -if [ $count -le 0 ]; then - echo "" - echo "$db.$table.$column does not exist in InfiniDB." - echo "" - exit 1 -fi - -# -# Validate that the column type is one that this script supports. -# Supported Types: -# 6 int -# 8 date -# 9 bigint -# 11 datetime -sql="select datatype from syscolumn where \`schema\`='$db' and tablename='$table' and columnname='$column';" -dataType=`$MYSQLCMD calpontsys --skip-column-names -e "$sql"` -if [ $dataType -ne 6 ] && [ $dataType -ne 8 ] && [ $dataType -ne 9 ] && [ $dataType -ne 11 ]; then - echo "" - echo "The column data type must be an int, bigint, date, or datetime." - echo "" - exit 1 -fi - -# -# Grab the objectid for the column. -# -sql="select objectid from syscolumn where \`schema\`='$db' and tablename='$table' and columnname='$column';" -objectid=`$MYSQLCMD calpontsys --skip-column-names -e "$sql"` - -# -# Set the editem specific parameter if the column is a date or datetime. -# -if [ $dataType -eq 8 ]; then - parm="-t" -elif [ $dataType -eq 11 ]; then - parm="-s" -fi - -# -# Use the editem utility to get the min and max value. -# -/usr/local/mariadb/columnstore/bin/editem -o $objectid $parm | grep max | awk -v dataType=$dataType ' - BEGIN { - allValid=1; - foundValidExtent=0; - } - { - if(dataType == 11) { - state=substr($14, 1, length($14)-1); # Datetime has date and time as two fields. - thisMin=$6 " " substr($7, 1, length($7)-1); - thisMax=$9 " " substr($10, 1, length($10)-1); - } - else { - state=substr($12, 1, length($12)-1); - thisMin=substr($6, 1, length($6)-1); - thisMax=substr($8, 1, length($8)-1); - } - if(state == "valid") { - if(!foundValidExtent) { - min=thisMin; - max=thisMax; - foundValidExtent=1; - } - else { - if(thisMin < min) { - min=thisMin; - } - if(thisMax > max) { - max=thisMax; - } - } - } - else { - allValid=0; - } - } - END { - if(foundValidExtent == 1) { - print ""; - print "Min=" min; - print "Max=" max; - print ""; - if(allValid == 0) { - print "Not all extents had min and max values set. Answer is incomplete." - } - } - else { - print ""; - print "There were not any extents with valid min/max values. Unable to provide answer."; - print ""; - } - }' - -exit 0 diff --git a/oamapps/calpontSupport/hadoopReport.sh b/oamapps/calpontSupport/hadoopReport.sh deleted file mode 100755 index 644e696d9..000000000 --- a/oamapps/calpontSupport/hadoopReport.sh +++ /dev/null @@ -1,69 +0,0 @@ -#! /bin/sh -# - -if [ $1 ] ; then - MODULE=$1 -else - MODULE="pm1" -fi - -if [ $2 ] ; then - INSTALLDIR=$2 -else - INSTALLDIR="/usr/local/mariadb/columnstore" -fi - -if [ $USER = "hdfs" ]; then - SUDO=" " -else - SUDO="sudo -u hdfs" -fi - -sudo rm -f /tmp/hdfsReport.txt - -{ -echo -echo "****************************** HDFS REPORT ********************************" -echo -echo "-- Hadoop version --" -echo -echo "################# hadoop version #################" -echo -$SUDO hadoop version - -echo -echo "-- Data File Plugin --" -echo -echo "######### $INSTALLDIR/bin/getConfig SystemConfig DataFilePlugin ##########" -echo -sudo $INSTALLDIR/bin/getConfig SystemConfig DataFilePlugin - -echo -echo -echo "-- Hadoop Configuration File --" -echo -echo "################ core-site.xml ################" -echo -cat $HADOOP_CONF_DIR/core-site.xml - -echo -echo "################ hdfs-site.xml ################" -echo -cat $HADOOP_CONF_DIR/hdfs-site.xml - -echo -echo "-- Hadoop Health Check --" -echo -echo "################# hdfs dfsadmin -report #################" -echo -$SUDO hadoop dfsadmin -report 2>/dev/null - -echo -echo "-- HDFS check --" -echo -echo "################# hdfs fsck $INSTALLDIR #################" -echo -$SUDO hadoop fsck $INSTALLDIR 2>/dev/null -} > /tmp/hadoopReport.txt - -exit 0 diff --git a/oamapps/calpontSupport/hardwareReport.sh b/oamapps/calpontSupport/hardwareReport.sh deleted file mode 100755 index 1fedeffaa..000000000 --- a/oamapps/calpontSupport/hardwareReport.sh +++ /dev/null @@ -1,101 +0,0 @@ -#! /bin/sh -# -# $Id: hardwareReport.sh 421 2007-04-05 15:46:55Z dhill $ -# -if [ $1 ] ; then - MODULE=$1 -else - MODULE="pm1" -fi - -if [ $2 ] ; then - INSTALLDIR=$2 -else - INSTALLDIR="/usr/local/mariadb/columnstore" -fi - -if [ $USER = "root" ]; then - SUDO=" " -else - SUDO="sudo" -fi - -$SUDO rm -f /tmp/${MODULE}_hardwareReport.txt - -{ -echo " " -echo "******************** Hardware Report for ${MODULE} ********************" -echo " " - -echo "-- Server OS Version --" -echo " " -echo "################# cat /proc/version #################" -echo " " -$SUDO cat /proc/version 2>/dev/null -echo " " -echo "################# uname -a #################" -echo " " -uname -a -echo " " -echo "################# cat /etc/issue #################" -echo " " -cat /etc/issue 2>/dev/null -echo " " -echo "run os_check.sh" -echo " " -echo "################# /bin/os_check.sh #################" -echo " " -$INSTALLDIR/bin/os_check.sh 2>/dev/null - -echo " " -echo "-- Server Uptime --" -echo " " -echo "################# uptime #################" -echo " " -uptime - -echo " " -echo "-- Server cpu-info --" -echo " " -echo "################# cat /proc/cpuinfo #################" -echo " " -$SUDO cat /proc/cpuinfo 2>/dev/null - -echo " " -echo "-- Server memory-info --" -echo " " -echo "################# cat /proc/meminfo #################" -echo " " -$SUDO cat /proc/meminfo 2>/dev/null - -echo " " -echo "-- Server mounts --" -echo " " -echo "################# cat /proc/mounts #################" -echo " " -$SUDO cat /proc/mounts 2>/dev/null - -echo " " -echo "-- Server Disk Scheduler for Calpont Mounts --" -echo " " -for scsi_dev in `mount | awk '/mnt\/tmp/ {print $1}' | awk -F/ '{print $3}' | sed 's/[0-9]*$//'`; do - echo '/dev/'$scsi_dev ' scheduler setup is' - cat /sys/block/$scsi_dev/queue/scheduler 2>/dev/null -done -for scsi_dev in `mount | awk '/Calpont\/data/ {print $1}' | awk -F/ '{print $3}' | sed 's/[0-9]*$//'`; do - if [ $scsi_dev != "local" ] ; then - echo '/dev/'$scsi_dev ' scheduler setup is' - cat /sys/block/$scsi_dev/queue/scheduler 2>/dev/null - fi -done - -echo " " -echo "-- Server Ethernet Configuration --" -echo " " -echo "################# ifconfig -a #################" -echo " " -ifconfig -a 2>/dev/null - -} > /tmp/${MODULE}_hardwareReport.txt - -exit 0 \ No newline at end of file diff --git a/oamapps/calpontSupport/logReport.sh b/oamapps/calpontSupport/logReport.sh deleted file mode 100755 index 18da759a2..000000000 --- a/oamapps/calpontSupport/logReport.sh +++ /dev/null @@ -1,27 +0,0 @@ -#! /bin/sh -# -# $Id: logReport.sh 421 2007-04-05 15:46:55Z dhill $ -# -if [ $1 ] ; then - MODULE=$1 -else - MODULE="pm1" -fi - -if [ $2 ] ; then - INSTALLDIR=$2 -else - INSTALLDIR="/usr/local/mariadb/columnstore" -fi - -if [ $USER = "root" ]; then - SUDO=" " -else - SUDO="sudo" -fi - -$SUDO rm -f /tmp/${MODULE}_logReport.tar.gz - -tar -zcf /tmp/${MODULE}_logReport.tar.gz /var/log/mariadb/columnstore > /dev/null 2>&1 - -exit 0 diff --git a/oamapps/calpontSupport/minMaxCheck.sh b/oamapps/calpontSupport/minMaxCheck.sh deleted file mode 100755 index 4e36db272..000000000 --- a/oamapps/calpontSupport/minMaxCheck.sh +++ /dev/null @@ -1,170 +0,0 @@ -#!/bin/bash -# -# $Id: minMaxCheck.sh 1479 2011-07-20 09:53:32Z wweeks $ -# - -# -# This script resets the EM Min/Max values for the coluns defined in the cols array. -# -# Usage: -# ./minMax.sh -# runs against the columns defined in the cols array below. -# ./minMaxCheck.sh all -# run for all CP columns in the database (will take a long time against a large database). -# ./minMaxCheck.sh schemaname -# run for CP columns in tables in the schema. If your schema is named all, you'll get all columns. -# ./minMaxCheck.sh schemaname tablename -# run for CP columns against the given table. -# ./minMaxCheck.sh schemaname tablename columnname -# run against the given column. -# -# The script does the following: -# 1) Runs editem for the column. -# 2) Clears the min/max for the column with editem -c. -# 3) Counts the column so that the min/max get set again. -# 4) Runs editem for the column again. -# 5) Diffs the two editem runs and reports / saves the sdiff log files for the column if any of extents had the min/max changed. -# -# Notes: -# 1) An info.log entry will be logged at the end of the script if none of the columns checked had a bad extent map entry. -# Example: -# Mar 11 14:11:29 srvqaperf8 oamcpp[9872]: 29.091980 |0|0|0| I 08 CAL0000: min-max-monitor: okay -# 2) Two warning.log entries will be logged at the end of the script if one or min/max EM entries were corrected. -# Example: -# Mar 11 14:16:36 srvqaperf8 oamcpp[16364]: 36.231731 |0|0|0| W 08 CAL0000: min-max-monitor: some values were reset for oids 3004 3005 -# Mar 11 14:16:36 srvqaperf8 oamcpp[16365]: 36.263270 |0|0|0| W 08 CAL0000: min-max-monitor: log files are /tmp/idb_mm_mon.sdiff.*.15190 -# 3) The script outputs the results of the selects in #3 above as it's going through the columns and will echo a line when it finds a col that was corrected. -# Example: -# **** Extent map min/max changed on the scan. See results in /tmp/idb_mm_mon.sdiff.3039.15190 - - -# Define the cols array. Here's a sql statement that will list the date and datetime cols in the expected format. -# idbmysql calpontsys -e "select concat(objectid, ':', \`schema\`, '.', tablename, '.', columnname) from syscolumn where datatype in (8, 11) and tablename not like 'temp%';" > www.txt -# -# NOTE: The objectid will be looked up again when it's going through the columns in case the one in the array becomes stale. -# - -if [ -z "$MYSQLCMD" ]; then - MYSQLCMD="/usr/local/mariadb/columnstore/mysql/bin/mysql --defaults-extra-file=/usr/local/mariadb/columnstore/mysql/my.cnf -u root" -fi - -if [ -z "$INSTALLDIR" ]; then - INSTALLDIR="/usr/local/mariadb/columnstore" -fi - -if [ -z "$PGMPATH" ]; then - PGMPATH=$INSTALLDIR/bin -fi - -cols=( -1339664:tpch1.orders.o_orderdate -1339718:tpch1.lineitem.l_shipdate -1339719:tpch1.lineitem.l_commitdate -1339720:tpch1.lineitem.l_receiptdate -1339759:dml.orders.o_orderdate -1339813:dml.lineitem.l_shipdate -1339814:dml.lineitem.l_commitdate -1339815:dml.lineitem.l_receiptdate -) - -# -# If called with "all", run the script against all of the column types that use CP. -# -if [ $# -eq 1 ] && [ "$1" == "all" ]; then - $MYSQLCMD --execute="select concat(objectid, ':', \`schema\`, '.', tablename, '.', columnname) from syscolumn where datatype not in (4, 10, 13) and not (datatype = 2 and columnlength > 8) and not (datatype = 12 and columnlength > 7);" calpontsys --skip-column-names > /tmp/idb_mm_mon.cols - cols=( $( cat /tmp/idb_mm_mon.cols ) ) - rm -f /tmp/idb_mm_mon.cols - -# -# Else if one parm passed, run against the columns in the given schema. -# -elif [ $# -eq 1 ]; then - db=$1 - $MYSQLCMD --execute="select concat(objectid, ':', \`schema\`, '.', tablename, '.', columnname) from syscolumn where datatype not in (4, 10, 13) and not (datatype = 2 and columnlength > 8) and not (datatype = 12 and columnlength > 7) and \`schema\` = '$db';" calpontsys --skip-column-names > /tmp/idb_mm_mon.cols - cols=( $( cat /tmp/idb_mm_mon.cols ) ) - rm -f /tmp/idb_mm_mon.cols - -# -# Else if two parms passed, run the script against all the columns that use CP for that table. -# -elif [ $# -eq 2 ]; then - db=$1 - tbl=$2 - $MYSQLCMD --execute="select concat(objectid, ':', \`schema\`, '.', tablename, '.', columnname) from syscolumn where datatype not in (4, 10, 13) and not (datatype = 2 and columnlength > 8) and not (datatype = 12 and columnlength > 7) and \`schema\` = '$db' and tablename = '$tbl';" calpontsys --skip-column-names > /tmp/idb_mm_mon.cols - cols=( $( cat /tmp/idb_mm_mon.cols ) ) - rm -f /tmp/idb_mm_mon.cols - -# -# Else if three parms passed, run the script against the column. -# -elif [ $# -eq 3 ]; then - db=$1 - tbl=$2 - col=$3 - $MYSQLCMD --execute="select concat(objectid, ':', \`schema\`, '.', tablename, '.', columnname) from syscolumn where \`schema\` = '$db' and tablename = '$tbl' and columnname='$col';" calpontsys --skip-column-names > /tmp/idb_mm_mon.cols - cols=( $( cat /tmp/idb_mm_mon.cols ) ) - rm -f /tmp/idb_mm_mon.cols -fi - -i=0 -j=0 - -if [ ${#cols[@]} -le 0 ]; then - $PGMPATH/cplogger -w 0 "min-max-monitor: no qualifying columns" "$badoidlist" - echo "min-max-monitor: no qualifying columns" "$badoidlist" - exit 1 -fi - -badoidlist= -while [ $i -lt ${#cols[@]} ]; do - let row=$i+1 - echo "" - echo "Evaluating $row of ${#cols[@]} at `date`. Col is ${cols[$i]}." - eval $(echo ${cols[$i]} | awk -F: '{printf "oid=%d\ntcn=%s\n", $1, $2}') - eval $(echo $tcn | awk -F. '{printf "schema=%s\ntable=%s\ncolumn=%s\n", $1, $2, $3}') - - # - # Look up the oid if the cols array is being used to keep from having to continually update the array if tables are dropped and recreated. - # - if [ $# -eq 0 ]; then - $MYSQLCMD --execute="select concat(objectid, ':', \`schema\`, '.', tablename, '.', columnname) from syscolumn where \`schema\` = '$schema' and tablename='$table' and columnname='$column';" calpontsys --skip-column-names > /tmp/idb_mm_mon.cols - results=`wc -l /tmp/idb_mm_mon.cols | awk '{print $1}'` - if [ $results -eq 0 ]; then - oid=0 - else - oid=`cat /tmp/idb_mm_mon.cols` - fi - fi - - $PGMPATH/editem -o$oid | awk '{print $1, $6, $8, $12}' >/tmp/idb_mm_mon.$oid.1.$$ - $PGMPATH/editem -c$oid - $MYSQLCMD --execute="select count($column) from $table" $schema -vvv - $PGMPATH/editem -o$oid | awk '{print $1, $6, $8, $12}' >/tmp/idb_mm_mon.$oid.2.$$ - sdiff /tmp/idb_mm_mon.$oid.1.$$ /tmp/idb_mm_mon.$oid.2.$$ --suppress-common-lines | grep -n -v invalid > /tmp/idb_mm_mon.sdiff.$oid.$$ - count=`wc -l /tmp/idb_mm_mon.sdiff.$oid.$$ | awk '{print $1}'` - if [ $count -ne 0 ]; then - badoidlist="$badoidlist $oid" - ((j++)) - echo "**** Extent map min/max changed on the scan. See results in /tmp/idb_mm_mon.sdiff.$oid.$$" - else - rm -f /tmp/idb_mm_mon.sdiff.$oid.$$ - fi - rm -f /tmp/idb_mm_mon.$oid.*.$$ - ((i++)) -done -echo "" -if [ $j -eq 0 ]; then - $PGMPATH/cplogger -i 0 "min-max-monitor: okay" - echo "min-max-monitor: okay" - echo "" - exit 0 -else - $PGMPATH/cplogger -w 0 "min-max-monitor: some values were reset for oids" "$badoidlist" - $PGMPATH/cplogger -w 0 "min-max-monitor: log files are /tmp/idb_mm_mon.sdiff.*.$$" - echo "min-max-monitor: some values were reset for oids" "$badoidlist" - echo "min-max-monitor: log files are /tmp/idb_mm_mon.sdiff.*.$$" - echo "" - exit 1 -fi - - diff --git a/oamapps/calpontSupport/resourceReport.sh b/oamapps/calpontSupport/resourceReport.sh deleted file mode 100755 index 5beda4a76..000000000 --- a/oamapps/calpontSupport/resourceReport.sh +++ /dev/null @@ -1,74 +0,0 @@ -#! /bin/sh -# -# $Id: resourceReport.sh 421 2007-04-05 15:46:55Z dhill $ -# -if [ $1 ] ; then - MODULE=$1 -else - MODULE="pm1" -fi - -if [ $2 ] ; then - INSTALLDIR=$2 -else - INSTALLDIR="/usr/local/mariadb/columnstore" -fi - -if [ $USER = "root" ]; then - SUDO=" " -else - SUDO="sudo" -fi - -$SUDO rm -f /tmp/${MODULE}_resourceReport.txt - -{ -echo " " -echo "******************** Resource Usage Report for ${MODULE} ********************" -echo " " - -echo " " -echo "-- Shared Memory --" -echo " " -echo "################# ipcs -l #################" -echo " " -$SUDO ipcs -l - -echo "################# $INSTALLDIR/bin/clearShm -n #################" -echo " " -$INSTALLDIR/bin/clearShm -n - -echo " " -echo "-- Disk Usage --" -echo " " -echo "################# df -k #################" -echo " " -$SUDO df -k - -echo " " -echo "-- Disk BRM Data files --" -echo " " -ls -l $INSTALLDIR/data1/systemFiles/dbrm 2> /dev/null -ls -l $INSTALLDIR/dbrm 2> /dev/null - -echo "################# cat $INSTALLDIR/data1/systemFiles/dbrm/BRM_saves_current #################" -echo " " -cat $INSTALLDIR/data1/systemFiles/dbrm/BRM_saves_current 2> /dev/null - -echo " " -echo "-- View Table Locks --" -echo " " -echo "################# cat bin/viewtablelock #################" -echo " " -$INSTALLDIR/bin/viewtablelock 2> /dev/null - -echo " " -echo "-- BRM Extent Map --" -echo " " -echo "################# bin/editem -i #################" -echo " " -$INSTALLDIR/bin/editem -i 2>/dev/null - -} > /tmp/${MODULE}_resourceReport.txt - -exit 0 \ No newline at end of file diff --git a/oamapps/calpontSupport/sqlLogs.sh b/oamapps/calpontSupport/sqlLogs.sh deleted file mode 100755 index 818ab546c..000000000 --- a/oamapps/calpontSupport/sqlLogs.sh +++ /dev/null @@ -1,225 +0,0 @@ -#!/bin/bash - -# -# Script that does analysis on SQL statements from an InfiniDB debug log. -# -DB=idb_idb_sqllogs -TABLE=statements - -if [ -z "$COLUMNSTORE_INSTALL_DIR" ]; then - COLUMNSTORE_INSTALL_DIR=/usr/local/mariadb/columnstore -fi - -export COLUMNSTORE_INSTALL_DIR=$COLUMNSTORE_INSTALL_DIR - -if [ $COLUMNSTORE_INSTALL_DIR != "/usr/local/mariadb/columnstore" ]; then - export PATH=$COLUMNSTORE_INSTALL_DIR/bin:$COLUMNSTORE_INSTALL_DIR/mysql/bin:/bin:/usr/bin - export LD_LIBRARY_PATH=$COLUMNSTORE_INSTALL_DIR/lib:$COLUMNSTORE_INSTALL_DIR/mysql/lib -fi - - -if [ -z "$MYSQLCMD" ]; then - MYSQLCMD="$COLUMNSTORE_INSTALL_DIR/mysql/bin/mysql --defaults-extra-file=$COLUMNSTORE_INSTALL_DIR/mysql/my.cnf -u root" - export MYSQLCMD -fi - -main() -{ - if [ "$option" == "usage" ]; then - usage - exit - elif [ "$option" == "create" ]; then - if [ -f $logFile ]; then - create - else - echo "" - usage - echo "" - echo "*** $logFile not found. Pleae specify a valid debug log file.***" - echo "" - exit - fi - elif [ "$option" == "list" ]; then - list - elif [ "$option" == "listAll" ]; then - listAll - elif [ "$option" == "active" ]; then - listActive - elif [ "$option" == "activeAll" ]; then - listActiveAll - else - echo "" - usage - echo "*** $option is not a valid option. ***" - echo "" - exit - fi - -} - -usage () -{ - echo " - This script can be used to analyze select statements from an InfiniDB debug log. - - Usage: - - ./sqlLogs.sh create [debug log file name - default:debug.log] - Creates an $DB.$TABLE table with the select statements from the debug log. Must be run before other options can be used. - - ./sqlLogs.sh list - Lists the SQL statements and run times showing the following: - id - statement id in sequential order based on the start time - starttime - start time of the statement - endtime - end time of the statement - runtime - total run time of the statement - sessionid - the MySQL session id for the statement - sessionstatementid - the sequence of the statement within the session - - ./sqlLogs.sh listAll - Same as list with the addition of the SQL statement. - - ./sqlLogs.sh active timestamp - Example: ./sqlLogs.sh active 00:35:50.291408 - Lists the id, starttime, endtime, runtime, timeActive, sessionid, and sessionstatementid for the sql statements - that were active at the given timestamp. - - ./sqlLogs.sh activeAll timestamp - Same as listActive with the addition of the SQL statement. - " - -} - -create () -{ - echo "" - echo "Step 1 of 4. Building import file with Start SQL log entries." - grep "Start SQL" $logFile | grep -v syscolumn | grep -v systable | awk -F '|' '{print NR "|" substr($1,8,6) substr($1,length($1)-9,9) "|" $2 "|" $5}' | - sort -t '|' -n -k 3 -k 1 | - awk -F '|' ' - { - if(NR == 1) - { - prevSession=$3; - val=1; - } - else if(prevSession == $3) - val++; - else - { - val=1; - prevSession=$3; - } - print $0 "|" val "|" - }' | sort -t '|' -n -k 1 > /tmp/idbtmp.tbl - - echo "Step 2 of 4. Populating $DB.start table with Start SQL log entries." - sql=" - create database if not exists $DB; - use $DB; - drop table if exists start; - CREATE TABLE start ( - id int, - time char(20), - sessionid int, - statement varchar(8000), - sessionStatementId int - ) ENGINE=MyISAM ; - create index start_idx on start (sessionid, sessionStatementId); - load data infile '/tmp/idbtmp.tbl' into table start fields terminated by '|'; - " - $MYSQLCMD -e "$sql" - - echo "Step 3 of 4. Building import file with End SQL log entries." - grep "End SQL" $logFile | grep -v "2147483" | awk -F '|' '{print NR "|" substr($1,8,6) substr($1,length($1)-9,9) "|" $2}' | - sort -t '|' -n -k 3 -k 1 | - awk -F '|' ' - { - if(NR == 1) - { - prevSession=$3; - val=1; - } - else if(prevSession == $3) - val++; - else - { - val=1; - prevSession=$3; - } - print $0 "|" val "|" - }' | sort -t '|' -n -k 1 > /tmp/idbtmp.tbl - - echo "Step 4 of 4. Populating $DB.stop table with End SQL log entries." - sql=" - drop table if exists stop; - CREATE TABLE stop ( - id int, - time char(20), - sessionid int, - sessionStatementId int - ) ENGINE=MyISAM ; - create index stop_idx on stop (sessionid, sessionStatementId); - load data infile '/tmp/idbtmp.tbl' into table stop fields terminated by '|'; - " - $MYSQLCMD $DB -e "$sql;" - - echo "Step 5 of 5. Populating $DB.$TABLE table." - sql=" - drop table if exists $TABLE; - create table $TABLE as - (select - a.id id, a.time starttime, b.time endtime, substr(timediff(b.time, a.time), 1, 30) runTime, a.sessionid sessionId, a.sessionstatementid sessionStatementId, a.statement statement - from start a left join stop b - on a.sessionid = b.sessionid and a.sessionstatementid = b.sessionstatementid); - " - $MYSQLCMD $DB -e "$sql" - - echo "All done." - echo "" -} - -list() { - sql="select id, starttime, endtime, runtime, sessionid, sessionstatementid from statements;" - $MYSQLCMD $DB -vvv -e "$sql" -} - -listAll() -{ - sql="select id, starttime, endtime, runtime, sessionid, sessionstatementid, trim(statement) statement from statements;" - $MYSQLCMD $DB -vvv -e "$sql" -} - -listActive() -{ - dtm=$parm2 - sql=" - select id, starttime, endtime, runtime, timediff('$dtm', starttime) timeActive, sessionid, sessionstatementid from statements - where starttime <= '$dtm' and (endtime is null or endtime > '$dtm'); - " - $MYSQLCMD $DB -vvv -e "$sql" -} - -listActiveAll() -{ - dtm=$parm2 - sql=" - select id, starttime, endtime, runtime, timediff('$dtm', starttime) timeActive, sessionid, sessionstatementid, trim(statement) statement from statements - where starttime <= '$dtm' and (endtime is null or endtime > '$dtm'); - " - $MYSQLCMD $DB -vvv -e "$sql" -} - -if [ $# -lt 1 ]; then - usage - exit -else - option=$1 - parm2=$2 - logFile=debug.log - if [ $# -ge 2 ]; then - logFile=$2 - fi -fi - -main diff --git a/oamapps/columnstoreSupport/bulklogReport.sh b/oamapps/columnstoreSupport/bulklogReport.sh index 16faeec1e..29398b984 100755 --- a/oamapps/columnstoreSupport/bulklogReport.sh +++ b/oamapps/columnstoreSupport/bulklogReport.sh @@ -14,14 +14,7 @@ else INSTALLDIR="/usr/local/mariadb/columnstore" fi -USER=`whoami 2>/dev/null` -if [ $USER = "root" ]; then - SUDO=" " -else - SUDO="sudo" -fi - -$SUDO rm -f /tmp/${MODULE}_bulklogReport.txt +rm -f /tmp/${MODULE}_bulklogReport.txt { diff --git a/oamapps/columnstoreSupport/calpontSupport.cpp b/oamapps/columnstoreSupport/calpontSupport.cpp deleted file mode 100644 index 6dd8f375f..000000000 --- a/oamapps/columnstoreSupport/calpontSupport.cpp +++ /dev/null @@ -1,1102 +0,0 @@ -/* Copyright (C) 2013 Columnstore Corp. */ - - -/****************************************************************************************** -* $Id: columnstoreSupport.cpp 64 2006-10-12 22:21:51Z dhill $ -* -* -* -******************************************************************************************/ -/** - * @file - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "stdio.h" -#include "ctype.h" -#include -#include - -#include "liboamcpp.h" -#include "configcpp.h" -#include "installdir.h" - -using namespace std; -using namespace oam; -using namespace config; - -typedef struct Child_Module_struct -{ - std::string moduleName; - std::string moduleIP; - std::string hostName; -} ChildModule; - -typedef std::vector ChildModuleList; - -string currentDate; -string systemName; -string localModule; -string localModuleHostName; -ChildModuleList childmodulelist; -ChildModuleList parentmodulelist; -ChildModule childmodule; - -string rootPassword = ""; -string debug_flag = "0"; -string mysqlpw = " "; - -int runningThreads = 0; -pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; - -typedef boost::tuple threadInfo_t; - -bool LOCAL = false; - -void title(string outputFile = "columnstoreSupportReport.txt") -{ - string cmd = "echo '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' System " + systemName + "' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' columnstoreSupportReport script ran from Module " + localModule + " on " + currentDate + "' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%' >> " + outputFile; - system(cmd.c_str()); -} - -void childReportThread(threadInfo_t& st) -{ - ChildModuleList::iterator& list = boost::get<0>(st); - string reportType = boost::get<1>(st); - - string remoteModuleName = (*list).moduleName; - string remoteModuleIP = (*list).moduleIP; - string remoteHostName = (*list).hostName; - - string installDir(startup::StartUp::installDir()); - - pthread_mutex_lock( &mutex1 ); - runningThreads++; -//cout << "++ " << runningThreads << endl; - pthread_mutex_unlock( &mutex1 ); - - string outputFile; - - if (reportType == "log") - { - outputFile = remoteModuleName + "_" + reportType + "Report.tar.gz"; - } - else if (reportType == "hadoop") - { - outputFile = "hadoopReport.txt"; - } - else - { - outputFile = remoteModuleName + "_" + reportType + "Report.txt"; - - title(outputFile); - - string cmd = "echo '=======================================================================' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '= " + reportType + " report =' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '=======================================================================' >> " + outputFile; - system(cmd.c_str()); - } - - //run remote report script - if (reportType == "hadoop") - cout << "Get " + reportType + " report data" << endl; - else - cout << "Get " + reportType + " report data for " + remoteModuleName + " " << endl; - - cout.flush(); - - string cmd = installDir + "/bin/remote_command.sh " + remoteModuleIP + " " + rootPassword + " '" + - installDir + "/bin/" + reportType + "Report.sh " + remoteModuleName + " " + installDir + - "' " + debug_flag + " - forcetty"; - int rtnCode = system(cmd.c_str()); - - if (WEXITSTATUS(rtnCode) != 0) - { - cout << "Error with running remote_command.sh, exiting..." << endl; - } - - cmd = installDir + "/bin/remote_scp_get.sh " + remoteModuleIP + " " + rootPassword + " /tmp/" + outputFile + " > /dev/null 2>&1"; - rtnCode = system(cmd.c_str()); - - if (WEXITSTATUS(rtnCode) != 0) - cout << "ERROR: failed to retrieve /tmp/" << outputFile << " from " + remoteHostName << endl; - - pthread_mutex_lock( &mutex1 ); - runningThreads--; -//cout << "-- " << runningThreads << endl; - pthread_mutex_unlock( &mutex1 ); - - // exit thread - pthread_exit(0); -} - -void reportThread(string reporttype) -{ - string reportType = reporttype; - - string installDir(startup::StartUp::installDir()); - Oam oam; - - pthread_mutex_lock( &mutex1 ); - runningThreads++; -//cout << "++ " << runningThreads << endl; - pthread_mutex_unlock( &mutex1 ); - - string outputFile = localModule + "_" + reportType + "Report.txt"; - - // run on child servers and get report - if (!LOCAL) - { - ChildModuleList::iterator list1 = childmodulelist.begin(); - - for (; list1 != childmodulelist.end() ; list1++) - { - threadInfo_t* st = new threadInfo_t; - *st = boost::make_tuple(list1, reportType); - - pthread_t childreportthread; - int status = pthread_create (&childreportthread, NULL, (void* (*)(void*)) &childReportThread, st); - - if ( status != 0 ) - { - cout << "ERROR: childreportthread: pthread_create failed, return status = " + oam.itoa(status) << endl; - } - - sleep(1); - } - } - - // run report on local server - cout << "Get " + reportType + " report data for " + localModule << endl; - - if (reportType == "log") - { - string cmd = installDir + "/bin/logReport.sh " + localModule + " " + installDir; - system(cmd.c_str()); - - cmd = "mv -f /tmp/" + localModule + "_logReport.tar.gz ."; - system(cmd.c_str()); - - cmd = "tar -zcf " + localModule + "_mysqllogReport.tar.gz " + installDir + "/mysql/db/*.err* 2>/dev/null"; - system(cmd.c_str()); - - // run log config on local server - cout << "Get log config data for " + localModule << endl; - - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '******************** Log Configuration ********************' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '################# mcsadmin getLogConfig ################# ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = installDir + "/bin/mcsadmin getLogConfig >> " + outputFile; - system(cmd.c_str()); - } - else - { - //get local report - title(outputFile); - - string cmd = "echo '=======================================================================' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '= " + reportType + " report =' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '=======================================================================' >> " + outputFile; - system(cmd.c_str()); - - cmd = installDir + "/bin/" + reportType + "Report.sh " + localModule + " " + installDir; - system(cmd.c_str()); - cmd = " mv -f /tmp/" + localModule + "_" + reportType + "Report.txt ."; - system(cmd.c_str()); - - if (reportType == "config" ) - { - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '******************** System Network Configuration ********************' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '################# mcsadmin getSystemNetworkConfig ################# ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = installDir + "/bin/mcsadmin getSystemNetworkConfig >> " + outputFile; - system(cmd.c_str()); - - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '******************** System Module Configure ********************' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '################# mcsadmin getModuleTypeConfig ################# ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = installDir + "/bin/mcsadmin getModuleTypeConfig >> " + outputFile; - system(cmd.c_str()); - - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '******************** System Storage Configuration ********************' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '################# mcsadmin getStorageConfig ################# ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = installDir + "/bin/mcsadmin getStorageConfig >> " + outputFile; - system(cmd.c_str()); - - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '******************** System Storage Status ********************' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '################# mcsadmin getStorageStatus ################# ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = installDir + "/bin/mcsadmin getStorageStatus >> " + outputFile; - system(cmd.c_str()); - - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '******************** System Status ********************' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '################# mcsadmin getSystemInfo ################# ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = installDir + "/bin/mcsadmin getSystemInfo >> " + outputFile; - system(cmd.c_str()); - - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '******************** System Configuration File ********************' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo '################# cat /etc/mariadb/columnstore.xml ################# ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - cmd = "cat " + installDir + "/etc/mariadb/columnstore.xml >> " + outputFile; - system(cmd.c_str()); - } - - if (reportType == "resource" ) - { - if (LOCAL) - { - cmd = "echo '################# mcsadmin getModuleResourceUsage ################# ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - string cmd = installDir + "/bin/mcsadmin getModuleResourceUsage " + localModule + " >> " + outputFile; - system(cmd.c_str()); - } - else - { - cmd = "echo '################# mcsadmin getSystemResourceUsage ################# ' >> " + outputFile; - system(cmd.c_str()); - cmd = "echo ' ' >> " + outputFile; - system(cmd.c_str()); - string cmd = installDir + "/bin/mcsadmin getSystemResourceUsage >> " + outputFile; - system(cmd.c_str()); - } - } - } - - // exit thread - pthread_mutex_lock( &mutex1 ); - runningThreads--; -//cout << "-- " << runningThreads << endl; - pthread_mutex_unlock( &mutex1 ); - - pthread_exit(0); -} - -int main(int argc, char* argv[]) -{ - Oam oam; - string installDir(startup::StartUp::installDir()); - - Config* sysConfig = Config::makeConfig(); - string SystemSection = "SystemConfig"; - string InstallSection = "Installation"; - - bool HARDWARE = false; - bool SOFTWARE = false; - bool CONFIG = false; - bool DBMS = false; - bool RESOURCE = false; - bool LOG = false; - bool BULKLOG = false; - bool HADOOP = false; - - //get current time and date - time_t now; - now = time(NULL); - struct tm tm; - localtime_r(&now, &tm); - char timestamp[200]; - strftime (timestamp, 200, "%m:%d:%y-%H:%M:%S", &tm); - currentDate = timestamp; - - char helpArg[3] = "-h"; - - // Get System Name - try - { - oam.getSystemConfig("SystemName", systemName); - } - catch (...) - { - systemName = "unassigned"; - } - - // get Local Module Name and Server Install Indicator - string singleServerInstall; - - oamModuleInfo_t st; - - try - { - st = oam.getModuleInfo(); - localModule = boost::get<0>(st); - } - catch (...) - { - cout << endl << "**** Failed : Failed to read Local Module Name" << endl; - exit(-1); - } - - try - { - oam.getSystemConfig("SingleServerInstall", singleServerInstall); - } - catch (...) - { - singleServerInstall = "y"; - } - - if (argc == 1) - { - argv[1] = &helpArg[0]; - argc = 2; - } - - string DataFilePlugin; - - try - { - DataFilePlugin = sysConfig->getConfig(SystemSection, "DataFilePlugin"); - } - catch (...) - { - cout << "ERROR: Problem accessing Columnstore configuration file" << endl; - exit(-1); - } - - for ( int i = 1; i < argc; i++ ) - { - if ( string("-h") == argv[i] ) - { - cout << endl; - cout << "'columnstoreSupport' generates a Set of System Support Report Files in a tar file" << endl; - cout << "called columnstoreSupportReport.'system-name'.tar.gz in the local directory." << endl; - cout << "It should be run on the server with the DBRM front-end." << endl; - cout << "Check the Admin Guide for additional information." << endl; - cout << endl; - cout << "Usage: columnstoreSupport [-h][-a][-hw][-s][-c][-db][-r][-l][-bl][-lc][-p 'root-password'][-mp 'mysql-root-password'][-de]"; - - // if hdfs set up print the hadoop option - if (!DataFilePlugin.empty()) - cout << "[-hd]"; - - cout << endl; - cout << " -h help" << endl; - cout << " -a Output all Reports (excluding Bulk Logs Reports)" << endl; - cout << " -hw Output Hardware Reports only" << endl; - cout << " -s Output Software Reports only" << endl; - cout << " -c Output Configuration/Status Reports only" << endl; - cout << " -db Output DBMS Reports only" << endl; - cout << " -r Output Resource Reports only" << endl; - cout << " -l Output Columnstore Log/Alarms Reports only" << endl; - cout << " -bl Output Columnstore Bulk Log Reports only" << endl; - cout << " -lc Output Reports for Local Server only" << endl; - cout << " -p password (multi-server systems), root-password or 'ssh' to use 'ssh keys'" << endl; - cout << " -mp mysql root user password" << endl; - cout << " -de Debug Flag" << endl; - - // if hdfs set up print the hadoop option - if (!DataFilePlugin.empty()) - cout << " -hd Output hadoop reports only" << endl; - - exit (0); - } - else - { - if ( string("-a") == argv[i] ) - { - HARDWARE = true; - SOFTWARE = true; - CONFIG = true; - DBMS = true; - RESOURCE = true; - LOG = true; - HADOOP = (DataFilePlugin.empty() ? false : true); - } - else if ( string("-hw") == argv[i] ) - HARDWARE = true; - else if ( string("-s") == argv[i] ) - SOFTWARE = true; - else if ( string("-c") == argv[i] ) - CONFIG = true; - else if ( string("-db") == argv[i] ) - DBMS = true; - else if ( string("-r") == argv[i] ) - RESOURCE = true; - else if ( string("-l") == argv[i] ) - LOG = true; - else if ( string("-bl") == argv[i] ) - BULKLOG = true; - else if ( string("-lc") == argv[i] ) - LOCAL = true; - else if ( string("-p") == argv[i] ) - { - i++; - - if ( argc == i ) - { - cout << "ERROR: missing root password argument" << endl; - exit(-1); - } - - rootPassword = argv[i]; - - //add single quote for special characters - if ( rootPassword != "ssh" ) - { - rootPassword = "'" + rootPassword + "'"; - } - } - else if ( string("-mp") == argv[i] ) - { - i++; - - if ( argc == i ) - { - cout << "ERROR: missing mysql root user password argument" << endl; - exit(-1); - } - - mysqlpw = argv[i]; - mysqlpw = "'" + mysqlpw + "'"; - } - else if ( string("-de") == argv[i] ) - debug_flag = "1"; - else if ( string("-hd") == argv[i] ) - { - HADOOP = (DataFilePlugin.empty() ? false : true); - } - else - { - cout << "Invalid Option of '" << argv[i] << "', run with '-h' for help" << endl; - exit (1); - } - } - } - - //default to -a if nothing is set - if ( !HARDWARE && !SOFTWARE && !CONFIG && !DBMS && !RESOURCE && !LOG && !BULKLOG && !HADOOP) - { - HARDWARE = true; - SOFTWARE = true; - CONFIG = true; - DBMS = true; - RESOURCE = true; - LOG = true; - HADOOP = (DataFilePlugin.empty() ? false : true); - } - - //get Parent OAM Module Name and setup of it's Custom OS files - string PrimaryUMModuleName; - - try - { - PrimaryUMModuleName = sysConfig->getConfig(SystemSection, "PrimaryUMModuleName"); - } - catch (...) - { - cout << "ERROR: Problem getting Parent OAM Module Name" << endl; - exit(-1); - } - - if ( PrimaryUMModuleName == "unassigned" ) - PrimaryUMModuleName = localModule; - - if ( (localModule != PrimaryUMModuleName) && DBMS ) - { - char* pcommand = 0; - char* p; - string argument = "n"; - - while (true) - { - cout << endl << "You selected to get the DBMS data." << endl; - cout << "You need to run the columnstoreSupport command on module '" << PrimaryUMModuleName << "' to get that information." << endl; - cout << "Or you can proceed on to get all data except the DBMS." << endl; - - pcommand = readline(" Do you want to proceed: (y or n) [n]: "); - - if (pcommand && *pcommand) - { - p = strtok(pcommand, " "); - argument = p; - free(pcommand); - pcommand = 0; - } - - if (pcommand) - { - free(pcommand); - pcommand = 0; - } - - if ( argument == "y") - { - cout << endl; - break; - } - else if ( argument == "n") - exit (1); - } - } - - //get number of worker-nodes, will tell us if a single server system - //get Parent OAM Module Name and setup of it's Custom OS files - try - { - string NumWorkers = sysConfig->getConfig("DBRM_Controller", "NumWorkers"); - - if ( NumWorkers == "1" ) - singleServerInstall = "y"; - } - catch (...) - {} - - if ( singleServerInstall == "n" && !LOCAL) - if ( HARDWARE || SOFTWARE || CONFIG || RESOURCE || LOG || HADOOP ) - if ( rootPassword.empty() ) - { - cout << "ERROR: Multi-Module System, Password Argument required or use '-lc' option, check help for more information" << endl; - exit(-1); - } - - //get Parent OAM Module Name and setup of it's Custom OS files - //string parentOAMModuleName; - ChildModule parentOAMModule; - - try - { - parentOAMModule.moduleName = sysConfig->getConfig(SystemSection, "ParentOAMModuleName"); - } - catch (...) - { - cout << "ERROR: Problem getting Parent OAM Module Name" << endl; - exit(-1); - } - - //Get list of configured system modules - SystemModuleTypeConfig sysModuleTypeConfig; - - try - { - oam.getSystemConfig(sysModuleTypeConfig); - } - catch (...) - { - cout << "ERROR: Problem reading the Columnstore System Configuration file" << endl; - exit(-1); - } - - string ModuleSection = "SystemModuleConfig"; - - for ( unsigned int i = 0 ; i < sysModuleTypeConfig.moduletypeconfig.size(); i++) - { - string moduleType = sysModuleTypeConfig.moduletypeconfig[i].ModuleType; - int moduleCount = sysModuleTypeConfig.moduletypeconfig[i].ModuleCount; - - if ( moduleCount == 0 ) - //no modules equipped for this Module Type, skip - continue; - - //get IP addresses and Host Names - DeviceNetworkList::iterator listPT = sysModuleTypeConfig.moduletypeconfig[i].ModuleNetworkList.begin(); - - for ( ; listPT != sysModuleTypeConfig.moduletypeconfig[i].ModuleNetworkList.end() ; listPT++) - { - string moduleName = (*listPT).DeviceName; - HostConfigList::iterator pt1 = (*listPT).hostConfigList.begin(); - string moduleIPAddr = (*pt1).IPAddr; - string moduleHostName = (*pt1).HostName; - - if ( moduleName == localModule) - { - localModuleHostName = moduleHostName; - } - - //save Child modules - if ( moduleName != localModule && moduleType != "xm") - { - childmodule.moduleName = moduleName; - childmodule.moduleIP = moduleIPAddr; - childmodule.hostName = moduleHostName; - childmodulelist.push_back(childmodule); - } - - if (moduleName == parentOAMModule.moduleName) - { - parentOAMModule.moduleIP = moduleIPAddr; - parentOAMModule.hostName = moduleHostName; - parentOAMModule.moduleName = moduleName; - } - } - } //end of i for loop - - // create a clean Columnstore Support Report - system("rm -f *_configReport.txt"); - system("rm -f *_dbmsReport.txt"); - system("rm -f *_hardwareReport.txt"); - system("rm -f *_logReport.txt"); - system("rm -f *_bulklogReport.txt"); - system("rm -f *_resourceReport.txt"); - system("rm -f *_softwareReport.txt"); - system("rm -f hadoopReport.txt"); - - // - // Software - // - - if ( SOFTWARE ) - { - string reportType = "software"; - pthread_t reportthread; - int status = pthread_create (&reportthread, NULL, (void* (*)(void*)) &reportThread, &reportType); - - if ( status != 0 ) - { - cout << "ERROR: reportthread: pthread_create failed, return status = " + oam.itoa(status); - } - - sleep(5); - } - - // - // Configuration - // - - if ( CONFIG ) - { - string reportType = "config"; - pthread_t reportthread; - int status = pthread_create (&reportthread, NULL, (void* (*)(void*)) &reportThread, &reportType); - - if ( status != 0 ) - { - cout << "ERROR: reportthread: pthread_create failed, return status = " + oam.itoa(status); - } - - sleep(5); - } - - // - // Alarms and Columnstore Logs - // - - if ( LOG ) - { - string reportType = "log"; - pthread_t reportthread; - int status = pthread_create (&reportthread, NULL, (void* (*)(void*)) &reportThread, &reportType); - - if ( status != 0 ) - { - cout << "ERROR: reportthread: pthread_create failed, return status = " + oam.itoa(status); - } - - sleep(5); - } - - // - // Bulk Logs - // - - if ( BULKLOG ) - { - string reportType = "bulklog"; - pthread_t reportthread; - int status = pthread_create (&reportthread, NULL, (void* (*)(void*)) &reportThread, &reportType); - - if ( status != 0 ) - { - cout << "ERROR: reportthread: pthread_create failed, return status = " + oam.itoa(status); - } - - sleep(5); - } - - // - // Hardware - // - - if ( HARDWARE ) - { - string reportType = "hardware"; - pthread_t reportthread; - int status = pthread_create (&reportthread, NULL, (void* (*)(void*)) &reportThread, &reportType); - - if ( status != 0 ) - { - cout << "ERROR: reportthread: pthread_create failed, return status = " + oam.itoa(status); - } - - sleep(5); - } - - // - // Resources - // - - if ( RESOURCE ) - { - string reportType = "resource"; - pthread_t reportthread; - int status = pthread_create (&reportthread, NULL, (void* (*)(void*)) &reportThread, &reportType); - - if ( status != 0 ) - { - cout << "ERROR: reportthread: pthread_create failed, return status = " + oam.itoa(status); - } - - sleep(5); - } - - // - // DBMS - // - - if ( DBMS ) - { - system("rm -f columnstoreSupportReport.txt;touch columnstoreSupportReport.txt"); - title(); - - system("echo '=======================================================================' >> columnstoreSupportReport.txt"); - system("echo '= DBMS Report =' >> columnstoreSupportReport.txt"); - system("echo '=======================================================================' >> columnstoreSupportReport.txt"); - - // run DBMS report on local server - cout << "Get dbms report data for " << localModule << endl; - - bool FAILED = false; - - if ( localModule != PrimaryUMModuleName ) - { - cout << " FAILED: run columnstoreSupport on '" << PrimaryUMModuleName << "' to get the dbrm report" << endl; - FAILED = true; - } - else - { - // check if mysql is supported and get info - string columnstoreMysql = installDir + "/mysql/bin/mysql --defaults-file=" + installDir + "/mysql/my.cnf -u root "; - string cmd = columnstoreMysql + " -e 'status' > /tmp/idbmysql.log 2>&1"; - system(cmd.c_str()); - - //check for mysql password set - string pwprompt = " "; - - if (oam.checkLogStatus("/tmp/idbmysql.log", "ERROR 1045") ) - { - cout << "NOTE: MySQL root user password is set" << endl; - - //needs a password, was password entered on command line - if ( mysqlpw == " " ) - { - //go check my.cnf - string file = installDir + "/mysql/my.cnf"; - ifstream oldFile (file.c_str()); - - vector lines; - char line[200]; - string buf; - - while (oldFile.getline(line, 200)) - { - buf = line; - string::size_type pos = buf.find("password", 0); - - if (pos != string::npos) - { - string::size_type pos1 = buf.find("=", 0); - - if (pos1 != string::npos) - { - pos = buf.find("#", 0); - - if (pos == string::npos) - { - //password arg in my.cnf, go get password - cout << "NOTE: Using password from my.cnf" << endl; - mysqlpw = buf.substr(pos1 + 1, 80); - cout << mysqlpw << endl; - break; - } - } - } - } - - oldFile.close(); - - if ( mysqlpw == " " ) - { - cout << "NOTE: No password provide on command line or found uncommented in my.cnf" << endl; - cout << endl; - string prompt = " *** Enter MySQL password > "; - mysqlpw = getpass(prompt.c_str()); - } - } - - //check for mysql password set - pwprompt = "--password=" + mysqlpw; - - string cmd = columnstoreMysql + pwprompt + " -e 'status' > /tmp/idbmysql.log 2>&1"; - system(cmd.c_str()); - - if (oam.checkLogStatus("/tmp/idbmysql.log", "ERROR 1045") ) - { - cout << "FAILED: Failed login using MySQL root user password '" << mysqlpw << "'" << endl; - FAILED = true; - } - } - - if (!FAILED) - { - // check if mysql is supported and get info - string columnstoreMysql = installDir + "/mysql/bin/mysql --defaults-file=" + installDir + "/mysql/my.cnf -u root " + pwprompt; - string cmd = columnstoreMysql + " -V > /dev/null 2>&1"; - int ret = system(cmd.c_str()); - - if ( WEXITSTATUS(ret) == 0) - { - // run DBMS report info - system("echo ' ' >> columnstoreSupportReport.txt"); - system("echo '******************** DBMS Columnstore Mysql Version ********************' >> columnstoreSupportReport.txt"); - system("echo ' ' >> columnstoreSupportReport.txt"); - cmd = "echo '################# " + columnstoreMysql + " -e status ################# ' >> columnstoreSupportReport.txt"; - system(cmd.c_str()); - cmd = "echo ' ' >> columnstoreSupportReport.txt"; - system(cmd.c_str()); - cmd = columnstoreMysql + " -e 'status' >> columnstoreSupportReport.txt"; - system(cmd.c_str()); - - system("echo ' ' >> columnstoreSupportReport.txt"); - system("echo '******************** DBMS Mysql Columnstore System Column ********************' >> columnstoreSupportReport.txt"); - system("echo ' ' >> columnstoreSupportReport.txt"); - cmd = "echo '################# " + columnstoreMysql + " -e desc calpontsys.syscolumn ################# ' >> columnstoreSupportReport.txt"; - system(cmd.c_str()); - cmd = "echo ' ' >> columnstoreSupportReport.txt"; - system(cmd.c_str()); - cmd = columnstoreMysql + " -e 'desc calpontsys.syscolumn;' >> columnstoreSupportReport.txt"; - system(cmd.c_str()); - - system("echo ' ' >> columnstoreSupportReport.txt"); - system("echo '******************** DBMS Mysql Columnstore System Table ********************' >> columnstoreSupportReport.txt"); - system("echo ' ' >> columnstoreSupportReport.txt"); - cmd = "echo '################# " + columnstoreMysql + " -e desc calpontsys.systable ################# ' >> columnstoreSupportReport.txt"; - system(cmd.c_str()); - cmd = "echo ' ' >> columnstoreSupportReport.txt"; - system(cmd.c_str()); - cmd = columnstoreMysql + " -e 'desc calpontsys.systable;' >> columnstoreSupportReport.txt"; - system(cmd.c_str()); - - system("echo ' ' >> columnstoreSupportReport.txt"); - system("echo '******************** DBMS Mysql Columnstore System Catalog Data ********************' >> columnstoreSupportReport.txt"); - system("echo ' ' >> columnstoreSupportReport.txt"); - cmd = "echo '################# " + columnstoreMysql + " calpontsys < " + installDir + "/mysql/dumpcat_mysql.sql ################# ' >> columnstoreSupportReport.txt"; - system(cmd.c_str()); - cmd = "echo ' ' >> columnstoreSupportReport.txt"; - system(cmd.c_str()); - cmd = columnstoreMysql + " calpontsys < " + installDir + "/mysql/dumpcat_mysql.sql >> columnstoreSupportReport.txt"; - system(cmd.c_str()); - - system("echo ' ' >> columnstoreSupportReport.txt"); - system("echo '******************** DBMS Mysql Columnstore System Table Data ********************' >> columnstoreSupportReport.txt"); - system("echo ' ' >> columnstoreSupportReport.txt"); - cmd = "echo '################# " + columnstoreMysql + " -e select * from calpontsys.systable ################# ' >> columnstoreSupportReport.txt"; - system(cmd.c_str()); - cmd = "echo ' ' >> columnstoreSupportReport.txt"; - system(cmd.c_str()); - cmd = columnstoreMysql + " -e 'select * from calpontsys.systable;' >> columnstoreSupportReport.txt"; - system(cmd.c_str()); - - system("echo ' ' >> columnstoreSupportReport.txt"); - system("echo '******************** DBMS Mysql Columnstore Usernames ********************' >> columnstoreSupportReport.txt"); - system("echo ' ' >> columnstoreSupportReport.txt"); - cmd = "echo '################# " + columnstoreMysql + " -e show databases ################# ' >> columnstoreSupportReport.txt"; - system(cmd.c_str()); - cmd = "echo ' ' >> columnstoreSupportReport.txt"; - system(cmd.c_str()); - cmd = columnstoreMysql + " -e 'show databases;' >> columnstoreSupportReport.txt"; - system(cmd.c_str()); - - system("echo ' ' >> columnstoreSupportReport.txt"); - system("echo '******************** DBMS Mysql Columnstore variables ********************' >> columnstoreSupportReport.txt"); - system("echo ' ' >> columnstoreSupportReport.txt"); - cmd = "echo '################# " + columnstoreMysql + " show variables ################# ' >> columnstoreSupportReport.txt"; - system(cmd.c_str()); - cmd = "echo ' ' >> columnstoreSupportReport.txt"; - system(cmd.c_str()); - cmd = columnstoreMysql + " -e 'show variables;' >> columnstoreSupportReport.txt"; - system(cmd.c_str()); - } - } - } - - system("echo ' ' >> columnstoreSupportReport.txt"); - system("echo '******************** Database Size Report ********************' >> columnstoreSupportReport.txt"); - system("echo ' ' >> columnstoreSupportReport.txt"); - string cmd = "echo '################# /bin/databaseSizeReport ################# ' >> columnstoreSupportReport.txt"; - system(cmd.c_str()); - cmd = "echo ' ' >> columnstoreSupportReport.txt"; - system(cmd.c_str()); - cmd = installDir + "/bin/databaseSizeReport >> columnstoreSupportReport.txt"; - system(cmd.c_str()); - - system("echo ' ' >> columnstoreSupportReport.txt"); - system("echo '******************** DBMS Mysql Columnstore config file ********************' >> columnstoreSupportReport.txt"); - system("echo ' ' >> columnstoreSupportReport.txt"); - cmd = "echo '################# cat /mysql/my.cnf ################# ' >> columnstoreSupportReport.txt"; - system(cmd.c_str()); - cmd = "echo ' ' >> columnstoreSupportReport.txt"; - system(cmd.c_str()); - cmd = "cat " + installDir + "/mysql/my.cnf 2>/dev/null >> columnstoreSupportReport.txt"; - system(cmd.c_str()); - - system("echo ' ' >> columnstoreSupportReport.txt"); - system("echo '******************** Active Queries ********************' >> columnstoreSupportReport.txt"); - system("echo ' ' >> columnstoreSupportReport.txt"); - cmd = "echo '################# mcsadmin getActiveSqlStatement ################# ' >> columnstoreSupportReport.txt"; - system(cmd.c_str()); - cmd = "echo ' ' >> columnstoreSupportReport.txt"; - system(cmd.c_str()); - cmd = installDir + "/bin/mcsadmin getActiveSqlStatement >> columnstoreSupportReport.txt"; - system(cmd.c_str()); - - cmd = "cat columnstoreSupportReport.txt > " + localModule + "_dbmsReport.txt"; - system(cmd.c_str()); - } - - // - // HADOOP - // - - if (HADOOP) - { - if (LOCAL || childmodulelist.empty()) - { - cout << "Get hadoop report data" << endl; - string cmd = installDir + "/bin/hadoopReport.sh " + localModule + " " + installDir + "\n"; - cmd += " mv -f /tmp/hadoopReport.txt ."; - FILE* pipe = popen(cmd.c_str(), "r"); - - if (!pipe) - { - cout << "Failed to get a pipe for hadoop health check commands" << endl; - exit(-1); - } - - pclose(pipe); - } - else - { - // only get hadoop report from parentOAMModule, because it's consistant view. - parentmodulelist.push_back(parentOAMModule); - threadInfo_t* st = new threadInfo_t; - ChildModuleList::iterator iter = parentmodulelist.begin(); - *st = boost::make_tuple(iter, "hadoop"); - - pthread_t hdthread; - int status = pthread_create (&hdthread, NULL, (void* (*)(void*)) &childReportThread, st); - - if ( status != 0 ) - { - cout << "ERROR: childreportthread: pthread_create failed, return status = " + oam.itoa(status) << endl; - } - } - } - - //wait for all threads to complete - sleep(5); - int wait = 0; - - while (true) - { -//cout << "check " << runningThreads << endl; - if (runningThreads < 1) - break; - - sleep(2); - wait++; - - // give it 60 minutes to complete - if ( wait >= 3600 * 5) - { - cout << "Timed out (60 minutes) waiting for Requests to complete" << endl; - } - } - - system("rm -f columnstoreSupportReport.txt"); - - system("unix2dos *Report.txt > /dev/null 2>&1"); - system("rm -rf columnstoreSupportReport;mkdir columnstoreSupportReport;mv *Report.txt columnstoreSupportReport/. > /dev/null 2>&1;mv *Report.tar.gz columnstoreSupportReport/. > /dev/null 2>&1"); - string cmd = "tar -zcf columnstoreSupportReport." + systemName + ".tar.gz columnstoreSupportReport/*"; - system(cmd.c_str()); - - - cout << endl << "Columnstore Support Script Successfully completed, files located in columnstoreSupportReport." + systemName + ".tar.gz" << endl; -} diff --git a/oamapps/columnstoreSupport/configReport.sh b/oamapps/columnstoreSupport/configReport.sh index b7e0a044a..2a73479e7 100755 --- a/oamapps/columnstoreSupport/configReport.sh +++ b/oamapps/columnstoreSupport/configReport.sh @@ -14,14 +14,7 @@ else INSTALLDIR="/usr/local/mariadb/columnstore" fi -USER=`whoami 2>/dev/null` -if [ $USER = "root" ]; then - SUDO=" " -else - SUDO="sudo" -fi - -$SUDO rm -f /tmp/${MODULE}_configReport.txt +rm -f /tmp/${MODULE}_configReport.txt { echo " " @@ -34,10 +27,10 @@ if [ -n "$chkconfig" ]; then echo " " echo "################# chkconfig --list | grep columnstore #################" echo " " - $SUDO chkconfig --list | grep columnstore 2>/dev/null + chkconfig --list | grep columnstore 2>/dev/null echo "################# chkconfig --list | grep mysql-Columnstore #################" echo " " - $SUDO chkconfig --list | grep mysql-Columnstore 2>/dev/null + chkconfig --list | grep mysql-Columnstore 2>/dev/null fi systemctl=`which systemctl 2>/dev/null` @@ -46,10 +39,10 @@ if [ -n "$systemctl" ]; then echo " " echo "################# systemctl list-unit-files --type=service | grep columnstore #################" echo " " - $SUDO systemctl list-unit-files --type=service | grep columnstore 2>/dev/null + systemctl list-unit-files --type=service | grep columnstore 2>/dev/null echo "################# systemctl list-unit-files --type=service | grep mysql-Columnstore #################" echo " " - $SUDO systemctl list-unit-files --type=service | grep mysql-Columnstore 2>/dev/null + systemctl list-unit-files --type=service | grep mysql-Columnstore 2>/dev/null fi updaterc=`which update-rc.d 2>/dev/null` @@ -58,10 +51,10 @@ if [ -n "$updaterc" ]; then echo " " echo "################# service --status-all | grep columnstore #################" echo " " - $SUDO service --status-all | grep columnstore 2>/dev/null + service --status-all | grep columnstore 2>/dev/null echo "################# service --status-all | grep mysql-Columnstore #################" echo " " - $SUDO service --status-all | grep mysql-Columnstore 2>/dev/null + service --status-all | grep mysql-Columnstore 2>/dev/null fi @@ -70,21 +63,21 @@ echo "-- fstab Configuration --" echo " " echo "################# cat /etc/fstab #################" echo " " -$SUDO cat /etc/fstab 2>/dev/null +cat /etc/fstab 2>/dev/null echo " " echo "-- Server Processes --" echo " " echo "################# ps axu #################" echo " " -$SUDO ps axu +ps axu echo " " echo "-- Server Processes with resource usage --" echo " " echo "################# top -b -n 1 #################" echo " " -$SUDO top -b -n 1 +top -b -n 1 } > /tmp/${MODULE}_configReport.txt diff --git a/oamapps/columnstoreSupport/hadoopReport.sh b/oamapps/columnstoreSupport/hadoopReport.sh index 22612fe18..7b45b6d9d 100755 --- a/oamapps/columnstoreSupport/hadoopReport.sh +++ b/oamapps/columnstoreSupport/hadoopReport.sh @@ -13,14 +13,7 @@ else INSTALLDIR="/usr/local/mariadb/columnstore" fi -USER=`whoami 2>/dev/null` -if [ $USER = "hdfs" ]; then - SUDO=" " -else - SUDO="sudo -u hdfs" -fi - -sudo rm -f /tmp/hdfsReport.txt +rm -f /tmp/hdfsReport.txt { echo @@ -30,14 +23,14 @@ echo "-- Hadoop version --" echo echo "################# hadoop version #################" echo -$SUDO hadoop version +hadoop version echo echo "-- Data File Plugin --" echo echo "######### $INSTALLDIR/bin/getConfig SystemConfig DataFilePlugin ##########" echo -sudo $INSTALLDIR/bin/getConfig SystemConfig DataFilePlugin +$INSTALLDIR/bin/getConfig SystemConfig DataFilePlugin echo echo @@ -57,14 +50,14 @@ echo "-- Hadoop Health Check --" echo echo "################# hdfs dfsadmin -report #################" echo -$SUDO hadoop dfsadmin -report 2>/dev/null +hadoop dfsadmin -report 2>/dev/null echo echo "-- HDFS check --" echo echo "################# hdfs fsck $INSTALLDIR #################" echo -$SUDO hadoop fsck $INSTALLDIR 2>/dev/null +hadoop fsck $INSTALLDIR 2>/dev/null } > /tmp/hadoopReport.txt exit 0 diff --git a/oamapps/columnstoreSupport/hardwareReport.sh b/oamapps/columnstoreSupport/hardwareReport.sh index dba32e9d2..c1db4bf67 100755 --- a/oamapps/columnstoreSupport/hardwareReport.sh +++ b/oamapps/columnstoreSupport/hardwareReport.sh @@ -14,14 +14,7 @@ else INSTALLDIR="/usr/local/mariadb/columnstore" fi -USER=`whoami 2>/dev/null` -if [ $USER = "root" ]; then - SUDO=" " -else - SUDO="sudo" -fi - -$SUDO rm -f /tmp/${MODULE}_hardwareReport.txt +rm -f /tmp/${MODULE}_hardwareReport.txt { echo " " @@ -32,7 +25,7 @@ echo "-- Server OS Version --" echo " " echo "################# cat /proc/version #################" echo " " -$SUDO cat /proc/version 2>/dev/null +cat /proc/version 2>/dev/null echo " " echo "################# uname -a #################" echo " " @@ -60,35 +53,21 @@ echo "-- Server cpu-info --" echo " " echo "################# cat /proc/cpuinfo #################" echo " " -$SUDO cat /proc/cpuinfo 2>/dev/null +cat /proc/cpuinfo 2>/dev/null echo " " echo "-- Server memory-info --" echo " " echo "################# cat /proc/meminfo #################" echo " " -$SUDO cat /proc/meminfo 2>/dev/null +$cat /proc/meminfo 2>/dev/null echo " " echo "-- Server mounts --" echo " " echo "################# cat /proc/mounts #################" echo " " -$SUDO cat /proc/mounts 2>/dev/null - -echo " " -echo "-- Server Disk Scheduler for Columnstore Mounts --" -echo " " -for scsi_dev in `mount | awk '/mnt\/tmp/ {print $1}' | awk -F/ '{print $3}' | sed 's/[0-9]*$//'`; do - echo '/dev/'$scsi_dev ' scheduler setup is' - cat /sys/block/$scsi_dev/queue/scheduler 2>/dev/null -done -for scsi_dev in `mount | awk '/MariaDB\/Columnstore\/data/ {print $1}' | awk -F/ '{print $3}' | sed 's/[0-9]*$//'`; do - if [ $scsi_dev != "local" ] ; then - echo '/dev/'$scsi_dev ' scheduler setup is' - cat /sys/block/$scsi_dev/queue/scheduler 2>/dev/null - fi -done +cat /proc/mounts 2>/dev/null echo " " echo "-- Server Ethernet Configuration --" diff --git a/oamapps/columnstoreSupport/logReport.sh b/oamapps/columnstoreSupport/logReport.sh index bd1b766af..72bbb8da1 100755 --- a/oamapps/columnstoreSupport/logReport.sh +++ b/oamapps/columnstoreSupport/logReport.sh @@ -14,14 +14,7 @@ else INSTALLDIR="/usr/local/mariadb/columnstore" fi -USER=`whoami 2>/dev/null` -if [ $USER = "root" ]; then - SUDO=" " -else - SUDO="sudo" -fi - -$SUDO rm -f /tmp/${MODULE}_logReport.tar.gz +rm -f /tmp/${MODULE}_logReport.tar.gz tar -zcf /tmp/${MODULE}_logReport.tar.gz /var/log/mariadb/columnstore > /dev/null 2>&1 diff --git a/oamapps/columnstoreSupport/resourceReport.sh b/oamapps/columnstoreSupport/resourceReport.sh index 03f19c2bd..f1c1be617 100755 --- a/oamapps/columnstoreSupport/resourceReport.sh +++ b/oamapps/columnstoreSupport/resourceReport.sh @@ -14,14 +14,7 @@ else INSTALLDIR="/usr/local/mariadb/columnstore" fi -USER=`whoami 2>/dev/null` -if [ $USER = "root" ]; then - SUDO=" " -else - SUDO="sudo" -fi - -$SUDO rm -f /tmp/${MODULE}_resourceReport.txt +rm -f /tmp/${MODULE}_resourceReport.txt { echo " " @@ -33,7 +26,7 @@ echo "-- Shared Memory --" echo " " echo "################# ipcs -l #################" echo " " -$SUDO ipcs -l +ipcs -l echo "################# $INSTALLDIR/bin/clearShm -n #################" echo " " @@ -44,7 +37,7 @@ echo "-- Disk Usage --" echo " " echo "################# df -k #################" echo " " -$SUDO df -k +df -k echo " " echo "-- Disk BRM Data files --" diff --git a/oamapps/columnstoreSupport/softwareReport.sh b/oamapps/columnstoreSupport/softwareReport.sh index b7a6e90b0..d94f5c7b3 100755 --- a/oamapps/columnstoreSupport/softwareReport.sh +++ b/oamapps/columnstoreSupport/softwareReport.sh @@ -14,14 +14,7 @@ else INSTALLDIR="/usr/local/mariadb/columnstore" fi -USER=`whoami 2>/dev/null` -if [ $USER = "root" ]; then - SUDO=" " -else - SUDO="sudo" -fi - -$SUDO rm -f /tmp/${MODULE}_softwareReport.txt +rm -f /tmp/${MODULE}_softwareReport.txt { echo " " diff --git a/oamapps/postConfigure/installer.cpp b/oamapps/postConfigure/installer.cpp index c0aee150a..661725d8e 100644 --- a/oamapps/postConfigure/installer.cpp +++ b/oamapps/postConfigure/installer.cpp @@ -173,7 +173,7 @@ int main(int argc, char* argv[]) // setup to start on reboot, for non-root amazon installs if ( !rootUser ) { - system("sudo sed -i -e 's/#sudo runuser/sudo runuser/g' /etc/rc.d/rc.local >/dev/null 2>&1"); + system("sed -i -e 's/#runuser/runuser/g' /etc/rc.d/rc.local >/dev/null 2>&1"); } //copy Columnstore.xml.rpmsave if upgrade option is selected diff --git a/utils/clusterTester/columnstoreClusterTester.sh b/utils/clusterTester/columnstoreClusterTester.sh index 8b69f6926..2534fdd19 100755 --- a/utils/clusterTester/columnstoreClusterTester.sh +++ b/utils/clusterTester/columnstoreClusterTester.sh @@ -840,7 +840,7 @@ checkPackages() echo "" - declare -a CENTOS_PKG=("expect" "perl" "perl-DBI" "openssl" "zlib" "file" "sudo" "libaio" "rsync" "snappy" "net-tools" "numactl-libs") + declare -a CENTOS_PKG=("expect" "perl" "perl-DBI" "openssl" "zlib" "file" "libaio" "rsync" "snappy" "net-tools" "numactl-libs") declare -a CENTOS_PKG_NOT=("mariadb-libs") if [ "$OS" == "centos6" ] || [ "$OS" == "centos7" ]; then @@ -960,7 +960,7 @@ checkPackages() fi - declare -a SUSE_PKG=("boost-devel" "expect" "perl" "perl-DBI" "openssl" "file" "sudo" "libaio1" "rsync" "libsnappy1" "net-tools" "libnuma1") + declare -a SUSE_PKG=("boost-devel" "expect" "perl" "perl-DBI" "openssl" "file" "libaio1" "rsync" "libsnappy1" "net-tools" "libnuma1") declare -a SUSE_PKG_NOT=("mariadb" , "libmariadb18") if [ "$OS" == "suse12" ]; then @@ -1051,7 +1051,7 @@ checkPackages() fi fi - declare -a UBUNTU_PKG=("libboost-all-dev" "expect" "libdbi-perl" "perl" "openssl" "file" "sudo" "libreadline-dev" "rsync" "libsnappy1V5" "net-tools" "libnuma1" ) + declare -a UBUNTU_PKG=("libboost-all-dev" "expect" "libdbi-perl" "perl" "openssl" "file" "libreadline-dev" "rsync" "libsnappy1V5" "net-tools" "libnuma1" ) declare -a UBUNTU_PKG_NOT=("mariadb-server" "libmariadb18") if [ "$OS" == "ubuntu16" ] || [ "$OS" == "ubuntu18" ]; then @@ -1169,7 +1169,7 @@ checkPackages() fi - declare -a DEBIAN_PKG=("libboost-all-dev" "expect" "libdbi-perl" "perl" "openssl" "file" "sudo" "libreadline-dev" "rsync" "libsnappy1" "net-tools" "libnuma1") + declare -a DEBIAN_PKG=("libboost-all-dev" "expect" "libdbi-perl" "perl" "openssl" "file" "libreadline-dev" "rsync" "libsnappy1" "net-tools" "libnuma1") declare -a DEBIAN_PKG_NOT=("libmariadb18" "mariadb-server") if [ "$OS" == "debian8" ]; then @@ -1287,7 +1287,7 @@ checkPackages() fi - declare -a DEBIAN9_PKG=("libboost-all-dev" "expect" "libdbi-perl" "perl" "openssl" "file" "sudo" "libreadline5" "rsync" "libsnappy1V5" "net-tools" "libaio1" "libnuma1") + declare -a DEBIAN9_PKG=("libboost-all-dev" "expect" "libdbi-perl" "perl" "openssl" "file" "libreadline5" "rsync" "libsnappy1V5" "net-tools" "libaio1" "libnuma1") declare -a DEBIAN9_PKG_NOT=("libmariadb18" "mariadb-server") if [ "$OS" == "debian9" ]; then diff --git a/utils/udfsdk/README.txt b/utils/udfsdk/README.txt index 83497ca46..3210979b4 100644 --- a/utils/udfsdk/README.txt +++ b/utils/udfsdk/README.txt @@ -11,7 +11,7 @@ files to create your own function or just try that function as is. $ make - Copy the libudf_mysql.so.1.0.0 and libudfsdk.so.1.0.0 file to /usr/local/mariadb/columnstore/lib on every columnstore node. - $ sudo cp libudf_mysql.so.1.0.0 libudfsdk.so.1.0.0 /usr/local/mariadb/columnstore/lib/ + $ cp libudf_mysql.so.1.0.0 libudfsdk.so.1.0.0 /usr/local/mariadb/columnstore/lib/ - Restart ColumnStore $ mcsadmin restartsystem y - Using the mcsmysql client add the user defined function, e.g, @@ -20,4 +20,4 @@ files to create your own function or just try that function as is. > create function mcs_isnull returns string soname 'libudf_mysql.so'; You should now be able to use the mcs_add(arg1, arg2) and mcs_isnull(arg) functions in the select and/or where clauses -of SQL statements. \ No newline at end of file +of SQL statements.