提交 eee440e6 编写于 作者: T Tyler Ramer 提交者: Tyler Ramer

Remove gpsys1

I'm not quite sure of the purpose of this utility, nor, apparently, is
any readme or historical repo.

Apart from a small fix provided in
commit 71d67305,
there has been no modification to this file since at least 2008. More
importantly, I'm not quite sure of any reasonable use for this file. The
supported platforms are only linux, darwin, or sunos5, and the listed
use, of printing the memory size in bytes, is trivial on any of those
systems without resorting to some python script that wraps a command line
call.

Given that it hasn't been updated since 2008, it's still compatible with
some ancient version of python, which means that it's yet another file to
upgrade to python 3 - in this case, let's drop the program, rather than
bother upgrading it.
Authored-by: NTyler Ramer <tramer@pivotal.io>
上级 f91e2d81
......@@ -575,7 +575,6 @@ SET_VERSION_SCRIPTS = \
bin/gpstart \
bin/gpstate \
bin/gpstop \
bin/gpsys1 \
bin/lib/gpcheckcat \
sbin/gpconfig_helper.py \
sbin/gpcleansegmentdir.py \
......
......@@ -22,5 +22,4 @@ ext
/gpstartc
/gpstatec
/gpstopc
/gpsys1c
/minireproc
......@@ -16,7 +16,7 @@ PROGRAMS= analyzedb gpactivatestandby gpaddmirrors gpcheckcat gpcheckperf \
gpcheckresgroupimpl gpconfig gpdeletesystem gpexpand gpinitstandby \
gpinitsystem gpload gpload.py gplogfilter gpmovemirrors \
gppkg gprecoverseg gpreload gpscp gpsd gpssh gpssh-exkeys gpstart \
gpstate gpstop gpsys1 minirepro
gpstate gpstop minirepro
installdirs:
$(MKDIR_P) '$(DESTDIR)$(bindir)/lib'
......@@ -242,5 +242,5 @@ clean distclean:
gpcheckperfc gpcheckresgroupimplc gpchecksubnetcfgc gpconfigc \
gpdeletesystemc gpexpandc gpinitstandbyc gplogfilterc gpmovemirrorsc \
gppkgc gprecoversegc gpreloadc gpscpc gpsdc gpssh-exkeysc gpsshc \
gpstartc gpstatec gpstopc gpsys1c minireproc
gpstartc gpstatec gpstopc minireproc
rm -f gpconfig_modules/gucs_disallowed_in_file.txt
......@@ -35,7 +35,6 @@ bin/gpload - Sets env variables and calls gpload.py
List of Management Scripts Written in Python (no libraries)
-----------------------------------------------------------
bin/gpload.py - Loads data into a Greenplum Database
bin/gpsys1 - Print system information on a host (???)
List of Management Scripts Written in Python (gpmlib - old libraries)
......
#!/usr/bin/env python
"""
gpsys1 -- print system info on a host
Usage:
gpsys1 [--version] [-?amp]
--version : print version information
-? : print this help screen
-a : [default] print "platform memory"
-m : print "memory"
-p : print "platform"
Output:
platform: can be 'linux', 'darwin' or 'sunos5'
memory: system memory installed in bytes
e.g. linux 1073741824
"""
import sys, os, getopt
script_name = os.path.split(__file__)[-1]
opt = {}
opt['-a'] = False
opt['-m'] = False
opt['-p'] = False
################
def usage(exitarg):
help_path = os.path.join(sys.path[0], '..', 'docs', 'cli_help', script_name + '_help');
try:
f = open(help_path);
for line in f:
print line,
except:
print __doc__
sys.exit(exitarg)
#############
def print_version():
print '%s version $Revision$' % script_name
sys.exit(0)
################
def parseCommandLine():
global opt
try:
(options, args) = getopt.getopt(sys.argv[1:], '?amp', ['version'])
except Exception, e:
usage('Error: ' + str(e))
for (switch, val) in options:
if (switch == '-?'): usage(0)
elif switch == '--version': print_version()
else: opt[switch] = True
val = False
for k in opt:
val = val or opt[k]
if not val: opt['-a'] = True
################
def run(cmd):
f = None
ok = False
out = None
try:
f = os.popen(cmd)
out = f.read()
ok = not f.close()
except:
f.close()
ok = False
return (ok, out)
################
def getPlatform():
if sys.platform.find('linux') >= 0: return 'linux'
if sys.platform.find('darwin') >= 0: return 'darwin'
if sys.platform.find('sunos5') >= 0: return 'sunos5'
return '?'
################
def getMemory():
if getPlatform() == 'linux':
ok, out = run("sh -c 'cat /proc/meminfo | grep MemTotal'")
if not ok: return '?'
list = out.strip().split(' ')
val = int(list[len(list) - 2])
factor = list[len(list) - 1]
if factor == 'kB': return val * 1024
return '?'
if getPlatform() == 'darwin':
ok, out = run("sysctl hw.memsize")
if not ok: return '?'
list = out.strip().split(' ')
val = int(list[1])
return val
if getPlatform() == 'sunos5':
ok, out = run("sh -c \"prtconf | awk '/^Memory/{print}'\"")
if not ok: return '?'
list = out.strip().split(' ')
val = int(list[2])
factor = list[3]
if factor == 'Megabytes': return val * 1024 * 1024
return '?'
return '?'
################
parseCommandLine()
if opt['-a'] or opt['-p']:
try:
v = getPlatform()
except:
v = '?'
print v,
if opt['-a'] or opt['-m']:
try:
v = getMemory()
except:
v = '?'
print v,
print
......@@ -12,7 +12,7 @@ DOCS= gpactivatestandby_help gpaddmirrors_help gpcheckperf_help \
gpinitstandby_help gpinitsystem_help gpload_help gplogfilter_help \
gpmapreduce_help gppkg_help gprecoverseg_help \
gpreload_help gpscp_help gpssh-exkeys_help gpssh_help gpstart_help \
gpstate_help gpstop_help gpsys1_help
gpstate_help gpstop_help
installdirs:
$(MKDIR_P) '$(DESTDIR)$(prefix)/docs/cli_help'
......
COMMAND NAME: gpsys1
Displays information about your operating system.
*****************************************************
SYNOPSIS
*****************************************************
gpsys1 [ -a | -m | -p ]
gpsys1 -?
gpsys1 --version
*****************************************************
DESCRIPTION
*****************************************************
gpsys1 displays the platform and installed memory (in bytes)
of the current host. For example:
linux 1073741824
*****************************************************
OPTIONS
*****************************************************
-a (show all)
Shows both platform and memory information for the current
host. This is the default.
-m (show memory only)
Shows system memory installed in bytes.
-p (show platform only)
Shows the OS platform. Platform can be linux, darwin or sunos5.
-? (help)
Displays the online help.
--version
Displays the version of this utility.
*****************************************************
EXAMPLES
*****************************************************
Show information about the current host operating system:
gpsys1
*****************************************************
SEE ALSO
*****************************************************
gpcheckperf
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册