diff --git a/gpMgmt/bin/gpdebug b/gpMgmt/bin/gpdebug index ad857a74d4faf2ef54396166d469c1fee50fc405..7b565242cf3c114f469167e50f3643b790a0fc4f 100755 --- a/gpMgmt/bin/gpdebug +++ b/gpMgmt/bin/gpdebug @@ -72,10 +72,6 @@ class GpDebugMain(YamlMain): help: Hosts file type: string dest: hostsfile - -o: - help: Output file with details and gpkill commands - type: string - dest: outputfile --orphans: help: Search cluster for orphan processes action: store_const @@ -308,28 +304,6 @@ class GpDebugMain(YamlMain): tabLog.outputTable() self.logger.info("--------------------------------------------") - - def generate_output_file(self): - "" - if self.options.outputfile is None: - return - - self.logger.info('writing gpkill script to %s' % self.options.outputfile) - - with open(self.options.outputfile, 'w') as f: - for host, lines in self.results.items(): - prev = None - for line in lines: - host2, era, sessid, pid, detail = line.split('|') - assert host == host2 - if era != prev: - f.write('# era %s\n' % era) - prev = era - f.write('# sessid %s\n' % sessid) - f.write('# %s\n' % detail) - f.write('gpssh -h %s gpkill %s\n\n' % (host, pid)) - - # # Scenario: Check Host For Orphans (segment hosts, via search for orphans) # diff --git a/gpMgmt/bin/gpkill b/gpMgmt/bin/gpkill deleted file mode 100755 index 0f821da0acb6062535d3443ddef07faa1d89a8ed..0000000000000000000000000000000000000000 --- a/gpMgmt/bin/gpkill +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env python - -from gppylib.mainUtils import simple_main -from gppylib.programs.kill import KillProgram - -if __name__ == '__main__': - simple_main(KillProgram.create_parser, KillProgram) diff --git a/gpMgmt/bin/gppylib/commands/gp.py b/gpMgmt/bin/gppylib/commands/gp.py index 18f5b897fffc8939a879ef10aca08e6e4f21d656..ce31e6f39a4605a379da54c44a805e4534c3048a 100644 --- a/gpMgmt/bin/gppylib/commands/gp.py +++ b/gpMgmt/bin/gppylib/commands/gp.py @@ -275,7 +275,7 @@ class PgCtlStartArgs(CmdArgs): """ CmdArgs.__init__(self, [ - "env", # variables examined by gpkill/gpdebug/etc + "env", # variables examined by gpdebug/etc "GPSESSID=0000000000", # <- overwritten with gp_session_id to help identify orphans "GPERA=%s" % str(era), # <- master era used to help identify orphans "$GPHOME/bin/pg_ctl", diff --git a/gpMgmt/bin/gppylib/programs/kill.py b/gpMgmt/bin/gppylib/programs/kill.py deleted file mode 100644 index 181eeda8ceda5cb4cb38f3addd428e056a1206f1..0000000000000000000000000000000000000000 --- a/gpMgmt/bin/gppylib/programs/kill.py +++ /dev/null @@ -1,118 +0,0 @@ -# Line too long - pylint: disable=C0301 -# Copyright (c) Greenplum Inc 2011. All Rights Reserved. - -from gppylib import gplog -from gppylib.commands import gp -from optparse import OptionGroup -from gppylib.gpparseopts import OptParser, OptChecker -from gppylib.mainUtils import addStandardLoggingAndHelpOptions, ProgramArgumentValidationException -from gppylib.commands.unix import kill_sequence, check_pid -from gppylib.operations.package import dereference_symlink -from psutil import Process, NoSuchProcess - -logger = gplog.get_default_logger() - -class KillError(Exception): pass - -class KillProgram: - def __init__(self, options, args): - self.check = options.check - self.pid_list = args - - @staticmethod - def create_parser(): - """Create the command line parser object for gpkill""" - - help = [] - parser = OptParser(option_class=OptChecker, - description='Check or Terminate a Greenplum Database process.', - version='%prog version $Revision: #1 $') - parser.setHelp(help) - - addStandardLoggingAndHelpOptions(parser, True) - - parser.remove_option('-l') - parser.remove_option('-a') - - addTo = OptionGroup(parser, 'Check Options') - parser.add_option_group(addTo) - addTo.add_option('--check', metavar='pid', help='Only returns status 0 if pid may be killed without gpkill, status 1 otherwise.', action='store_true') - - return parser - - @staticmethod - def create_program(options, args): - return KillProgram(options, args) - - def cleanup(self): pass - - def run(self): - - self.validate_arguments() - if self.check: - for pid in self.pid_list: - self.validate_attempt(pid) - else: - for pid in self.pid_list: - self.terminate_process(pid) - - return 0 - - def validate_arguments(self): - - if len(self.pid_list) < 1: - raise KillError('No pid specified') - - int_pid_list = [] - try: - for x in self.pid_list: - int_pid_list.append(int(x)) - except ValueError, e: - raise KillError('Invalid pid specified (%s)' % x) - - self.pid_list = int_pid_list - - def validate_attempt(self, pid): - """ - Checks if we can kill the process - """ - - command = self.examine_process(pid) - - critical_process_prefix = ['postgres', gp.get_gphome(), dereference_symlink(gp.get_gphome())] - - for prefix in critical_process_prefix: - if command.startswith(prefix): - raise KillError('process %s may not be killed' % pid) - - if not command.startswith('python ' + gp.get_gphome()): - raise KillError('process %s ignored by gpkill as it is not a greenplum process' % pid) - - def examine_process(self, pid): - - logger.info('Examining process: pid(%s)' % pid) - - try: - proc = Process(pid=pid) - except NoSuchProcess, e: - raise KillError('Process with pid(%s) does not exist' % pid) - - command = ' '.join(proc.cmdline()) - logger.info('process %s is %s' % (pid, command.strip())) - - return command.strip() - - def terminate_process(self, pid): - - self.validate_attempt(pid) - - logger.warning('Confirm [N/y]:') - - confirmation = raw_input().strip().lower() - if confirmation not in ['y', 'ye', 'yes']: - raise KillError('operation aborted') - - kill_sequence(pid) - - if check_pid(pid): - raise KillError('Failed to kill process %s' % pid) diff --git a/gpMgmt/doc/gpkill_help b/gpMgmt/doc/gpkill_help deleted file mode 100644 index 4e6db2d1351e9d97300bef11e144e436e376dbf0..0000000000000000000000000000000000000000 --- a/gpMgmt/doc/gpkill_help +++ /dev/null @@ -1,77 +0,0 @@ -COMMAND NAME: gpkill - -Checks or terminates a Greenplum Database process. -Users other than the superuser can only use gpkill -to terminate their own processes. - -***************************************************** -SYNOPSIS -***************************************************** - -gpkill [options] pid -gpkill --version -gpkill -? | -h | --help - -***************************************************** -DESCRIPTION -***************************************************** - - -This utility checks or terminates a Greenplum process. -If the process is a critical Greenplum Database process -or a system process that is not part of Greenplum, gpkill -does not terminate it. - -After gpkill verifies that the specified process can be -terminated safely, it prompts for confirmation. Prior to -terminating a process, gpkill attempts to capture -troubleshooting information, if the user has appropriate -operating system priviliges. - -* The troubleshooting information is captured, even if - the user does not confirm killing the process. - -* Failure to capture troubleshooting information does not - stop gpkill from proceeding. - - -***************************************************** -OPTIONS -***************************************************** - -pid -The process ID to check or terminate. - ---check -Checks the specified process ID to verify that it is a -Greenplum process and can safely be killed, but does not -erminate it. - --v -Displays verbose debugging information. - --q -Enables quiet mode. Informational messages are suppressed. - -NOTE: Choosing both the -v and -q options sends the verbose -debugging information to the system log, but does not display -informational messages on stdout. - --? | -h | --help (help) -Displays the online help. - - -***************************************************** -EXAMPLES -***************************************************** - - -Kill process 27893 - - gpkill 27893 - -Check process 27893 to see if it can be killed. Send -debugging information to the system log, but do not -display informational messages. - - gpkill -q -v --check 27893 \ No newline at end of file