Exemple #1
0
 def __init__(self,
              host='0.0.0.0',
              port=5601,
              elasticsearch_host=None,
              elasticsearch_port=None,
              elasticsearch_password='******',
              install_directory=INSTALL_DIRECTORY,
              configuration_directory=CONFIGURATION_DIRECTORY,
              log_directory=LOG_DIRECTORY):
     """
     :param host: The IP address to listen on (E.G "0.0.0.0")
     :param port: The port that the Kibana UI/API is bound to (E.G 5601)
     :param elasticsearch_host: A hostname/IP of the target elasticsearch instance
     :param elasticsearch_port: A port number for the target elasticsearch instance
     :param elasticsearch_password: The password used for authentication across all builtin ES users
     :param configuration_directory: Path to the configuration directory (E.G /etc/dynamite/kibana/)
     :param install_directory: Path to the install directory (E.G /opt/dynamite/kibana/)
     :param log_directory: Path to the log directory (E.G /var/log/dynamite/kibana/)
     """
     self.host = host
     self.port = port
     self.elasticsearch_host = elasticsearch_host
     self.elasticsearch_port = elasticsearch_port
     self.elasticsearch_password = elasticsearch_password
     if not elasticsearch_host:
         if ElasticProfiler().is_installed:
             self.elasticsearch_host = 'localhost'
         else:
             raise Exception(
                 "Elasticsearch must either be installed locally, or a remote host must be specified."
             )
     self.install_directory = install_directory
     self.configuration_directory = configuration_directory
     self.log_directory = log_directory
Exemple #2
0
 def _install_kibana_objects(self):
     if KibanaProfiler().is_installed and (ElasticProfiler().is_installed or self.elasticsearch_host != 'localhost'):
         if self.stdout:
             sys.stdout.write('[+] Installing Kibana Dashboards\n')
         if self.stdout:
             sys.stdout.write('[+] Waiting for ElasticSearch to become accessible.\n')
         # Start ElasticSearch if it is installed locally and is not running
         if self.elasticsearch_host in ['localhost', '127.0.0.1', '0.0.0.0', '::1', '::/128']:
             sys.stdout.write('[+] Starting ElasticSearch.\n')
             ElasticProcess().start(stdout=self.stdout)
             sys.stdout.flush()
             while not ElasticProfiler().is_listening:
                 if self.stdout:
                     sys.stdout.write('[+] Waiting for ElasticSearch API to become accessible.\n')
                 time.sleep(5)
             if self.stdout:
                 sys.stdout.write('[+] ElasticSearch API is up.\n')
                 sys.stdout.write('[+] Sleeping for 10 seconds, while ElasticSearch API finishes booting.\n')
                 sys.stdout.flush()
             time.sleep(10)
         kibana_process = KibanaProcess()
         kibana_process.optimize(stdout=self.stdout)
         utilities.set_ownership_of_file('/opt/dynamite/', user='******', group='dynamite')
         utilities.set_ownership_of_file('/etc/dynamite/', user='******', group='dynamite')
         time.sleep(5)
         sys.stdout.write('[+] Starting Kibana.\n')
         kibana_process.start(stdout=self.stdout)
         while not KibanaProfiler().is_listening:
             if self.stdout:
                 sys.stdout.write('[+] Waiting for Kibana API to become accessible.\n')
             time.sleep(5)
         if self.stdout:
             sys.stdout.write('[+] Kibana API is up.\n')
             sys.stdout.write('[+] Sleeping for 15 seconds, while Kibana API finishes booting.\n')
             sys.stdout.flush()
         time.sleep(15)
         api_config = KibanaAPIConfigurator(self.configuration_directory)
         kibana_object_create_attempts = 1
         while not api_config.create_elastiflow_saved_objects():
             if self.stdout:
                 sys.stdout.write('[+] Attempting to dashboards/visualizations [Attempt {}]\n'.format(
                     kibana_object_create_attempts))
             kibana_object_create_attempts += 1
             time.sleep(10)
         if self.stdout:
             sys.stdout.write('[+] Successfully created dashboards/visualizations.\n')
         kibana_process.stop()
