diff --git a/apps/jumpserver/settings.py b/apps/jumpserver/settings.py index 7a8aa422e..89686cada 100644 --- a/apps/jumpserver/settings.py +++ b/apps/jumpserver/settings.py @@ -373,7 +373,8 @@ CAPTCHA_FOREGROUND_COLOR = '#001100' CAPTCHA_NOISE_FUNCTIONS = ('captcha.helpers.noise_dots',) CAPTCHA_TEST_MODE = CONFIG.CAPTCHA_TEST_MODE -COMMAND_STORAGE_BACKEND = 'terminal.backends.command.db' +#COMMAND_STORAGE_BACKEND = 'terminal.backends.command.db' +COMMAND_STORAGE_BACKEND = 'terminal.backends.command.es' # Django bootstrap3 setting, more see http://django-bootstrap3.readthedocs.io/en/latest/settings.html BOOTSTRAP3 = { diff --git a/apps/terminal/backends/command/es.py b/apps/terminal/backends/command/es.py new file mode 100644 index 000000000..39c83f09d --- /dev/null +++ b/apps/terminal/backends/command/es.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# + +from jms_es_storage import ESStore +from .base import CommandBase + + +class CommandStore(CommandBase, ESStore): + def __init__(self): + ESStore.__init__(self, hosts=["http://elastic:changeme@localhost:9200"]) + + def save(self, command): + return ESStore.save(self, command) + + def bulk_save(self, commands): + return ESStore.bulk_save(self, commands) + + def filter(self, date_from=None, date_to=None, + user=None, asset=None, system_user=None, + input=None, session=None): + + data = ESStore.filter( + self, date_from=date_from, date_to=date_to, + user=user, asset=asset, system_user=system_user, + input=input, session=session + ) + return [item["_source"] for item in data["hits"] if item]