Skip to content

Commit

Permalink
Merge branch 'release/0.0.11'
Browse files Browse the repository at this point in the history
  • Loading branch information
kportertx committed Jun 22, 2015
2 parents 72a6b5c + 56c4e3f commit dd6fb61
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 48 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ stat of their Aerospike Cluster. Start the tool with *python asadmin.py* and
run the *help* command to get started.

## Installing Aerospike Admin
```
make
sudo make install
```

## Running Aerospike Admin
asadmin -h <Aerospike Server Address>
Expand Down
5 changes: 3 additions & 2 deletions asadm.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@ def precmd(self, line):

sys.stdout.write(terminal.reset())
try:
self.ctrl.execute(line)
response = self.ctrl.execute(line)
if response == "EXIT":
return "exit"
except ShellException as e:
print "%sERR: %s%s"%(terminal.fg_red(), e, terminal.fg_clear())

return "" # line was handled by execute

def completenames(self, text, line, begidx, endidx):
Expand Down
2 changes: 1 addition & 1 deletion lib/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(self, seed_nodes=[('127.0.0.1',3000)]
@CommandHelp('Terminate session')
def do_exit(self, line):
# This function is a hack for autocomplete
raise Exception("Should not be possible to call")
return "EXIT"

@CommandHelp('Returns documentation related to a command'
, 'for example, to retrieve documentation for the "info"'
Expand Down
14 changes: 7 additions & 7 deletions lib/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def getfqdn(address, timeout=0.5):
# main thread

result = [address]

def helper():
result[0] = socket.getfqdn(address)

Expand Down Expand Up @@ -144,7 +144,7 @@ def isXDREnabled(self):
if isinstance(config, Exception):
return False


xdr_enabled = config['xdr']['enable-xdr']
return xdr_enabled == 'true'

Expand Down Expand Up @@ -208,7 +208,7 @@ def xdrInfo(self, command):
Arguments:
command -- the info command to execute on this node
"""

try:
return self._infoCInfo(command, self.xdr_port)
except Exception as e:
Expand Down Expand Up @@ -261,7 +261,7 @@ def infoServicesAlumni(self):
Returns:
list -- [(ip,port),...]
"""

try:
return self._infoServicesHelper(self.info("services-alumni"))
except IOError:
Expand Down Expand Up @@ -320,7 +320,7 @@ def infoSetStatistics(self):
stats = util.info_to_list(stats)
stats.pop()
stats = [util.info_colon_to_dict(stat) for stat in stats]

sets = {}
for stat in stats:
ns_name = stat['ns_name']
Expand Down Expand Up @@ -383,7 +383,7 @@ def infoGetConfig(self, stanza = "", namespace = ""):
namespace_config = namespace_config['namespace'][namespace]
namespace_configs[namespace] = namespace_config
config['namespace'] = namespace_configs

elif stanza == '':
config['service'] = util.info_to_dict(self.info("get-config:"))
elif stanza != 'all':
Expand Down Expand Up @@ -420,7 +420,7 @@ def infoLatency(self):
row.insert(0, "%s->%s"%(start_time, end_time))

data[hist_name] = (columns, row)

return data

@return_exceptions
Expand Down
50 changes: 32 additions & 18 deletions lib/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,17 @@

class Extractors(object):
# standard set of extractors

@staticmethod
def _numExtractor(column, system):
def _numExtractor(columns, system):
if not isinstance(columns, tuple):
columns = (columns,)

def si_extractor(data):
for column in columns:
if column in data:
break

if system == int:
return int(data[column])
elif system == float:
Expand All @@ -32,28 +39,35 @@ def si_extractor(data):
return si_extractor

@staticmethod
def floatExtractor(column):
return Extractors._numExtractor(column, float)
def floatExtractor(columns):
return Extractors._numExtractor(columns, float)

@staticmethod
def intExtractor(column):
return Extractors._numExtractor(column, int)
def intExtractor(columns):
return Extractors._numExtractor(columns, int)

@staticmethod
def sifExtractor(column):
return Extractors._numExtractor(column, filesize.sif)
def sifExtractor(columns):
return Extractors._numExtractor(columns, filesize.sif)

@staticmethod
def siExtractor(column):
return Extractors._numExtractor(column, filesize.si)
def siExtractor(columns):
return Extractors._numExtractor(columns, filesize.si)

@staticmethod
def byteExtractor(column):
return Extractors._numExtractor(column, filesize.byte)
def byteExtractor(columns):
return Extractors._numExtractor(columns, filesize.byte)

@staticmethod
def timeExtractor(column):
def timeExtractor(columns):
if not isinstance(columns, tuple):
columns = (columns,)

def t_extractor(data):
for column in columns:
if column in data:
break

time_stamp = int(data[column])
hours = time_stamp / 3600
minutes = (time_stamp % 3600) / 60
Expand Down Expand Up @@ -189,7 +203,7 @@ def insertRow(self, row_data):
is_alert = False
if column in self._cell_alert:
is_alert, color = self._cell_alert[column]

if is_alert and is_alert(row_data):
cell = (color, cell)
else:
Expand Down Expand Up @@ -220,7 +234,7 @@ def _do_group(self, data):
group_by = row[self._group_by]
if group_by not in grouped_data:
grouped_data[group_by] = []

grouped_data[group_by].append(row)

data = []
Expand Down Expand Up @@ -286,7 +300,7 @@ def genDescription(self, line_width, desc_width):
if words:
line = ' '.join(words)
lines.append(line)

description = ["%s%s%s"%(terminal.dim()
, l.center(line_width)
, terminal.reset()) for l in lines]
Expand Down Expand Up @@ -369,7 +383,7 @@ def _str_horizontal(self):

def _str_vertical(self):
output = []

title_width = sum(self._render_column_widths) + 1 # 1 for ":"
title_width += len(self._column_padding) * (len(self._render_column_widths) - 1)
output = [terminal.bold()]
Expand Down
4 changes: 2 additions & 2 deletions lib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def __getitem__(self, key):
value, eol = self.cache[key]
if eol > time():
return value

self[key] = self.func(*key)
return self.cache[key][0]

Expand Down Expand Up @@ -138,4 +138,4 @@ def capture_stdout(func,line=''):

output = capturer.getvalue()
sys.stdout = old
return output
return output
46 changes: 28 additions & 18 deletions lib/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,28 +155,33 @@ def infoNamespace(stats, cluster, **ignore):

title = "Namespace Information"
column_names = ('node'
,'namespace'
,('available_pct', 'Avail%')
,('evicted-objects', 'Evictions')
,'_objects'
,'repl-factor'
,'stop-writes'
,('_used-bytes-disk', 'Disk Used')
,('_used-disk-pct', 'Disk Used%')
,('high-water-disk-pct', 'HWM Disk%')
,('_used-bytes-memory', 'Mem Used')
,('_used-mem-pct', 'Mem Used%')
,('high-water-memory-pct', 'HWM Mem%')
,('stop-writes-pct', 'Stop Writes%'))
, 'namespace'
, ('available_pct', 'Avail%')
, ('evicted-objects', 'Evictions')
, ('_master-objects', 'Master Objects')
, ('_prole-objects', 'Replica Objects')
, 'repl-factor'
, 'stop-writes'
, ('_used-bytes-disk', 'Disk Used')
, ('_used-disk-pct', 'Disk Used%')
, ('high-water-disk-pct', 'HWM Disk%')
, ('_used-bytes-memory', 'Mem Used')
, ('_used-mem-pct', 'Mem Used%')
, ('high-water-memory-pct', 'HWM Mem%')
, ('stop-writes-pct', 'Stop Writes%'))

t = Table(title, column_names, group_by=1)
t.addDataSource('_used-bytes-disk'
,Extractors.byteExtractor('used-bytes-disk'))
t.addDataSource('_used-bytes-memory'
,Extractors.byteExtractor(
'used-bytes-memory'))
t.addDataSource('_objects'
,Extractors.sifExtractor('objects'))

t.addDataSource('_master-objects'
,Extractors.sifExtractor('master-objects'))

t.addDataSource('_prole-objects'
,Extractors.sifExtractor('prole-objects'))

t.addDataSource('_used-disk-pct'
, lambda data: 100 - int(data['free-pct-disk']))
Expand Down Expand Up @@ -245,10 +250,12 @@ def infoXDR(stats, builds, xdr_enable, cluster, **ignore):

t = Table(title, column_names)

t.addDataSource('_xdr-uptime', Extractors.timeExtractor('xdr-uptime'))
t.addDataSource('_xdr-uptime', Extractors.timeExtractor(
('xdr-uptime', 'xdr_uptime')))

t.addDataSource('_bytes-shipped',
Extractors.byteExtractor('esmt-bytes-shipped'))
Extractors.byteExtractor(
('esmt-bytes-shipped', 'esmt_bytes_shipped')))

t.addDataSource('_lag-secs',
Extractors.timeExtractor('timediff_lastship_cur_secs'))
Expand Down Expand Up @@ -279,7 +286,10 @@ def infoXDR(stats, builds, xdr_enable, cluster, **ignore):
if xdr_enable[node_key]:
if row:
row['build'] = builds[node_key]
row['_free-dlog-pct'] = row['free-dlog-pct'][:-1]
if 'free_dlog_pct' in row:
row['_free-dlog-pct'] = row['free_dlog_pct'][:-1]
else:
row['_free-dlog-pct'] = row['free-dlog-pct'][:-1]
else:
row = {}
row['node-id'] = node.node_id
Expand Down

0 comments on commit dd6fb61

Please sign in to comment.