Exemple #3
0
    def __init__(self,
                 elasticsearch_host=None,
                 elasticsearch_port=None,
                 elasticsearch_password='******',
                 jupyterhub_host=None,
                 jupyterhub_password='******',
                 configuration_directory=CONFIGURATION_DIRECTORY,
                 notebook_home=NOTEBOOK_HOME,
                 download_dynamite_sdk_archive=True,
                 stdout=False,
                 verbose=False):
        """
        :param elasticsearch_host: A hostname/IP of the target elasticsearch instance
        :param elasticsearch_port: A port number for the target elasticsearch instance
        :param elasticsearch_password: The password used for authentication across all builtin ES users
        :param jupyterhub_host: The host by which users can access this instance;
                                (Used for creating kibana -> Jupyter hyperlinks)
        :param jupyterhub_password: The password used for authenticating to jupyterhub (via jupyter user)
        :param configuration_directory: Path to the configuration directory (E.G /etc/dynamite/dynamite_sdk/)
        :param notebook_home: The path where Jupyter notebooks are stored
        :param download_dynamite_sdk_archive: If True, download the DynamiteSDK archive from a mirror
        :param stdout: Print output to console
        :param verbose: Include output from system utilities
        """

        self.elasticsearch_host = elasticsearch_host
        self.elasticsearch_port = elasticsearch_port
        self.elasticsearch_password = elasticsearch_password
        self.jupyterhub_host = jupyterhub_host
        self.jupyterhub_password = jupyterhub_password
        self.configuration_directory = configuration_directory
        self.notebook_home = notebook_home
        if download_dynamite_sdk_archive:
            self.download_dynamite_sdk(stdout=stdout)
            self.extract_dynamite_sdk(stdout=stdout)
        if not self.install_jupyterhub_dependencies(stdout=stdout,
                                                    verbose=verbose):
            raise Exception("Could not install jupyterhub dependencies.")
        if not self.install_jupyterhub(stdout=stdout):
            raise Exception("Could not install jupyterhub.")
        if stdout:
            sys.stdout.write('[+] Creating jupyter user in dynamite group.\n')
            sys.stdout.flush()
        utilities.create_jupyter_user(password=self.jupyterhub_password)
        self.stdout = stdout
        self.verbose = verbose

        if not elasticsearch_host:
            if ElasticProfiler().is_installed:
                self.elasticsearch_host = 'localhost'
            else:
                raise Exception(
                    "Elasticsearch must either be installed locally, or a remote host must be specified."
                )
Exemple #4
0
 def __init__(self,
              host='0.0.0.0',
              port=5601,
              elasticsearch_host=None,
              elasticsearch_port=None,
              elasticsearch_password='******',
              install_directory=INSTALL_DIRECTORY,
              configuration_directory=CONFIGURATION_DIRECTORY,
              log_directory=LOG_DIRECTORY,
              download_kibana_archive=True,
              stdout=True,
              verbose=False):
     """
     :param host: The IP address to listen on (E.G "0.0.0.0")
     :param port: The port that the Kibana UI/API is bound to (E.G 5601)
     :param elasticsearch_host: A hostname/IP of the target elasticsearch instance
     :param elasticsearch_port: A port number for the target elasticsearch instance
     :param elasticsearch_password: The password used for authentication across all builtin ES users
     :param configuration_directory: Path to the configuration directory (E.G /etc/dynamite/kibana/)
     :param install_directory: Path to the install directory (E.G /opt/dynamite/kibana/)
     :param log_directory: Path to the log directory (E.G /var/log/dynamite/kibana/)
     :param download_kibana_archive: If True, download the Kibana archive from a mirror
     :param stdout: Print the output to console
     :param verbose: Include output from system utilities
     """
     self.host = host
     self.port = port
     self.elasticsearch_host = elasticsearch_host
     self.elasticsearch_port = elasticsearch_port
     self.elasticsearch_password = elasticsearch_password
     if not elasticsearch_host:
         if ElasticProfiler().is_installed:
             self.elasticsearch_host = 'localhost'
         else:
             raise Exception(
                 "ElasticSearch must either be installed locally, or a remote host must be specified."
             )
     self.install_directory = install_directory
     self.configuration_directory = configuration_directory
     self.log_directory = log_directory
     self.stdout = stdout
     self.verbose = verbose
     if download_kibana_archive:
         self.download_kibana()
         self.extract_kibana()