Skip to content

Commit

Permalink
asadm improvements (#33)
Browse files Browse the repository at this point in the history
* TOOLS-971: (ASADM) Fix command history for Mac.

* TOOLS-975: (ASADM) Provide sindex and set filter for 'show statistics' command.

* TOOLS-1026: (ASADM) Fix collectinfo JSON dump error.

* TOOLS-1049: (ASADM) Modify show latency columns to display % sign.

* TOOLS-1052: (ASADM-HEALTHCHECK) Add more configurations in ignore list.

* TOOLS-1057: (ASADM) Modify to collect system stats for offline node

* TOOLS-1060: (ASADM) Use optimal lsof command line option, when running it for collectinfo.

* TOOLS-1061: (ASADM) Modify collectinfo to collect nvme* drive info.

* TOOLS-1064: (ASADM) Improve to show stack trace for exceptions.
  • Loading branch information
hbpatre authored Jan 24, 2018
1 parent 89aabe1 commit 98dbe24
Show file tree
Hide file tree
Showing 13 changed files with 1,411 additions and 1,048 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ Admin> help
sudo ./asadm-deps/install.sh
```

### Mac OSX
Run following command to ensure asadm history works properly:
```
sudo easy_install -a readline
```

## Tests
### Dependencies
- unittest2: 0.5.1
Expand Down
42 changes: 31 additions & 11 deletions asadm.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def critical(self, msg, *args, **kwargs):
from lib.client.ssl_context import SSLContext
from lib.collectinfocontroller import CollectinfoRootController
from lib.logcontroller import LogRootController
from lib.utils import util
from lib.utils import common, util
from lib.utils.constants import ADMIN_HOME
from lib.view import terminal, view

Expand All @@ -114,6 +114,9 @@ def __init__(self, seed, user=None, password=None, use_services_alumni=False, us
log_path="", log_analyser=False, collectinfo=False,
ssl_context=None, only_connect_seed=False, execute_only_mode=False, timeout=5):

# indicates shell created successfully and connected to cluster/collectinfo/logfile
self.connected = True

self.execute_only_mode = execute_only_mode

if log_analyser:
Expand Down Expand Up @@ -165,7 +168,12 @@ def __init__(self, seed, user=None, password=None, use_services_alumni=False, us

if not self.ctrl.cluster.get_live_nodes():
self.do_exit('')
logger.critical("Not able to connect any cluster.")
if self.execute_only_mode:
logger.error("Not able to connect any cluster.")
self.connected = False
return
else:
logger.critical("Not able to connect any cluster.")

self.prompt = "Admin> "
self.intro = ""
Expand Down Expand Up @@ -248,7 +256,7 @@ def precmd(self, line, max_commands_to_print_header=1,
if not lines: # allow empty lines
return ""
except Exception as e:
logger.error(str(e))
logger.error(e)
return ""

for line in lines:
Expand All @@ -271,7 +279,7 @@ def precmd(self, line, max_commands_to_print_header=1,
if response == "EXIT":
return "exit"
except Exception as e:
logger.error(str(e))
logger.error(e)
return "" # line was handled by execute

def _listdir(self, root):
Expand Down Expand Up @@ -717,7 +725,7 @@ def main():
ssl_context=ssl_context, line_separator=cli_args.line_separator)
exit(0)
except Exception as e:
logger.error(str(e))
logger.error(e)
exit(1)

if not execute_only_mode:
Expand Down Expand Up @@ -750,8 +758,12 @@ def main():
single_command = True
real_stdout = sys.stdout
if not execute_only_mode:
if not shell.connected:
exit(1)

func = shell.cmdloop
single_command = False

else:
commands_arg = cli_args.execute
max_commands_to_print_header = 1
Expand All @@ -771,13 +783,21 @@ def main():
except Exception as e:
print e

line = shell.precmd(commands_arg,
max_commands_to_print_header=max_commands_to_print_header,
command_index_to_print_from=command_index_to_print_from)
if shell.connected:
line = shell.precmd(commands_arg,
max_commands_to_print_header=max_commands_to_print_header,
command_index_to_print_from=command_index_to_print_from)

shell.onecmd(line)
func = shell.onecmd
args = (line,)
shell.onecmd(line)
func = shell.onecmd
args = (line,)

else:
if "collectinfo" in commands_arg:
logger.info("Collecting only System data")
func = common.collect_sys_info(port=cli_args.port)

exit(1)

cmdloop(shell, func, args, use_yappi, single_command)
shell.close()
Expand Down
Loading

0 comments on commit 98dbe24

Please sign in to comment.