提交 50f98856 编写于 作者: K Kalen Krempely 提交者: Kalen Krempely

Remove gpcheck

Due to the number of platforms we now support and variety of customer
specific environments, it is not practical to update gpcheck to cover
all these cases.
Co-authored-by: NJamie McAtamney <jmcatamney@pivotal.io>
上级 9f4d2a7e
......@@ -12,7 +12,7 @@
## file (example: templates/gpdb-tpl.yml) and regenerate the pipeline
## using appropriate tool (example: gen_pipeline.py -t prod).
## ----------------------------------------------------------------------
## Generated by gen_pipeline.py at: 2019-06-05 12:32:22.570295
## Generated by gen_pipeline.py at: 2019-06-05 10:53:33.720741
## Template file: gpdb-tpl.yml
## OS Types: ['centos6', 'centos7', 'ubuntu18.04', 'win']
## Test Sections: ['ICW', 'Replication', 'ResourceGroups', 'Interconnect', 'CLI', 'UD', 'Extensions', 'Gpperfmon']
......@@ -60,7 +60,6 @@ groups:
## --------------------------------------------------------------------
- gate_cli_start
- gpmovemirrors
- gpcheck
- gppkg
- analyzedb
- gpinitsystem
......@@ -153,7 +152,6 @@ groups:
jobs:
- gate_cli_start
- gpmovemirrors
- gpcheck
- gppkg
- analyzedb
- gpinitsystem
......@@ -1281,27 +1279,6 @@ jobs:
params:
BEHAVE_FLAGS: --tags=gpmovemirrors --tags=~concourse_cluster,demo_cluster
- name: gpcheck
plan:
- aggregate:
- get: gpdb_src
params:
submodules:
- gpMgmt/bin/pythonSrc/ext
passed: [gate_cli_start]
- get: gpdb6-centos6-test
- aggregate:
- do:
- get: bin_gpdb
resource: bin_gpdb_centos6
passed: [gate_cli_start]
trigger: true
- task: gpcheck_demo_cluster_tests
file: gpdb_src/concourse/tasks/behave_gpdb.yml
image: gpdb6-centos6-test
params:
BEHAVE_FLAGS: --tags=gpcheck --tags=~concourse_cluster,demo_cluster
- name: gppkg
plan:
- aggregate:
......@@ -1868,7 +1845,6 @@ jobs:
- gpperfmon_centos6
- gpperfmon_centos7
- gpmovemirrors
- gpcheck
- gppkg
- analyzedb
- gpinitsystem
......@@ -1900,7 +1876,6 @@ jobs:
- icw_extensions_gpcloud_centos6
- resource_group_centos6
- gpmovemirrors
- gpcheck
- gppkg
- analyzedb
- gpinitsystem
......
......@@ -2,8 +2,6 @@
{'name': 'gpmovemirrors',
'use_concourse_cluster': true,
'additional_ccp_vars': 'number_of_nodes: 4'},
{'name': 'gpcheck',
'use_concourse_cluster': false},
{'name': 'gppkg',
'use_concourse_cluster': true},
{'name': 'analyzedb',
......
......@@ -77,40 +77,6 @@ function gen_env(){
chmod a+x /opt/run_test.sh
}
function gpcheck_setup() {
# gpcheck looks for specific system settings as a requirement.
# normally, containers do not have root access when running as gpadmin.
# So, we need to setup system requirements prior to running the test. Note
# that, for this test, we simply change the conf file gpcheck only checks
# the conf file, not the runtime system settings
echo "
xfs_mount_options = rw,noatime,inode64,allocsize=16m
kernel.shmmax = 500000000
kernel.shmmni = 4096
kernel.shmall = 4000000000
kernel.sem = 500 1024000 200 4096
kernel.sysrq = 1
kernel.core_uses_pid = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.msgmni = 2048
net.ipv4.tcp_syncookies = 1
net.ipv4.ip_forward = 0
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_max_syn_backlog = 4096
net.ipv4.conf.all.arp_filter = 1
net.ipv4.ip_local_port_range = 1025 65535
net.core.netdev_max_backlog = 10000
vm.overcommit_memory = 2" >> /etc/sysctl.conf
echo "
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072" >> /etc/security/limits.conf
}
function _main() {
if [ -z "${BEHAVE_TAGS}" ] && [ -z "${BEHAVE_FLAGS}" ]; then
......@@ -128,10 +94,6 @@ function _main() {
time install_python_hacks
time gen_env
if echo "$BEHAVE_TAGS" "$BEHAVE_FLAGS" | grep -q "gpcheck\b"; then
time gpcheck_setup
fi
time run_test
}
......
......@@ -100,8 +100,6 @@ install: generate_greenplum_path_file
cp $(top_builddir)/src/test/regress/*.pm $(DESTDIR)$(prefix)/bin
if [ ! -d ${DESTDIR}${prefix}/docs ] ; then mkdir ${DESTDIR}${prefix}/docs ; fi
if [ -d doc ]; then cp -rp doc $(DESTDIR)$(prefix)/docs/cli_help; fi
mkdir -p $(DESTDIR)$(prefix)/etc
cp -p doc/gpconfigs/gpcheck.cnf $(DESTDIR)$(prefix)/etc/
# THIS NEEDS TO MOVE
# if [ -d demo/gpfdist_transform ]; then \
......
此差异已折叠。
#!/usr/bin/env python
class HostType:
GPCHECK_HOSTTYPE_UNDEFINED = 0
GPCHECK_HOSTTYPE_APPLIANCE = 1
GPCHECK_HOSTTYPE_GENERIC_LINUX = 2
def hosttype_str(type):
if type == HostType.GPCHECK_HOSTTYPE_APPLIANCE:
return "GPDB Appliance"
elif type == HostType.GPCHECK_HOSTTYPE_GENERIC_LINUX:
return "Generic Linux Cluster"
else:
return "Undetected Platform"
class sysctl:
def __init__(self):
self.variables = dict() # dictionary of values
self.errormsg = None
class omreport:
def __init__(self):
self.biossetup = dict() # key value pairs
self.biossetup_errormsg = None
self.bootorder = list() # list of Devices in order of boot
self.bootorder_errormsg = None
self.remoteaccess = dict() # key value pairs
self.remoteaccess_errormsg = None
self.vdisks = list() # list of dicts, 1 for each virtual disk
self.vdisks_errormsg = None
self.controller = dict() # key value pairs
self.controller_errormsg = None
self.omversion = None
self.omversion_errormsg = None
self.bios = dict() # key value pairs
self.bios_errormsg = None
self.alerts = list() # list of alerts... each alert is a dictionary of key value pairs
self.alerts_errormsg = None
class chkconfig:
def __init__(self):
self.services = dict() # hash of services, each entry is hash of run levels and boolean value
self.xinetd = dict() # hash of services, value is boolean
self.errormsg = None
class grubconf:
def __init__(self):
self.serial_declaration = False
self.terminal_declaration = False
self.ttyS1_declaration = False
self.errormsg = None
def __str__(self):
return "serial_declaration(%s) terminal_declaration(%s) ttyS1_declaration(%s)" % (self.serial_declaration, self.terminal_declaration, self.ttyS1_declaration)
class inittab:
def __init__(self):
self.s1 = False
self.defaultRunLevel = None
self.errormsg = None
def __str__(self):
return "s1_declaration(%s) default_run_level(%s)" % (self.s1, self.defaultRunLevel)
class uname:
def __init__(self):
self.output = None
self.errormsg = None
def __str__(self):
return self.output
class connectemc:
def __init__(self):
self.output = None
self.errormsg = None
def __str__(self):
return self.output
class securetty:
def __init__(self):
self.errormsg = None
self.data = set()
class bcu:
def __init__(self):
self.firmware = None
self.biosversion = None
self.errormsg = None
def __str__(self):
return "firmware_version=%s|biosversion=%s" % (self.firmware, self.biosversion)
class ioschedulers:
def __init__(self):
self.devices = dict() # key is device name value is scheduler name
self.errormsg = ''
class blockdev:
def __init__(self):
self.ra = dict() # key is device name value is getra value
self.errormsg = ''
class rclocal:
def __init__(self):
self.isexecutable = False # check that /etc/rc.d/rc.local is executable permissions
def __str__(self):
return "executable(%s)" % self.isexecutable
class limitsconf_entry:
def __init__(self, domain, type, item, value):
self.domain = domain
self.type = type
self.item = item
self.value = value
def __str__(self):
return "%s %s %s %s" % (self.domain, self.type, self.item, self.value)
class limitsconf:
def __init__(self):
self.lines = list()
self.errormsg = None
def __str__(self):
output = ""
for line in self.lines:
output = "%s\n%s" % (output, line)
return output
class GpMount:
def __init__(self):
self.partition = None
self.dir= None
self.type = None
self.options = set() # mount options
def __str__(self):
optionstring = ''
first = True
for k in self.options:
if not first:
optionstring = "%s," % optionstring
thisoption = k
optionstring = "%s%s" % (optionstring, thisoption)
first = False
return "%s on %s type %s (%s)" % (self.partition, self.dir, self.type, optionstring)
class ntp:
def __init__(self):
self.running = False
self.hosts = set()
self.currentime = None
self.errormsg = None
def __str__(self):
return "(running %s) (time %f) (peers: %s)" % (self.running, self.currenttime, self.hosts)
class mounts:
def __init__(self):
self.entries = dict() # dictionary key=partition value=mount object
self.errormsg = None
def __str__(self):
output = ''
for k in self.entries.keys():
output = "%s\n%s" % (output, self.entries[k].__str__())
return output
class GenericLinuxOutputData:
def __init__(self):
self.mounts = None
self.uname = None
self.blockdev = None
self.ioschedulers = None
self.sysctl = None
self.limitsconf = None
self.ntp = None
def __str__(self):
grc = "============= SYSCTL=========================\n"
gre = "============= SYSCTL ERRORMSG================\n"
output = "%s%s\n%s%s" % (grc, self.sysctl.variables.__str__(), gre, self.sysctl.errormsg)
grc = "============= LIMITS=========================\n"
gre = "============= LIMITS ERRORMSG================\n"
output = "%s\n%s%s\n%s%s" % (output, grc, self.limitsconf.__str__(), gre, self.limitsconf.errormsg)
mnt = "============= MOUNT==========================\n"
mte = "============= MOUNT ERRORMSG=================\n"
output = "%s\n%s%s\n%s%s" % (output, mnt, self.mounts.__str__(), mte, self.mounts.errormsg)
grc = "============= UNAME==========================\n"
gre = "============= UNAME ERRORMSG=================\n"
output = "%s\n%s%s\n%s%s" % (output, grc, self.uname.__str__(), gre, self.uname.errormsg)
grc = "============= IO SCHEDULERS==================\n"
gre = "============= IO SCHEDULERS ERRORMSG========\n"
output = "%s\n%s%s\n%s%s" % (output, grc, self.ioschedulers.devices.__str__(), gre, self.ioschedulers.errormsg)
grc = "============= BLOCKDEV RA ====================\n"
gre = "============= BLOCKDEV RA ERRORMSG============\n"
output = "%s\n%s%s\n%s%s" % (output, grc, self.blockdev.ra.__str__(), gre, self.blockdev.errormsg)
grc = "============= NTPD ===========================\n"
gre = "============= NTPD ERRORMSG===================\n"
output = "%s\n%s%s\n%s%s" % (output, grc, self.ntp.__str__(), gre, self.ntp.errormsg)
return output
class ApplianceOutputData:
def __init__(self):
self.chkconfig = None
self.omreport = None
self.grubconf = None
self.mounts = None
self.inittab = None
self.uname = None
self.securetty = None
self.bcu = None
self.blockdev = None
self.rclocal = None
self.ioschedulers = None
self.sysctl = None
self.limitsconf = None
self.connectemc = None
self.ntp = None
def __str__(self):
ser = "=============SERVICES=======================\n"
xin = "=============XINETD =======================\n"
err = "=============CHKCONFIG ERRORMSG=============\n"
output = "%s%s\n%s%s\n%s%s" % (ser, self.chkconfig.services.__str__(), xin, self.chkconfig.xinetd.__str__(), err, self.chkconfig.errormsg)
omr = "=============OMREPORT VERSION ==============\n"
ome = "=============OMREPORT VERSION ERRORMSG======\n"
output = "%s\n%s%s\n%s%s" % (output, omr, self.omreport.omversion, ome, self.omreport.omversion_errormsg)
omr = "=============OMREPORT BIOS==================\n"
ome = "=============OMREPORT BIOS ERRORMSG=========\n"
output = "%s\n%s%s\n%s%s" % (output, omr, self.omreport.bios.__str__(), ome,self.omreport.bios_errormsg)
omr = "=============OMREPORT BIOSSETUP=============\n"
ome = "=============OMREPORT BIOSSETUP ERRORMSG====\n"
output = "%s\n%s%s\n%s%s" % (output, omr, self.omreport.biossetup.__str__(), ome,self.omreport.biossetup_errormsg)
omr = "=============OMREPORT CONTROLLER============\n"
ome = "=============OMREPORT CONTROLLER ERRORMSG===\n"
output = "%s\n%s%s\n%s%s" % (output, omr, self.omreport.controller.__str__(), ome,self.omreport.controller_errormsg)
boo = "=============OMREPORT BOOTORDER=============\n"
boe = "=============OMREPORT BOOTORDER ERRORMSG====\n"
output = "%s\n%s%s\n%s%s" % (output, boo, self.omreport.bootorder.__str__(), boe, self.omreport.bootorder_errormsg)
omr = "=============OMREPORT REMOTEACCESS==========\n"
ome = "=============OMREPORT REMOTEACCESS ERRORMSG=\n"
output = "%s\n%s%s\n%s%s" % (output, omr, self.omreport.remoteaccess.__str__(), ome,self.omreport.remoteaccess_errormsg)
omr = "=============OMREPORT ALERTS==========\n"
ome = "=============OMREPORT ALERTS ERRORMSG=\n"
output = "%s\n%s%s\n%s%s" % (output, omr, self.omreport.alerts.__str__(), ome,self.omreport.alerts_errormsg)
omr = "=============OMREPORT VIRTUAL DISKS=========\n"
ome = "=============OMREPORT VIRTUAL DISKS ERRORMSG\n"
output = "%s\n%s%s\n%s%s" % (output, omr, self.omreport.vdisks.__str__(), ome,self.omreport.vdisks_errormsg)
grc = "============= GRUB.CONF======================\n"
gre = "============= GRUB.CONF ERRORMSG=============\n"
output = "%s\n%s%s\n%s%s" % (output, grc, self.grubconf.__str__(), gre, self.grubconf.errormsg)
grc = "============= SYSCTL=========================\n"
gre = "============= SYSCTL ERRORMSG================\n"
output = "%s\n%s%s\n%s%s" % (output, grc, self.sysctl.variables.__str__(), gre, self.sysctl.errormsg)
grc = "============= LIMITS=========================\n"
gre = "============= LIMITS ERRORMSG================\n"
output = "%s\n%s%s\n%s%s" % (output, grc, self.limitsconf.__str__(), gre, self.limitsconf.errormsg)
mnt = "============= MOUNT==========================\n"
mte = "============= MOUNT ERRORMSG=================\n"
output = "%s\n%s%s\n%s%s" % (output, mnt, self.mounts.__str__(), mte, self.mounts.errormsg)
grc = "============= INITTAB========================\n"
gre = "============= INITTAB ERRORMSG===============\n"
output = "%s\n%s%s\n%s%s" % (output, grc, self.inittab.__str__(), gre, self.inittab.errormsg)
grc = "============= UNAME==========================\n"
gre = "============= UNAME ERRORMSG=================\n"
output = "%s\n%s%s\n%s%s" % (output, grc, self.uname.__str__(), gre, self.uname.errormsg)
grc = "============= CONNECTEMC=====================\n"
gre = "============= CONNECtEMC ERRORMSG============\n"
output = "%s\n%s%s\n%s%s" % (output, grc, self.connectemc.__str__(), gre, self.connectemc.errormsg)
grc = "============= SECURETTY======================\n"
gre = "============= SECURETTY ERRORMSG=============\n"
output = "%s\n%s%s\n%s%s" % (output, grc, self.securetty.data.__str__(), gre, self.securetty.errormsg)
grc = "============= IO SCHEDULERS==================\n"
gre = "============= IO SCHEDULERS ERRORMSG========\n"
output = "%s\n%s%s\n%s%s" % (output, grc, self.ioschedulers.devices.__str__(), gre, self.ioschedulers.errormsg)
grc = "============= BLOCKDEV RA ====================\n"
gre = "============= BLOCKDEV RA ERRORMSG============\n"
output = "%s\n%s%s\n%s%s" % (output, grc, self.blockdev.ra.__str__(), gre, self.blockdev.errormsg)
grc = "============= BCU CNA ========================\n"
gre = "============= BCU CNA ERRORMSG================\n"
output = "%s\n%s%s\n%s%s" % (output, grc, self.bcu.__str__(), gre, self.bcu.errormsg)
grc = "============= /etc/rc.d/rc.local =============\n"
output = "%s\n%s%s" % (output, grc, self.rclocal.__str__())
grc = "============= NTPD ===========================\n"
gre = "============= NTPD ERRORMSG===================\n"
output = "%s\n%s%s\n%s%s" % (output, grc, self.ntp.__str__(), gre, self.ntp.errormsg)
return output
import os
from gppylib.commands.base import Command, REMOTE
from gppylib.commands.unix import getLocalHostname
gphome = os.environ.get('GPHOME')
def get_command(local, command, hostname):
if local:
cmd = Command(hostname, cmdStr=command)
else:
cmd = Command(hostname, cmdStr=command, ctxt=REMOTE, remoteHost=hostname)
return cmd
def get_host_for_command(local, cmd):
if local:
cmd = Command(name='get the hostname', cmdStr='hostname')
cmd.run(validateAfter=True)
results = cmd.get_results()
return results.stdout.strip()
else:
return cmd.remoteHost
def get_copy_command(local, host, datafile, tmpdir):
if local:
cmd_str = 'mv -f %s %s/%s.data' % (datafile, tmpdir, host)
else:
cmd_str = 'scp %s:%s %s/%s.data' % (host, datafile, tmpdir, host)
return Command(host, cmd_str)
from gppylib.commands.base import Command, REMOTE
from gppylib.operations.gpcheck import get_host_for_command, get_command, get_copy_command
from test.unit.gp_unittest import GpTestCase, run_tests
class GpCheckTestCase(GpTestCase):
def test_get_host_for_command_uses_supplied_remote_host(self):
cmd = Command('name', 'hostname', ctxt=REMOTE, remoteHost='foo')
result = get_host_for_command(False, cmd)
expected_result = 'foo'
self.assertEqual(result, expected_result)
def test_get_host_for_command_for_local_uses_local_hostname(self):
cmd = Command('name', 'hostname')
cmd.run(validateAfter=True)
hostname = cmd.get_results().stdout.strip()
result = get_host_for_command(True, cmd)
expected_result = hostname
self.assertEqual(result, expected_result)
def test_get_command_creates_command_with_parameters_supplied(self):
host = 'foo'
cmd = 'bar'
result = get_command(True, cmd, host)
expected_result = Command(host, cmd)
self.assertEqual(result.name, expected_result.name)
self.assertEqual(result.cmdStr, expected_result.cmdStr)
def test_get_command_creates_command_with_remote_params_supplied(self):
host = 'foo'
cmd = 'bar'
result = get_command(False, cmd, host)
expected_result = Command(host, cmd, ctxt=REMOTE, remoteHost=host)
self.assertEqual(result.name, expected_result.name)
self.assertEqual(result.cmdStr, expected_result.cmdStr)
def test_get_copy_command_when_remote_does_scp(self):
host = 'foo'
datafile = 'bar'
tmpdir = '/tmp/foobar'
result = get_copy_command(False, host, datafile, tmpdir)
expected_result = Command(host, 'scp %s:%s %s/%s.data' % (host, datafile, tmpdir, host))
self.assertEqual(result.name, expected_result.name)
self.assertEqual(result.cmdStr, expected_result.cmdStr)
def test_get_copy_command_when_local_does_mv(self):
host = 'foo'
datafile = 'bar'
tmpdir = '/tmp/foobar'
result = get_copy_command(True, host, datafile, tmpdir)
expected_result = Command(host, 'mv -f %s %s/%s.data' % (datafile, tmpdir, host))
self.assertEqual(result.name, expected_result.name)
self.assertEqual(result.cmdStr, expected_result.cmdStr)
if __name__ == '__main__':
run_tests()
COMMAND NAME: gpcheck
Verifies and validates Greenplum Database platform settings.
*****************************************************
SYNOPSIS
*****************************************************
gpcheck {{-f | --file} <hostfile_gpcheck> | {-h | --host} <host_ID>
| --local } [-m <master_host>] [-s <standby_master_host>]
[--stdout | --zipout] [--config <config_file>]
gpcheck --zipin <gpcheck_zipfile>
gpcheck -?
gpcheck --version
*****************************************************
DESCRIPTION
*****************************************************
The gpcheck utility determines the platform on which you are running
Greenplum Database and validates various platform-specific configuration
settings. gpcheck can use a host file or a file previously created with
the --zipout option to validate platform settings. At the end of a
successful validation process, GPCHECK_NORMAL message displays. If
GPCHECK_ERROR displays, one or more validation checks failed. You can
use also gpcheck to gather and view platform settings on hosts without
running validation checks.
Greenplum recommends that you run gpcheck as root. If you do not run
gpcheck as root, the utility displays a warning message and will not be
able to validate all configuration settings; Only some of these settings
will be validated.
*****************************************************
OPTIONS
*****************************************************
--config <config_file>
The name of a configuration file to use instead of the default file
$GPHOME/etc/gpcheck.cnf. This file specifies the OS-specific checks to
run.
{-f | --file} <hostfile_gpcheck>
The name of a file that contains a list of hosts that gpcheck uses to
validate platform-specific settings. This file should contain a single
host name for all hosts in your Greenplum Database system (master,
standby master, and segments). gpcheck uses SSH to connect to the hosts.
{--h | --host} <host_ID>
Checks platform-specific settings on the host in your Greenplum Database
system specified by <host_ID>. gpcheck uses SSH to connect to the host.
--local
Checks platform-specific settings on the segment host where gpcheck is
run. This option does not require SSH authentication.
-m <master_host>
This option is deprecated and will be removed in a future release.
-s <standby_master_host>
This option is deprecated and will be removed in a future release.
--stdout
Display collected host information from gpcheck. No checks or
validations are performed.
--zipout
Save all collected data to a .zip file in the current working directory.
gpcheck automatically creates the .zip file and names it
gpcheck_<timestamp>.tar.gz. No checks or validations are performed.
--zipin <gpcheck_zipfile>
Use this option to decompress and check a .zip file created with the
--zipout option. gpcheck performs validation tasks against the file you
specify in this option.
-? (help)
Displays the online help.
--version
Displays the version of this utility.
*****************************************************
EXAMPLES
*****************************************************
Verify and validate the Greenplum Database platform settings by entering
a host file:
# gpcheck -f hostfile_gpcheck
Save Greenplum Database platform settings to a zip file:
# gpcheck -f hostfile_gpcheck --zipout
Verify and validate the Greenplum Database platform settings using a zip
file created with the --zipout option:
# gpcheck --zipin gpcheck_timestamp.tar.gz
View collected Greenplum Database platform settings:
# gpcheck -f hostfile_gpcheck --stdout
See Also
gpcheckperf
[global]
configfile_version = 3
[linux]
xfs_mount_options = rw,noatime,inode64,allocsize=16m
sysctl.kernel.shmmax = 500000000
sysctl.kernel.shmmni = 4096
sysctl.kernel.shmall = 4000000000
sysctl.kernel.sem = 500 1024000 200 4096
sysctl.kernel.sysrq = 1
sysctl.kernel.core_uses_pid = 1
sysctl.kernel.msgmnb = 65536
sysctl.kernel.msgmax = 65536
sysctl.kernel.msgmni = 2048
sysctl.net.ipv4.tcp_syncookies = 1
sysctl.net.ipv4.ip_forward = 0
sysctl.net.ipv4.conf.default.accept_source_route = 0
sysctl.net.ipv4.tcp_tw_recycle = 1
sysctl.net.ipv4.tcp_max_syn_backlog = 4096
sysctl.net.ipv4.conf.all.arp_filter = 1
sysctl.net.ipv4.ip_local_port_range = 1025 65535
sysctl.net.core.netdev_max_backlog = 10000
sysctl.vm.overcommit_memory = 2
#!/usr/bin/env python
'''
USAGE: gpcheck_hostdump [--appliance] [--linux]
where --appliance will do a dump of appliance server
where --linux will do a dump of a generic linux server
'''
import os, sys, re, tempfile, subprocess, pickle, glob, stat, time
try:
from optparse import Option, OptionParser
from gppylib.gpparseopts import OptParser, OptChecker
from gppylib.gpcheckutil import HostType, ApplianceOutputData, GenericLinuxOutputData
from gppylib.gpcheckutil import chkconfig, omreport, grubconf, mounts, GpMount, GpMount, inittab, ntp
from gppylib.gpcheckutil import securetty, ioschedulers, blockdev, bcu, rclocal, sysctl, limitsconf, limitsconf_entry, uname, connectemc
except ImportError, e:
sys.exit('Cannot import modules. Please check that you have sourced greenplum_path.sh. Detail: ' + str(e))
output = None
options = None
hosttype = HostType.GPCHECK_HOSTTYPE_UNDEFINED
def removeComments(line):
words = line.split("#")
if len(words) < 2:
return line
return words[0]
def collectChkconfigData():
data = chkconfig()
p = subprocess.Popen("/sbin/chkconfig --list", shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
result = p.communicate()
data.errormsg = result[1].strip()
if p.returncode:
return data
startxInet = False
for line in result[0].splitlines():
if not startxInet:
if re.search("xinetd based services", line):
startxInet = True
else:
words = line.split()
if len(words) != 8:
continue
levels = dict()
for i in range(1,8):
state = words[i].split(":")
if state[1] == 'on':
levels[state[0]] = True
else:
levels[state[0]] = False
data.services[words[0]] = levels
else:
words = line.split()
if len(words) != 2:
continue
name = words[0].split(":")
if words[1] == 'on':
data.xinetd[name[0]] = True
else:
data.xinetd[name[0]] = False
return data
# argument is a reference to instantiated omreport object
def omReportOmVersion(data):
# Obtain Dell OpenManage software version
p = subprocess.Popen("omreport system version", shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
result = p.communicate()
data.omversion_errormsg = result[1].strip()
if p.returncode:
return
nextLineisOurs = False
for line in result[0].splitlines():
words = line.split(":")
if len(words) != 2:
continue
if nextLineisOurs:
data.omversion = words[1].strip()
break
label = words[1].strip()
if label == 'Dell Server Administrator':
nextLineisOurs = True
# argument is a reference to instantiated omreport object
def omReportStorageController(data):
p = subprocess.Popen("omreport storage controller", shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
result = p.communicate()
data.controller_errormsg = result[1].strip()
if p.returncode:
return
for line in result[0].splitlines():
words = line.split(":")
if len(words) != 2:
continue
data.controller[words[0].strip()] = words[1].strip()
# argument is a reference to instantiated omreport object
def omReportStorageVdisk(data):
p = subprocess.Popen("omreport storage vdisk controller=0", shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
result = p.communicate()
data.vdisks_errormsg = result[1].strip()
if p.returncode:
return
counter = -1
for line in result[0].splitlines():
if re.search("ID\s*:", line):
counter += 1
data.vdisks.append(dict())
words = line.split(":")
if len(words) < 2:
continue
data.vdisks[counter][words[0].strip()] = ":".join(words[1:]).strip()
# argument is a reference to instantiated omreport object
def omReportChassisRemoteaccess(data):
p = subprocess.Popen("omreport chassis remoteaccess", shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
result = p.communicate()
if p.returncode:
# the remote access command on omreport is flaky... retry it once
p = subprocess.Popen("omreport chassis remoteaccess", shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
result = p.communicate()
data.remoteaccess_errormsg = result[1].strip()
if p.returncode:
data.remoteaccess_errormsg = "%s\nreturn code from omreport %d" % (data.remoteaccess_errormsg, p.returncode)
return
attribute = None
for line in result[0].splitlines():
if not attribute:
if re.search("Attribute :", line):
words = line.strip().split("Attribute :")
attribute = words[1].strip()
else:
if re.search("Value :", line):
words = line.strip().split("Value :")
data.remoteaccess[attribute] = words[1].strip()
attribute = None
# argument is a reference to instantiated omreport object
def omReportChassisBios(data):
p = subprocess.Popen("omreport chassis bios", shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
result = p.communicate()
data.bios_errormsg = result[1].strip()
if p.returncode:
return
for line in result[0].splitlines():
words = line.split(":")
if len(words) != 2:
continue
data.bios[words[0].strip()] = words[1].strip()
# argument is a reference to instantiated omreport object
def omReportChassisBiossetup(data):
p = subprocess.Popen("omreport chassis biossetup", shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
result = p.communicate()
data.biossetup_errormsg = result[1].strip()
if p.returncode:
return
attribute = None
for line in result[0].splitlines():
if not attribute:
if re.search("Attribute :", line):
words = line.strip().split("Attribute :")
attribute = words[1].strip()
else:
if re.search("Setting :", line):
words = line.strip().split("Setting :")
data.biossetup[attribute] = words[1].strip()
attribute = None
# argument is a reference to instantiated omreport object
def omReportSystemAlertlog(data):
p = subprocess.Popen("omreport system alertlog", shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
result = p.communicate()
data.alerts_errormsg = result[1].strip()
if p.returncode:
return
openAlert = False
for line in result[0].splitlines():
words = line.split(":")
if len(words) < 2:
openAlert = False
continue
if len(words) != 2 and len(words) != 4:
continue
key = words[0].strip()
if len(words) == 4:
if words[0].strip() != 'Date and Time':
continue
value = ":".join(words[1:])
else:
value = words[1].strip()
if key == 'Severity':
openAlert = False
# this is not an OK alert ... add it to the list and start adding attributes
if value != 'Ok':
workingDictionary = dict()
data.alerts.append(workingDictionary)
openAlert = True
if openAlert:
# add kvp to last element in list of alerts
data.alerts[-1][key] = value
# argument is a reference to instantiated omreport object
def omReportChassisBiossetupBootorder(data):
p = subprocess.Popen("omreport chassis biossetup attribute=bootorder", shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
result = p.communicate()
data.bootorder_errormsg = result[1].strip()
if p.returncode:
return
for line in result[0].splitlines():
if re.search("BIOS Hard Disk Sequence", line):
break
if re.search("Device Name :", line):
words = line.strip().split("Device Name :")
data.bootorder.append(words[1].strip())
# returns populated omreport object
def collectOmReports():
data = omreport()
omReportOmVersion(data)
omReportChassisBios(data)
omReportChassisBiossetup(data)
omReportChassisBiossetupBootorder(data)
omReportChassisRemoteaccess(data)
omReportStorageVdisk(data)
omReportStorageController(data)
omReportSystemAlertlog(data)
return data
def collectBcu():
data = bcu()
p = subprocess.Popen("bcu adapter --query 1", shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
result = p.communicate()
data.errormsg = result[1].strip()
if p.returncode:
return data
for line in result[0].splitlines():
if re.search("bios version:", line):
words = line.strip().split("bios version:")
if len(words) == 2:
data.biosversion = words[1].strip()
if re.search("fw version:", line):
words = line.strip().split("fw version:")
if len(words) == 2:
data.firmware = words[1].strip()
return data
# returns populated mounts object
def collectMounts():
data = mounts()
p = subprocess.Popen("mount", shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
result = p.communicate()
data.errormsg = result[1].strip()
if p.returncode:
return data
for line in result[0].splitlines():
mdata = GpMount()
words = line.strip().split()
mdata.partition = words[0]
mdata.dir = words[2]
mdata.type = words[4]
# get the options string
tmpa = words[5]
tmpb = tmpa.strip().strip("()")
tmpc = tmpb.split(",")
for op in tmpc:
mdata.options.add(op)
data.entries[mdata.partition] = mdata
return data
# returns populated blockdev object
def collectBlockdev():
data = blockdev()
devices = list()
try:
devices = glob.glob("/dev/sd*")
except Exception, e:
data.errormsg = e.__str__()
for d in devices:
p = subprocess.Popen("/sbin/blockdev --getra %s" % d, shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
result = p.communicate()
data.errormsg += result[1].strip()
if p.returncode:
continue
data.ra[d] = result[0].strip()
return data
# returns populated ioschedulers object
def collectIOschedulers():
data = ioschedulers()
devices = set()
try:
files = glob.glob("/sys/block/*/queue/scheduler")
for f in files:
words = f.split("/")
if len(words) != 6:
continue
devices.add(words[3].strip())
except Exception, e:
data.errormsg = e.__str__()
for d in devices:
try:
fd = open("/sys/block/%s/queue/scheduler" % d, 'r')
scheduler = fd.read()
words = scheduler.split("[")
if len(words) != 2:
continue
words = words[1].split("]")
if len(words) != 2:
continue
data.devices[d] = words[0].strip()
except Exception, e:
data.errormsg += e.__str__()
return data
# returns populated grubconf object
def collectGrubConf():
data = grubconf()
try:
for line in open("/boot/grub/grub.conf", "r"):
line = removeComments(line)
if re.search("^serial ", line):
data.serial_declaration = True
if re.search("^terminal ", line):
data.terminal_declaration = True
if re.search("kernel", line):
if re.search(" console=ttyS1,", line):
data.ttyS1_declaration = True
except Exception, e:
data.errormsg = e.__str__()
return data
# returns populated limitsconf object
def collectLimits():
data = limitsconf()
try:
for line in open("/etc/security/limits.conf", "r"):
line = removeComments(line)
words = line.split()
if len(words) != 4:
continue
domain = words[0].strip()
type = words[1].strip()
item = words[2].strip()
value = words[3].strip()
data.lines.append(limitsconf_entry(domain, type, item, value))
except Exception, e:
data.errormsg = e.__str__()
return data
# returns populated sysctl object
def collectSysctl():
data = sysctl()
try:
for line in open("/etc/sysctl.conf", "r"):
line = removeComments(line)
words = line.split("=")
if len(words) != 2:
continue
key = words[0].strip()
value = words[1].strip()
data.variables[key] = value
except Exception, e:
data.errormsg = e.__str__()
return data
# returns populated rclocal object
def collectRclocal():
data = rclocal()
data.isexecutable = False
try:
bits = os.stat('/etc/rc.d/rc.local')[stat.ST_MODE]
if bits & 0100:
data.isexecutable = True
except Exception, e:
pass
return data
# returns populated inittab object
def collectInittab():
data = inittab()
try:
for line in open("/etc/inittab", "r"):
if re.search("^id:", line):
words = line.split(":")
if len(words) > 2:
data.defaultRunLevel = words[1]
if re.search("^S1", line):
data.s1 = True
except Exception, e:
data.errormsg = e.__str__()
return data
# returns populated object of type: ntp
def collectNtpd():
data = ntp()
p = subprocess.Popen("/usr/sbin/ntpq -p", shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
result = p.communicate()
data.errormsg = result[1].strip()
if not p.returncode:
startHosts = False
for line in result[0].splitlines():
if startHosts:
words = line.split()
if len(words) < 2: # there are actually 10 fields but we only care about the first field
continue
host = words[0].strip()
if host.startswith("*"):
host = host.lstrip("*")
data.hosts.add(host)
else:
if re.search("======", line):
startHosts = True
p = subprocess.Popen("pgrep ntpd", shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
result = p.communicate()
if data.errormsg:
data.errormsg = "%s\n%s" % (data.errormsg, result[1].strip())
else:
data.errormsg = result[1].strip()
if not p.returncode:
for line in result[0].splitlines():
try:
pid = int(line.strip())
data.running = True
except:
pass
data.currenttime = time.time()
return data
# returns populated uname object
def collectUname():
data = uname()
p = subprocess.Popen("uname -r", shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
result = p.communicate()
data.errormsg = result[1].strip()
if p.returncode:
return data
data.output = result[0].strip()
return data
# returns populated connectemc object
def collectConnectemc():
data = connectemc()
p = subprocess.Popen("/etc/init.d/connectemc status", shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
result = p.communicate()
data.errormsg = result[1].strip()
if p.returncode:
return data
data.output = result[0].strip()
return data
# returns populated securetty object
def collectSecuretty():
data = securetty()
try:
for line in open("/etc/securetty", "r"):
val = line.strip()
data.data.add(val)
except Exception, e:
data.errormsg = e.__str__()
return data
def processGenericLinuxServer():
global output
output = GenericLinuxOutputData()
output.mounts = collectMounts()
output.uname = collectUname()
output.ioschedulers = collectIOschedulers()
output.blockdev = collectBlockdev()
output.sysctl = collectSysctl()
output.limitsconf = collectLimits()
output.ntp = collectNtpd()
def processApplianceServer():
global output
output = ApplianceOutputData()
output.chkconfig = collectChkconfigData()
output.omreport = collectOmReports()
output.grubconf = collectGrubConf()
output.mounts = collectMounts()
output.inittab = collectInittab()
output.uname = collectUname()
output.securetty = collectSecuretty()
output.ioschedulers = collectIOschedulers()
output.blockdev = collectBlockdev()
output.bcu = collectBcu()
output.rclocal = collectRclocal()
output.sysctl = collectSysctl()
output.limitsconf = collectLimits()
output.connectemc = collectConnectemc()
output.ntp = collectNtpd()
# True is an error
def parseargs():
global options, hosttype
parser = OptParser(option_class=OptChecker)
parser.remove_option('-h')
parser.add_option('-h', '-?', '--help', action='store_true')
parser.add_option('--appliance', action='store_true')
parser.add_option('--linux', action='store_true')
(options, args) = parser.parse_args()
global gphome
gphome = os.environ.get('GPHOME')
if not gphome:
logger.error("GPHOME not set")
return True
if options.help:
print __doc__
return True
if options.linux:
hosttype = HostType.GPCHECK_HOSTTYPE_GENERIC_LINUX
if options.appliance:
hosttype = HostType.GPCHECK_HOSTTYPE_APPLIANCE
if hosttype == HostType.GPCHECK_HOSTTYPE_UNDEFINED:
print "host type not specified on command line"
return True
return False
if (parseargs()):
sys.exit(1)
if hosttype == HostType.GPCHECK_HOSTTYPE_APPLIANCE:
processApplianceServer()
elif hosttype == HostType.GPCHECK_HOSTTYPE_GENERIC_LINUX:
processGenericLinuxServer()
(fd, filename) = tempfile.mkstemp(dir='/tmp', prefix='gpcheck_dump', text=True)
fd = open(filename, "wb")
pickle.dump(output, fd)
fd.close()
print filename
@gpcheck
Feature: Test gpcheck
Scenario: Run gpcheck --local as non-root without ssh permission
Given user does not have ssh permissions
When the user runs "gpcheck --local"
Then gpcheck should return a return code of 0
And gpcheck should print "gpcheck completing" to stdout
And user has ssh permissions
Scenario: Run gpcheck --host as non root with ssh permissions
Given we have exchanged keys with the cluster
When the user runs "gpcheck --host localhost"
Then gpcheck should return a return code of 0
And gpcheck should print "gpcheck completing" to stdout
Scenario: Negative tests cases command line options with --local
When the user runs "gpcheck --local --host foo"
Then gpcheck should return a return code of 0
And gpcheck should print "Only 1 of --file or --host or --local can be specified" to stdout
When the user runs "gpcheck --local --file foo"
Then gpcheck should return a return code of 0
And gpcheck should print "Only 1 of --file or --host or --local can be specified" to stdout
When the user runs "gpcheck --file bar --host foo"
Then gpcheck should return a return code of 0
And gpcheck should print "Only 1 of --file or --host or --local can be specified" to stdout
......@@ -633,21 +633,6 @@ def get_standby_host():
return []
@given('user does not have ssh permissions')
def impl(context):
user_home = os.environ.get('HOME')
authorized_keys_file = '%s/.ssh/authorized_keys' % user_home
if os.path.exists(os.path.abspath(authorized_keys_file)):
shutil.move(authorized_keys_file, '%s.bk' % authorized_keys_file)
@then('user has ssh permissions')
def impl(context):
user_home = os.environ.get('HOME')
authorized_keys_backup_file = '%s/.ssh/authorized_keys.bk' % user_home
if os.path.exists(authorized_keys_backup_file):
shutil.move(authorized_keys_backup_file, authorized_keys_backup_file[:-3])
def run_gpinitstandby(context, hostname, port, standby_data_dir, options='', remote=False):
if '-n' in options:
cmd = "gpinitstandby -a"
......@@ -798,12 +783,6 @@ def impl(context):
os.getenv("GPHOME") + '/greenplum_path.sh',
'export MASTER_DATA_DIRECTORY=%s' % context.standby_data_dir)
@given('we have exchanged keys with the cluster')
def impl(context):
hostlist = get_all_hostnames_as_list(context, 'template1')
host_str = ' -h '.join(hostlist)
cmd_str = 'gpssh-exkeys %s' % host_str
run_gpcommand(context, cmd_str)
def _process_exists(pid, host):
"""
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic
PUBLIC "-//OASIS//DTD DITA Composite//EN" "ditabase.dtd">
<topic id="topic1">
<!-- install_guide/refs/gpcheck.xml has a conref to this topic. -->
<title id="is142464">gpcheck</title>
<body>
<p>Verifies and validates Greenplum Database platform settings.</p>
<section id="section2">
<title>Synopsis</title>
<codeblock><b>gpcheck</b> {{<b>-f</b> | <b>--file</b>} <varname>hostfile_gpcheck</varname> | {<b>-h</b> | <b>--host</b>} <varname>host_ID</varname>| <b>--local</b> }
[<b>-m</b> <varname>master_host</varname>] [<b>-s</b> <varname>standby_master_host</varname>] [<b>--stdout</b> | <b>--zipout</b>]
[<b>--config</b> <varname>config_file</varname>]
<b>gpcheck</b> <b>--zipin</b> <varname>gpcheck_zipfile</varname>
<b>gpcheck</b> <b>-?</b>
<b>gpcheck</b> <b>--version</b></codeblock>
</section>
<section id="section3">
<title>Description</title>
<p>The <codeph>gpcheck</codeph> utility determines the platform on which you are running
Greenplum Database and validates various platform-specific configuration settings.
<codeph>gpcheck</codeph> can use a host file or a file previously created with
the <codeph>--zipout</codeph> option to validate platform settings. At the end of a
successful validation process, <codeph>GPCHECK_NORMAL</codeph> message displays. If
<codeph>GPCHECK_ERROR</codeph> displays, one or more validation checks failed.
You can use also <codeph>gpcheck</codeph> to gather and view platform settings on
hosts without running validation checks.</p>
<p>You should run <codeph>gpcheck</codeph> as <codeph>root</codeph>.
If you do not run <codeph>gpcheck</codeph> as <codeph>root</codeph>, the utility
displays a warning message and will not be able to validate all configuration
settings; Only some of these settings will be validated.</p>
</section>
<section id="section4">
<title>Options</title>
<parml>
<plentry>
<pt>--config <varname>config_file</varname></pt>
<pd>The name of a configuration file to use instead of the default file
<codeph>$GPHOME/etc/gpcheck.cnf</codeph> (or
<codeph>~/gpconfigs/gpcheck_dca_config</codeph> on the Dell EMC Greenplum
Data Computing Appliance). This file specifies the OS-specific checks to
run.</pd>
</plentry>
<plentry>
<pt>{-f | --file} <varname>hostfile_gpcheck</varname></pt>
<pd>The name of a file that contains a list of hosts that <codeph>gpcheck
</codeph>uses to validate platform-specific settings. This file should
contain a single host name for all hosts in your Greenplum Database system
(master, standby master, and segments). <codeph>gpcheck</codeph> uses SSH to
connect to the hosts.</pd>
</plentry>
<plentry>
<pt>{--h | --host} <varname>host_ID</varname></pt>
<pd>Checks platform-specific settings on the host in your Greenplum Database
system specified by <varname>host_ID</varname>. <codeph>gpcheck</codeph>
uses SSH to connect to the host. </pd>
</plentry>
<plentry>
<pt>--local</pt>
<pd>Checks platform-specific settings on the segment host where
<codeph>gpcheck</codeph> is run. This option does not require SSH
authentication. </pd>
</plentry>
<plentry>
<pt>-m <varname>master_host</varname></pt>
<pd>This option is deprecated and will be removed in a future release.</pd>
</plentry>
<plentry>
<pt>-s <varname>standby_master_host</varname></pt>
<pd>This option is deprecated and will be removed in a future release.</pd>
</plentry>
<plentry>
<pt>--stdout</pt>
<pd>Display collected host information from gpcheck. No checks or validations
are performed.</pd>
</plentry>
<plentry>
<pt>--zipout</pt>
<pd>Save all collected data to a <codeph>.zip</codeph> file in the current
working directory. <codeph>gpcheck</codeph> automatically creates the
<codeph>.zip</codeph> file and names it gpcheck_timestamp.tar.gz. No
checks or validations are performed.</pd>
</plentry>
<plentry>
<pt>--zipin <varname>gpcheck_zipfile</varname></pt>
<pd>Use this option to decompress and check a <codeph>.zip</codeph> file created
with the <codeph>--zipout</codeph> option. <codeph>gpcheck</codeph> performs
validation tasks against the file you specify in this option.</pd>
</plentry>
<plentry>
<pt>-? (help)</pt>
<pd>Displays the online help.</pd>
</plentry>
<plentry>
<pt>--version</pt>
<pd>Displays the version of this utility.</pd>
</plentry>
</parml>
</section>
<section id="section5">
<title>Examples</title>
<p>Verify and validate the Greenplum Database platform settings by entering a host
file:</p>
<codeblock># gpcheck -f hostfile_gpcheck </codeblock>
<p>Save Greenplum Database platform settings to a zip file:</p>
<codeblock># gpcheck -f hostfile_gpcheck --zipout</codeblock>
<p>Verify and validate the Greenplum Database platform settings using a zip file created
with the <codeph>--zipout</codeph> option:</p>
<codeblock># gpcheck --zipin gpcheck_timestamp.tar.gz</codeblock>
<p>View collected Greenplum Database platform settings:</p>
<codeblock># gpcheck -f hostfile_gpcheck --stdout</codeblock>
</section>
<section id="section6">
<title>See Also</title>
<p><codeph><xref href="gpssh.xml#topic1"/></codeph>, <codeph><xref
href="gpscp.xml#topic1"/></codeph>, <codeph><xref
href="./gpcheckperf.xml#topic1" type="topic" format="dita"/></codeph></p>
</section>
</body>
</topic>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册